use of net.nemerosa.ontrack.client.JsonClient in project ontrack by nemerosa.
the class DefaultJenkinsClientTest method before.
@Before
public void before() {
OTHttpClient httpClient = mock(OTHttpClient.class);
when(httpClient.getUrl(anyString(), any(String[].class))).thenAnswer(invocation -> {
String path = (String) invocation.getArguments()[0];
String parameters = (String) invocation.getArguments()[1];
return String.format("http://jenkins/%s", String.format(path, parameters));
});
JsonClient jsonClient = new JsonClientImpl(httpClient);
jenkinsClient = new DefaultJenkinsClient(jsonClient);
}
use of net.nemerosa.ontrack.client.JsonClient in project ontrack by nemerosa.
the class JIRASessionFactoryImpl method create.
@Override
public JIRASession create(JIRAConfiguration configuration) {
// Creates a HTTP JSON client
JsonClient jsonClient = clientFactory.getJsonClient(new ClientConnection(configuration.getUrl(), configuration.getUser(), configuration.getPassword()));
// Creates the client
JIRAClient client = new JIRAClientImpl(jsonClient);
// Creates the session
return new JIRASession() {
@Override
public JIRAClient getClient() {
return client;
}
@Override
public void close() {
client.close();
}
};
}
use of net.nemerosa.ontrack.client.JsonClient in project ontrack by nemerosa.
the class ArtifactoryClientImplTest method buildNumbersEmptyForBuildNotFound.
@Test
public void buildNumbersEmptyForBuildNotFound() {
JsonClient jsonClient = mock(JsonClient.class);
when(jsonClient.get("/api/build/%s", "PROJECT")).thenThrow(new ClientNotFoundException("Not found"));
ArtifactoryClientImpl client = new ArtifactoryClientImpl(jsonClient);
assertEquals(Collections.<String>emptyList(), client.getBuildNumbers("PROJECT"));
}
use of net.nemerosa.ontrack.client.JsonClient in project ontrack by nemerosa.
the class ArtifactoryClientImplTest method buildNumbers.
@Test
public void buildNumbers() {
JsonClient jsonClient = mock(JsonClient.class);
when(jsonClient.get("/api/build/%s", "PROJECT")).thenReturn(object().with("buildsNumbers", array().with(object().with("uri", "/1").end()).with(object().with("uri", "/2").end()).end()).end());
ArtifactoryClientImpl client = new ArtifactoryClientImpl(jsonClient);
assertEquals(Arrays.asList("1", "2"), client.getBuildNumbers("PROJECT"));
}
Aggregations