use of com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity in project hub-alert by blackducksoftware.
the class DistributionConfigActions method constructRestModel.
public R constructRestModel(final D entity) throws AlertException {
final D distributionEntity = getRepository().findOne(entity.getId());
final CommonDistributionConfigEntity commonEntity = commonDistributionRepository.findByDistributionConfigIdAndDistributionType(entity.getId(), getDistributionName());
if (distributionEntity != null && commonEntity != null) {
final R restModel = constructRestModel(commonEntity, distributionEntity);
restModel.setConfiguredProjects(configuredProjectsActions.getConfiguredProjects(commonEntity));
restModel.setNotificationTypes(notificationTypesActions.getNotificationTypes(commonEntity));
return restModel;
}
return null;
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity in project hub-alert by blackducksoftware.
the class DistributionConfigActions method deleteConfig.
@Override
public void deleteConfig(final Long id) {
if (id != null) {
final CommonDistributionConfigEntity commonEntity = commonDistributionRepository.findOne(id);
if (commonEntity != null) {
final Long distributionConfigId = commonEntity.getDistributionConfigId();
getRepository().delete(distributionConfigId);
commonDistributionRepository.delete(id);
}
configuredProjectsActions.cleanUpConfiguredProjects();
notificationTypesActions.removeOldNotificationTypes(id);
}
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity in project hub-alert by blackducksoftware.
the class DistributionChannelTest method handleEventWrongTypeTest.
@Test
public void handleEventWrongTypeTest() {
final GlobalProperties globalProperties = new TestGlobalProperties();
final Gson gson = new Gson();
final CommonDistributionRepositoryWrapper commonRepositoryWrapper = Mockito.mock(CommonDistributionRepositoryWrapper.class);
final EmailGroupChannel channel = new EmailGroupChannel(globalProperties, gson, null, null, null, commonRepositoryWrapper);
final Long commonId = 1L;
final EmailGroupEvent event = new EmailGroupEvent(createProjectData("Distribution Channel Test"), commonId);
final CommonDistributionConfigEntity commonEntity = new CommonDistributionConfigEntity(commonId, SupportedChannels.SLACK, "Other Config", DigestTypeEnum.REAL_TIME, false);
Mockito.when(commonRepositoryWrapper.findOne(Mockito.anyLong())).thenReturn(commonEntity);
channel.handleEvent(event);
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity in project hub-alert by blackducksoftware.
the class CommonDistributionConfigControllerTestIT method testDeleteConfig.
@Test
@Override
public void testDeleteConfig() throws Exception {
entityRepository.deleteAll();
final CommonDistributionConfigEntity savedEntity = entityRepository.save(entity);
final MockHttpServletRequestBuilder request = MockMvcRequestBuilders.delete(restUrl).with(SecurityMockMvcRequestPostProcessors.user("admin").roles("ADMIN"));
restModel.setId(String.valueOf(savedEntity.getId()));
request.content(gson.toJson(restModel));
request.contentType(contentType);
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isAccepted());
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity in project hub-alert by blackducksoftware.
the class CommonConfigHandlerTest method postWithInvalidConfigTest.
@Test
public void postWithInvalidConfigTest() throws AlertFieldException {
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(false);
Mockito.when(configActions.validateConfig(Mockito.any())).thenThrow(new AlertFieldException(Collections.emptyMap()));
Mockito.when(configActions.getObjectTransformer()).thenReturn(objectTransformer);
final CommonDistributionConfigRestModel restModel = mockCommonDistributionRestModel.createRestModel();
final ResponseEntity<String> response = handler.postConfig(restModel);
assertEquals(HttpStatus.BAD_REQUEST, response.getStatusCode());
}
Aggregations