Search in sources :

Example 11 with AbstractChannelEvent

use of com.blackducksoftware.integration.hub.alert.event.AbstractChannelEvent in project hub-alert by blackducksoftware.

the class DigestNotificationProcessorIT method processNotificationDataBasicTestIT.

@Test
public void processNotificationDataBasicTestIT() {
    final Long distributionConfigId = 10L;
    final String distributionType = SupportedChannels.HIPCHAT;
    final String name = "Config Name";
    final DigestTypeEnum frequency = DigestTypeEnum.REAL_TIME;
    final Boolean filterByProject = true;
    final String projectName = "Test Hub Project Name";
    final CommonDistributionConfigEntity commonDistributionConfigEntity = commonDistributionRepository.save(new CommonDistributionConfigEntity(distributionConfigId, distributionType, name, frequency, filterByProject));
    final ConfiguredProjectEntity configuredProjectEntity = configuredProjectsRepository.save(new ConfiguredProjectEntity(projectName));
    distributionProjectRepository.save(new DistributionProjectRelation(commonDistributionConfigEntity.getId(), configuredProjectEntity.getId()));
    final CommonDistributionConfigRestModel restModel = new CommonDistributionConfigRestModel(null, null, null, null, null, null, null, Arrays.asList("POLICY_VIOLATION"));
    notificationActions.saveNotificationTypes(commonDistributionConfigEntity, restModel);
    final List<NotificationModel> notificationList = new ArrayList<>();
    final NotificationEntity applicableNotification = new NotificationEntity("event_key_1", new Date(System.currentTimeMillis()), NotificationCategoryEnum.POLICY_VIOLATION, projectName, "", "", "", "Test Component", "Test Component Version", "Test Policy Rule Name", "Test Person");
    final NotificationEntity nonApplicableNotification = new NotificationEntity("event_key_2", new Date(System.currentTimeMillis()), NotificationCategoryEnum.POLICY_VIOLATION, "Project that we don't care about", "", "", "", "Test Component", "Test Component Version", "Test Policy Rule Name", "Test Person");
    notificationList.add(new NotificationModel(applicableNotification, Collections.emptyList()));
    notificationList.add(new NotificationModel(nonApplicableNotification, Collections.emptyList()));
    final List<AbstractChannelEvent> eventsCreated = processor.processNotifications(DigestTypeEnum.REAL_TIME, notificationList);
    assertEquals(1, eventsCreated.size());
    final AbstractChannelEvent event = eventsCreated.get(0);
    assertTrue(event instanceof HipChatEvent);
    assertEquals(commonDistributionConfigEntity.getId(), event.getCommonDistributionConfigId());
}
Also used : DigestTypeEnum(com.blackducksoftware.integration.hub.alert.enumeration.DigestTypeEnum) CommonDistributionConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity) ArrayList(java.util.ArrayList) HipChatEvent(com.blackducksoftware.integration.hub.alert.channel.hipchat.HipChatEvent) ConfiguredProjectEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.ConfiguredProjectEntity) NotificationModel(com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel) Date(java.util.Date) AbstractChannelEvent(com.blackducksoftware.integration.hub.alert.event.AbstractChannelEvent) CommonDistributionConfigRestModel(com.blackducksoftware.integration.hub.alert.web.model.distribution.CommonDistributionConfigRestModel) DistributionProjectRelation(com.blackducksoftware.integration.hub.alert.datasource.relation.DistributionProjectRelation) NotificationEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationEntity) DatabaseConnectionTest(com.blackducksoftware.integration.test.annotation.DatabaseConnectionTest) Test(org.junit.Test)

Aggregations

AbstractChannelEvent (com.blackducksoftware.integration.hub.alert.event.AbstractChannelEvent)11 Test (org.junit.Test)8 CommonDistributionConfigRestModel (com.blackducksoftware.integration.hub.alert.web.model.distribution.CommonDistributionConfigRestModel)5 CommonDistributionConfigEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity)4 ProjectData (com.blackducksoftware.integration.hub.alert.digest.model.ProjectData)4 NotificationModel (com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel)4 Date (java.util.Date)4 ChannelTemplateManager (com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager)3 ConfiguredProjectEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.ConfiguredProjectEntity)3 NotificationEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationEntity)3 DistributionChannelConfigEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.distribution.DistributionChannelConfigEntity)3 GlobalChannelConfigEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.global.GlobalChannelConfigEntity)3 DistributionProjectRelation (com.blackducksoftware.integration.hub.alert.datasource.relation.DistributionProjectRelation)3 DigestTypeEnum (com.blackducksoftware.integration.hub.alert.enumeration.DigestTypeEnum)3 DatabaseConnectionTest (com.blackducksoftware.integration.test.annotation.DatabaseConnectionTest)3 ArrayList (java.util.ArrayList)3 IntegrationException (com.blackducksoftware.integration.exception.IntegrationException)2 AuditEntryEntity (com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryEntity)2 AuditNotificationRelation (com.blackducksoftware.integration.hub.alert.audit.repository.relation.AuditNotificationRelation)2 HipChatEvent (com.blackducksoftware.integration.hub.alert.channel.hipchat.HipChatEvent)2