use of com.blackducksoftware.integration.hub.alert.web.ObjectTransformer in project hub-alert by blackducksoftware.
the class HubDataHandlerTest method testGetHubProjectsThrowIntegrationException.
@Test
public void testGetHubProjectsThrowIntegrationException() throws Exception {
final ObjectTransformer objectTransformer = new ObjectTransformer();
final Gson gson = new Gson();
final HubDataActions hubDataActions = Mockito.mock(HubDataActions.class);
Mockito.when(hubDataActions.getHubProjects()).thenThrow(new IntegrationException("ErrorMessage"));
final HubDataHandler hubDataHandler = new HubDataHandler(objectTransformer, gson, hubDataActions);
final ResponseEntity<String> responseEntity = hubDataHandler.getHubProjects();
assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
assertEquals("{\"id\":-1,\"message\":\"ErrorMessage\"}", responseEntity.getBody());
}
use of com.blackducksoftware.integration.hub.alert.web.ObjectTransformer in project hub-alert by blackducksoftware.
the class HubDataHandlerTest method testGetHubGroupsThrowIntegrationRestException.
@Test
public void testGetHubGroupsThrowIntegrationRestException() throws Exception {
final ObjectTransformer objectTransformer = new ObjectTransformer();
final Gson gson = new Gson();
final HubDataActions hubDataActions = Mockito.mock(HubDataActions.class);
Mockito.when(hubDataActions.getHubGroups()).thenThrow(new IntegrationRestException(402, "StatusMessage", "ErrorMessage"));
final HubDataHandler hubDataHandler = new HubDataHandler(objectTransformer, gson, hubDataActions);
final ResponseEntity<String> responseEntity = hubDataHandler.getHubGroups();
assertEquals(HttpStatus.PAYMENT_REQUIRED, responseEntity.getStatusCode());
assertEquals("{\"id\":-1,\"message\":\"StatusMessage : ErrorMessage: 402: StatusMessage\"}", responseEntity.getBody());
}
use of com.blackducksoftware.integration.hub.alert.web.ObjectTransformer in project hub-alert by blackducksoftware.
the class HubDataHandlerTest method testGetHubProjectsThrowIntegrationRestException.
@Test
public void testGetHubProjectsThrowIntegrationRestException() throws Exception {
final ObjectTransformer objectTransformer = new ObjectTransformer();
final Gson gson = new Gson();
final HubDataActions hubDataActions = Mockito.mock(HubDataActions.class);
Mockito.when(hubDataActions.getHubProjects()).thenThrow(new IntegrationRestException(402, "StatusMessage", "ErrorMessage"));
final HubDataHandler hubDataHandler = new HubDataHandler(objectTransformer, gson, hubDataActions);
final ResponseEntity<String> responseEntity = hubDataHandler.getHubProjects();
assertEquals(HttpStatus.PAYMENT_REQUIRED, responseEntity.getStatusCode());
assertEquals("{\"id\":-1,\"message\":\"StatusMessage : ErrorMessage: 402: StatusMessage\"}", responseEntity.getBody());
}
use of com.blackducksoftware.integration.hub.alert.web.ObjectTransformer in project hub-alert by blackducksoftware.
the class HubDataHandlerTest method testGetHubGroups.
@Test
public void testGetHubGroups() throws Exception {
final ObjectTransformer objectTransformer = new ObjectTransformer();
final Gson gson = new Gson();
final HubDataActions hubDataActions = Mockito.mock(HubDataActions.class);
Mockito.when(hubDataActions.getHubGroups()).thenReturn(Collections.emptyList());
final HubDataHandler hubDataHandler = new HubDataHandler(objectTransformer, gson, hubDataActions);
final ResponseEntity<String> responseEntity = hubDataHandler.getHubGroups();
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
assertEquals("{\"id\":-1,\"message\":\"[]\"}", responseEntity.getBody());
}
use of com.blackducksoftware.integration.hub.alert.web.ObjectTransformer in project hub-alert by blackducksoftware.
the class HipChatManagerTest method getChannelManager.
@Override
public HipChatManager getChannelManager() {
final HipChatChannel mockChannel = Mockito.mock(HipChatChannel.class);
final GlobalHipChatRepositoryWrapper mockGlobalRepositoryWrapper = Mockito.mock(GlobalHipChatRepositoryWrapper.class);
final HipChatDistributionRepositoryWrapper mockRepositoryWrapper = Mockito.mock(HipChatDistributionRepositoryWrapper.class);
final HipChatManager manager = new HipChatManager(mockChannel, mockGlobalRepositoryWrapper, mockRepositoryWrapper, new ObjectTransformer());
return manager;
}
Aggregations