use of com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationTypeEntity in project hub-alert by blackducksoftware.
the class NotificationPostProcessorTestIT method getApplicableConfigurationsTest.
@Test
public void getApplicableConfigurationsTest() {
final NotificationPostProcessor postProcessor = new NotificationPostProcessor(distributionProjectRepository, configuredProjectsRepository, distributionNotificationTypeRepository, notificationTypeRepository);
final DigestTypeEnum digestType = DigestTypeEnum.REAL_TIME;
final String projectName = "Project Name";
final String projectVersion = "Project Version";
final List<Long> notificationIds = Collections.emptyList();
final Map<NotificationCategoryEnum, CategoryData> categoryMap = new HashMap<>();
for (final NotificationCategoryEnum categoryEnum : NotificationCategoryEnum.values()) {
categoryMap.put(categoryEnum, new CategoryData(null, null, 0));
notificationTypeRepository.save(new NotificationTypeEntity(categoryEnum));
}
final ProjectData projectData = new ProjectData(digestType, projectName, projectVersion, notificationIds, categoryMap);
final Long config1Id = 13L;
final CommonDistributionConfigEntity config1 = new CommonDistributionConfigEntity(config1Id, SupportedChannels.EMAIL_GROUP, "Config 1", digestType, true);
config1.setId(config1Id);
final Long config2Id = 17L;
final CommonDistributionConfigEntity config2 = new CommonDistributionConfigEntity(config2Id, SupportedChannels.EMAIL_GROUP, "Config 2", digestType, false);
config2.setId(config2Id);
final Long notificationTypeId = notificationTypeRepository.findAll().get(0).getId();
distributionNotificationTypeRepository.save(new DistributionNotificationTypeRelation(config1.getId(), notificationTypeId));
distributionNotificationTypeRepository.save(new DistributionNotificationTypeRelation(config2.getId(), notificationTypeId));
final ConfiguredProjectEntity configuredProjectEntity = configuredProjectsRepository.save(new ConfiguredProjectEntity(projectName));
distributionProjectRepository.save(new DistributionProjectRelation(config1.getId(), configuredProjectEntity.getId()));
final Set<CommonDistributionConfigEntity> applicableConfigs = postProcessor.getApplicableConfigurations(Arrays.asList(config1, config2), projectData);
assertTrue(applicableConfigs.contains(config1));
assertTrue(applicableConfigs.contains(config2));
assertEquals(2, applicableConfigs.size());
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationTypeEntity in project hub-alert by blackducksoftware.
the class NotificationTypesActions method getNotificationTypes.
public List<String> getNotificationTypes(final CommonDistributionConfigEntity commonEntity) {
final List<DistributionNotificationTypeRelation> foundRelations = distributionNotificationTypeRepository.findByCommonDistributionConfigId(commonEntity.getId());
final List<String> notificationTypes = new ArrayList<>(foundRelations.size());
for (final DistributionNotificationTypeRelation relation : foundRelations) {
final NotificationTypeEntity foundEntity = notificationTypeRepository.findOne(relation.getNotificationTypeId());
notificationTypes.add(foundEntity.getType().name());
}
return notificationTypes;
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationTypeEntity in project hub-alert by blackducksoftware.
the class NotificationTypesActions method addNewDistributionNotificationTypes.
private void addNewDistributionNotificationTypes(final Long commonDistributionConfigId, final List<String> notificationTypesFromRestModel) {
for (final String notificationType : notificationTypesFromRestModel) {
final NotificationCategoryEnum notificationTypeEnum = NotificationCategoryEnum.valueOf(notificationType);
Long notificationTypeId;
final NotificationTypeEntity foundEntity = notificationTypeRepository.findByType(notificationTypeEnum);
if (foundEntity != null) {
notificationTypeId = foundEntity.getId();
} else {
final NotificationTypeEntity createdEntity = notificationTypeRepository.save(new NotificationTypeEntity(notificationTypeEnum));
notificationTypeId = createdEntity.getId();
}
distributionNotificationTypeRepository.save(new DistributionNotificationTypeRelation(commonDistributionConfigId, notificationTypeId));
}
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationTypeEntity in project hub-alert by blackducksoftware.
the class NotificationTypeRepositoryWrapperTest method testFindByType.
@Test
public void testFindByType() throws EncryptionException, IOException {
final NotificationTypeRepositoryWrapper wrapper = getExceptionThrowingRepositoryWrapper();
final NotificationTypeEntity entity = wrapper.findByType(NotificationCategoryEnum.HIGH_VULNERABILITY);
assertExceptionThrown(entity);
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationTypeEntity in project hub-alert by blackducksoftware.
the class NotificationTypeMockUtils method createEntity.
@Override
public NotificationTypeEntity createEntity() {
final NotificationTypeEntity entity = new NotificationTypeEntity(type);
entity.setId(id);
return entity;
}
Aggregations