Search in sources :

Example 1 with DigestTypeEnum

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());
}
Also used : DigestTypeEnum(com.blackducksoftware.integration.hub.alert.enumeration.DigestTypeEnum) CommonDistributionConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity) Test(org.junit.Test) DatabaseConnectionTest(com.blackducksoftware.integration.test.annotation.DatabaseConnectionTest)

Example 2 with DigestTypeEnum

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());
}
Also used : DigestTypeEnum(com.blackducksoftware.integration.hub.alert.enumeration.DigestTypeEnum) CategoryData(com.blackducksoftware.integration.hub.alert.digest.model.CategoryData) CommonDistributionConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity) HashMap(java.util.HashMap) ConfiguredProjectEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.ConfiguredProjectEntity) DistributionNotificationTypeRelation(com.blackducksoftware.integration.hub.alert.datasource.relation.DistributionNotificationTypeRelation) NotificationCategoryEnum(com.blackducksoftware.integration.hub.notification.NotificationCategoryEnum) DistributionProjectRelation(com.blackducksoftware.integration.hub.alert.datasource.relation.DistributionProjectRelation) NotificationTypeEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationTypeEntity) ProjectData(com.blackducksoftware.integration.hub.alert.digest.model.ProjectData) DatabaseConnectionTest(com.blackducksoftware.integration.test.annotation.DatabaseConnectionTest) Test(org.junit.Test)

Example 3 with DigestTypeEnum

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));
}
Also used : DigestTypeEnum(com.blackducksoftware.integration.hub.alert.enumeration.DigestTypeEnum) CommonDistributionConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity) ProjectData(com.blackducksoftware.integration.hub.alert.digest.model.ProjectData) DatabaseConnectionTest(com.blackducksoftware.integration.test.annotation.DatabaseConnectionTest) Test(org.junit.Test)

Example 4 with DigestTypeEnum

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());
}
Also used : DigestTypeEnum(com.blackducksoftware.integration.hub.alert.enumeration.DigestTypeEnum) NotificationModel(com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel) Test(org.junit.Test)

Example 5 with DigestTypeEnum

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);
}
Also used : DigestTypeEnum(com.blackducksoftware.integration.hub.alert.enumeration.DigestTypeEnum) NotificationModel(com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel) Test(org.junit.Test)

Aggregations

DigestTypeEnum (com.blackducksoftware.integration.hub.alert.enumeration.DigestTypeEnum)8 Test (org.junit.Test)8 CommonDistributionConfigEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity)6 DatabaseConnectionTest (com.blackducksoftware.integration.test.annotation.DatabaseConnectionTest)6 NotificationModel (com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel)5 ConfiguredProjectEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.ConfiguredProjectEntity)4 DistributionProjectRelation (com.blackducksoftware.integration.hub.alert.datasource.relation.DistributionProjectRelation)4 NotificationEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationEntity)3 AbstractChannelEvent (com.blackducksoftware.integration.hub.alert.event.AbstractChannelEvent)3 CommonDistributionConfigRestModel (com.blackducksoftware.integration.hub.alert.web.model.distribution.CommonDistributionConfigRestModel)3 Date (java.util.Date)3 HipChatEvent (com.blackducksoftware.integration.hub.alert.channel.hipchat.HipChatEvent)2 ProjectData (com.blackducksoftware.integration.hub.alert.digest.model.ProjectData)2 ArrayList (java.util.ArrayList)2 NotificationTypeEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationTypeEntity)1 DistributionNotificationTypeRelation (com.blackducksoftware.integration.hub.alert.datasource.relation.DistributionNotificationTypeRelation)1 CategoryData (com.blackducksoftware.integration.hub.alert.digest.model.CategoryData)1 NotificationCategoryEnum (com.blackducksoftware.integration.hub.notification.NotificationCategoryEnum)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1