use of com.blackducksoftware.integration.hub.rest.UnauthenticatedRestConnection in project hub-alert by blackducksoftware.
the class HipChatChannelTest method testGlobalConfigThrowsExceptionTest.
@Test
public void testGlobalConfigThrowsExceptionTest() throws IntegrationException, MalformedURLException {
final ChannelRestConnectionFactory restFactory = Mockito.mock(ChannelRestConnectionFactory.class);
final HipChatChannel hipChatChannel = new HipChatChannel(null, null, null, null, null, restFactory);
RestConnection restConnection = new UnauthenticatedRestConnection(new PrintStreamIntLogger(System.out, LogLevel.INFO), new URL("http://google.com"), 100, null, new UriCombiner());
restConnection = Mockito.spy(restConnection);
Mockito.doThrow(new IntegrationException("Mock exception")).when(restConnection).connect();
Mockito.when(restFactory.createUnauthenticatedRestConnection(Mockito.anyString())).thenReturn(restConnection);
hipChatMockUtil.setApiKey("apiKey");
try {
final GlobalHipChatConfigEntity entity = hipChatMockUtil.createGlobalEntity();
hipChatChannel.testGlobalConfig(entity);
} catch (final IntegrationException ex) {
assertEquals("Invalid API key: Mock exception", ex.getMessage());
}
}
Aggregations