use of com.blackducksoftware.integration.hub.alert.exception.AlertException in project hub-alert by blackducksoftware.
the class HubDataActionsTest method testGetHubProjectsNullHubServicesFactory.
@Test
public void testGetHubProjectsNullHubServicesFactory() throws Exception {
final GlobalProperties globalProperties = Mockito.mock(GlobalProperties.class);
Mockito.when(globalProperties.createHubServicesFactory(Mockito.any(Logger.class))).thenReturn(null);
final HubDataActions hubDataActions = new HubDataActions(globalProperties);
try {
hubDataActions.getHubProjects();
fail();
} catch (final AlertException e) {
assertEquals("Missing global configuration.", e.getMessage());
}
}
use of com.blackducksoftware.integration.hub.alert.exception.AlertException in project hub-alert by blackducksoftware.
the class CommonConfigHandlerTest method putWithInternalServerErrorTest.
@Test
public void putWithInternalServerErrorTest() throws IntegrationException {
final CommonDistributionConfigActions configActions = Mockito.mock(CommonDistributionConfigActions.class);
final CommonConfigHandler<CommonDistributionConfigEntity, CommonDistributionConfigRestModel, CommonDistributionRepositoryWrapper> handler = new CommonConfigHandler<>(CommonDistributionConfigEntity.class, CommonDistributionConfigRestModel.class, configActions, objectTransformer);
Mockito.when(configActions.doesConfigExist(Mockito.anyString())).thenReturn(true);
Mockito.doNothing().when(configActions).configurationChangeTriggers(Mockito.any());
Mockito.when(configActions.saveNewConfigUpdateFromSavedConfig(Mockito.any())).thenThrow(new AlertException());
final CommonDistributionConfigRestModel restModel = mockCommonDistributionRestModel.createRestModel();
final ResponseEntity<String> response = handler.putConfig(restModel);
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode());
}
use of com.blackducksoftware.integration.hub.alert.exception.AlertException in project hub-alert by blackducksoftware.
the class ChannelRequestHelper method sendGenericRequest.
public Response sendGenericRequest(final Request request) throws IntegrationException {
Response response = null;
try {
final HubService service = hubServicesFactory.createHubService();
response = service.executeRequest(request);
logger.trace("Response: " + response.toString());
return response;
} catch (final Exception generalException) {
logger.error("Error sending request", generalException);
throw new AlertException(generalException.getMessage());
}
}
use of com.blackducksoftware.integration.hub.alert.exception.AlertException in project hub-alert by blackducksoftware.
the class HubDataActions method getHubGroups.
public List<HubGroup> getHubGroups() throws IntegrationException {
final HubServicesFactory hubServicesFactory = globalProperties.createHubServicesFactory(logger);
if (hubServicesFactory != null) {
final List<UserGroupView> rawGroups = hubServicesFactory.createHubService().getAllResponses(ApiDiscovery.USERGROUPS_LINK_RESPONSE);
final List<HubGroup> groups = new ArrayList<>();
for (final UserGroupView userGroupView : rawGroups) {
final HubGroup hubGroup = new HubGroup(userGroupView.name, userGroupView.active, userGroupView._meta.href);
groups.add(hubGroup);
}
return groups;
} else {
throw new AlertException("Missing global configuration.");
}
}
Aggregations