use of com.synopsys.integration.rest.client.IntHttpClient in project hub-alert by blackducksoftware.
the class DockerTagRetrieverTest method getTagsModelTest.
@Test
public void getTagsModelTest() throws IntegrationException {
IntHttpClient intHttpClient = Mockito.mock(IntHttpClient.class);
Response mockResponse = createMockResponse();
Mockito.when(intHttpClient.execute(Mockito.any(Request.class))).thenReturn(mockResponse);
DockerTagRetriever dockerTagRetriever = new DockerTagRetriever(gson, intHttpClient);
DockerTagsResponseModel tagsModel = dockerTagRetriever.getTagsModel();
assertEquals(TAGS_COUNT, tagsModel.getCount());
assertEquals(TAGS_COUNT, tagsModel.getResults().size());
}
use of com.synopsys.integration.rest.client.IntHttpClient in project hub-alert by blackducksoftware.
the class DockerTagRetrieverTest method getTagsModelTestIT.
@Test
@Tags({ @Tag(TestTags.DEFAULT_INTEGRATION), @Tag(TestTags.CUSTOM_EXTERNAL_CONNECTION) })
public void getTagsModelTestIT() throws IntegrationException {
IntLogger intLogger = new PrintStreamIntLogger(System.out, LogLevel.INFO);
IntHttpClient intHttpClient = new IntHttpClient(intLogger, gson, 10, true, ProxyInfo.NO_PROXY_INFO);
HttpUrl httpUrl = new HttpUrl("https://google.com");
Request testRequest = new Request.Builder(httpUrl).build();
try (Response googleResponse = intHttpClient.execute(testRequest)) {
googleResponse.throwExceptionForError();
} catch (IntegrationException | IOException e) {
assumeTrue(null == e, "Could not connect. Skipping this test...");
}
DockerTagRetriever dockerTagRetriever = new DockerTagRetriever(gson, intHttpClient);
DockerTagsResponseModel tagsModel = dockerTagRetriever.getTagsModel();
assertFalse(tagsModel.isEmpty(), "Expected tags from the docker repo to exist");
}
use of com.synopsys.integration.rest.client.IntHttpClient in project hub-alert by blackducksoftware.
the class RestChannelUtilityTest method sendMessageSuccessTest.
@Test
public void sendMessageSuccessTest() throws IntegrationException {
Response response = createMockResponse(HttpStatus.OK);
IntHttpClient intHttpClient = createMockHttpClientWithResponse(response);
RestChannelUtility restChannelUtility = new RestChannelUtility(intHttpClient);
try {
restChannelUtility.sendMessage(List.of(TEST_REQUEST, TEST_REQUEST), CLASS_NAME);
} catch (AlertException e) {
fail("Expected no exception to be thrown", e);
}
}
use of com.synopsys.integration.rest.client.IntHttpClient in project hub-alert by blackducksoftware.
the class ChannelRestConnectionFactory method createIntHttpClient.
public IntHttpClient createIntHttpClient(String baseUrl, IntLogger intLogger, int timeout) {
Optional<Boolean> alertTrustCertificate = alertProperties.getAlertTrustCertificate();
ProxyInfo proxyInfo = proxyManager.createProxyInfoForHost(baseUrl);
return new IntHttpClient(intLogger, gson, timeout, alertTrustCertificate.orElse(Boolean.FALSE), proxyInfo);
}
use of com.synopsys.integration.rest.client.IntHttpClient in project hub-alert by blackducksoftware.
the class RestChannelUtilityTest method sendMessageAlertExceptionTest.
@Test
public void sendMessageAlertExceptionTest() throws IntegrationException {
Response response = createMockResponse(HttpStatus.BAD_REQUEST);
IntHttpClient intHttpClient = createMockHttpClientWithResponse(response);
RestChannelUtility restChannelUtility = new RestChannelUtility(intHttpClient);
try {
restChannelUtility.sendMessage(List.of(TEST_REQUEST, TEST_REQUEST), CLASS_NAME);
fail("Expected an exception to be thrown");
} catch (AlertException e) {
// Pass
}
}
Aggregations