use of com.blackducksoftware.integration.hub.alert.web.ObjectTransformer in project hub-alert by blackducksoftware.
the class GlobalHubConfigActionsTest method testChannelTestConfig.
@Test
@Override
public void testChannelTestConfig() throws Exception {
final MockGlobalHubRestModel mockUtils = new MockGlobalHubRestModel();
final RestConnection mockedRestConnection = Mockito.mock(RestConnection.class);
final GlobalHubRepositoryWrapper mockedGlobalRepository = Mockito.mock(GlobalHubRepositoryWrapper.class);
final TestGlobalProperties globalProperties = new TestGlobalProperties(mockedGlobalRepository);
GlobalHubConfigActions configActions = new GlobalHubConfigActions(mockedGlobalRepository, globalProperties, new ObjectTransformer());
configActions = Mockito.spy(configActions);
Mockito.doAnswer(new Answer<RestConnection>() {
@Override
public RestConnection answer(final InvocationOnMock invocation) throws Throwable {
return mockedRestConnection;
}
}).when(configActions).createRestConnection(Mockito.any(HubServerConfigBuilder.class));
Mockito.doNothing().when(configActions).validateHubConfiguration(Mockito.any(HubServerConfigBuilder.class));
configActions.testConfig(mockUtils.createGlobalRestModel());
Mockito.verify(mockedRestConnection, Mockito.times(1)).connect();
Mockito.reset(mockedRestConnection);
final GlobalHubConfigRestModel restModel = mockUtils.createGlobalRestModel();
final String result = configActions.channelTestConfig(restModel);
assertEquals("Successfully connected to the Hub.", result);
Mockito.verify(mockedRestConnection, Mockito.times(1)).connect();
}
Aggregations