use of com.blackducksoftware.integration.hub.alert.enumeration.DigestTypeEnum in project hub-alert by blackducksoftware.
the class CommonDistributionRepositoryTestIT method saveEntityTestIT.
@Test
public void saveEntityTestIT() {
final Long distributionConfigId = 1L;
final String distributionType = SupportedChannels.EMAIL_GROUP;
final String name = "My Config";
final DigestTypeEnum frequency = DigestTypeEnum.DAILY;
final Boolean filterByProject = Boolean.TRUE;
final CommonDistributionConfigEntity entity = new CommonDistributionConfigEntity(distributionConfigId, distributionType, name, frequency, filterByProject);
final CommonDistributionConfigEntity savedEntity = commonDistributionRepository.save(entity);
assertEquals(1, commonDistributionRepository.count());
assertNotNull(savedEntity.getId());
assertEquals(distributionConfigId, savedEntity.getDistributionConfigId());
assertEquals(distributionType, savedEntity.getDistributionType());
assertEquals(name, savedEntity.getName());
assertEquals(frequency, savedEntity.getFrequency());
assertEquals(filterByProject, savedEntity.getFilterByProject());
}
use of com.blackducksoftware.integration.hub.alert.enumeration.DigestTypeEnum 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.enumeration.DigestTypeEnum in project hub-alert by blackducksoftware.
the class NotificationPostProcessorTestIT method doFrequenciesMatchTest.
@Test
public void doFrequenciesMatchTest() {
final NotificationPostProcessor postProcessor = new NotificationPostProcessor(distributionProjectRepository, configuredProjectsRepository, distributionNotificationTypeRepository, notificationTypeRepository);
final DigestTypeEnum digestType = DigestTypeEnum.DAILY;
final CommonDistributionConfigEntity config = new CommonDistributionConfigEntity(13L, SupportedChannels.EMAIL_GROUP, "Config 1", digestType, true);
final CommonDistributionConfigEntity configOther = new CommonDistributionConfigEntity(13L, SupportedChannels.EMAIL_GROUP, "Config 2", null, false);
final ProjectData projectDataMatching = new ProjectData(digestType, null, null, null, null);
final ProjectData projectDataOther = new ProjectData(DigestTypeEnum.REAL_TIME, null, null, null, null);
assertTrue(postProcessor.doFrequenciesMatch(config, projectDataMatching));
assertFalse(postProcessor.doFrequenciesMatch(config, projectDataOther));
assertFalse(postProcessor.doFrequenciesMatch(configOther, projectDataOther));
}
use of com.blackducksoftware.integration.hub.alert.enumeration.DigestTypeEnum in project hub-alert by blackducksoftware.
the class ProjectDataFactoryTest method createProjectDataWithDigestTypeTest.
@Test
public void createProjectDataWithDigestTypeTest() {
final NotificationModel notification = createPolicyNotification();
final ProjectDataFactory projectDataFactory = new ProjectDataFactory();
DigestTypeEnum digestType = DigestTypeEnum.DAILY;
ProjectData projectData = projectDataFactory.createProjectData(notification, digestType);
assertFields(notification, projectData);
assertEquals(digestType, projectData.getDigestType());
digestType = DigestTypeEnum.REAL_TIME;
projectData = projectDataFactory.createProjectData(notification, digestType);
assertFields(notification, projectData);
assertEquals(digestType, projectData.getDigestType());
}
use of com.blackducksoftware.integration.hub.alert.enumeration.DigestTypeEnum in project hub-alert by blackducksoftware.
the class ProjectDataFactoryTest method createProjectDataCollectionWithDigestTypeTest.
@Test
public void createProjectDataCollectionWithDigestTypeTest() {
final Collection<NotificationModel> notifications = createNotificationCollection();
final ProjectDataFactory projectDataFactory = new ProjectDataFactory();
final DigestTypeEnum digestType = DigestTypeEnum.DAILY;
final Collection<ProjectData> projectData = projectDataFactory.createProjectDataCollection(notifications, digestType);
assertFieldsForMultiple(notifications, projectData, digestType);
}
Aggregations