Commit 6032260f authored by Maxym Borodenko's avatar Maxym Borodenko
Browse files

just testing CI task

parent 92b1cbaf
stages:
- compile
- test-oauth
- deploy
run tests in branches:
......@@ -11,6 +12,16 @@ run tests in branches:
- master
- /^genesys\-client\-api\-/
run tests for OAuth in branches:
stage: test-oauth
image: maven:3-jdk-8
script:
# - MAVEN_OPTS="${MAVEN_OPTS} -Dorg.slf4j.simpleLogger.defaultLogLevel=warn -Dbase.url=${BASE_URL} -Dclient.key=${CLIENT_KEY} -Dclient.secret=${CLIENT_SECRET}" mvn test -B
- MAVEN_OPTS="${MAVEN_OPTS} -Dorg.slf4j.simpleLogger.defaultLogLevel=warn" mvn test -B -Dtest=SandboxApiTest -Dbase.url=testUrl -Dclient.key=testClientKey -Dclient.secret=testClientSecret
except:
- master
- /^genesys\-client\-api\-/
publish snapshot artifacts:
stage: deploy
image: maven:3-jdk-8
......
......@@ -69,6 +69,9 @@
<argLine>-Xms512m -Xmx1024m</argLine>
<useSystemClassLoader>false</useSystemClassLoader>
<testFailureIgnore>false</testFailureIgnore>
<excludes>
<exclude>**/SandboxApiTest.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
......
/*
* Copyright 2020 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.geneys2.client.oauth.sandbox;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.util.HashMap;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.genesys2.client.oauth.GenesysApiException;
import org.genesys2.client.oauth.GenesysClient;
import org.genesys2.client.oauth.OAuthAuthenticationException;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
/**
* @author Maxym Borodenko
*/
@RunWith(MockitoJUnitRunner.class)
public class SandboxApiTest {
/** The object mapper. */
private static final ObjectMapper objectMapper;
protected static GenesysClient genesysClient;
static {
objectMapper = new ObjectMapper();
}
@BeforeClass
public static void initGenesysClient() {
final String baseUrl = System.getProperty("base.url");
assertThat(baseUrl, not(isEmptyOrNullString()));
final String clientKey = System.getProperty("client.key");
assertThat(clientKey, not(isEmptyOrNullString()));
final String clientSecret = System.getProperty("client.secret");
assertThat(clientSecret, not(isEmptyOrNullString()));
System.out.println("base.url -------- " + baseUrl);
System.out.println("client.key -------- " + clientKey);
System.out.println("client.secret -------- " + clientSecret);
// genesysClient = new GenesysClient(baseUrl, clientKey, clientSecret, "oob", "write");
// assertThat(genesysClient, notNullValue());
//
// try {
// genesysClient.authenticate();
// final String accessToken = genesysClient.getTokens().getAccessToken();
// assertThat(accessToken, not(isEmptyOrNullString()));
// } catch (OAuthAuthenticationException e) {
// fail("Failed while trying to authenticate: " + e.getMessage());
// }
}
@Test
public void getMeTest() {
// try {
// String me = genesysClient.me();
// HashMap<String, Object> user = objectMapper.readValue(me, HashMap.class);
// assertThat(user.get("sid"), is(equalTo(System.getProperty("client.key"))));
// assertThat((int) user.get("id"), is(greaterThan(0)));
// } catch (GenesysApiException e) {
// fail("Failed while trying to fetch the profile.");
// } catch (IOException e) {
// fail("Failed while trying to parse the profile data: " + e.getMessage());
// }
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment