Search in sources :

Example 26 with NotificationModel

use of com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel in project hub-alert by blackducksoftware.

the class DailyItemReaderTest method testRead.

@Test
public void testRead() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
    final NotificationManager notificationManager = Mockito.mock(NotificationManager.class);
    final DailyItemReader dailyItemReader = new DailyItemReader(notificationManager, globalProperties);
    Mockito.when(notificationManager.findByCreatedAtBetween(Mockito.any(), Mockito.any())).thenReturn(Arrays.asList(new NotificationModel(null, null)));
    final List<NotificationModel> notificationList = dailyItemReader.read();
    assertTrue(!notificationList.isEmpty());
    Mockito.when(notificationManager.findByCreatedAtBetween(Mockito.any(), Mockito.any())).thenReturn(Arrays.asList());
    final List<NotificationModel> hasReadNotificationList = dailyItemReader.read();
    assertNull(hasReadNotificationList);
}
Also used : NotificationManager(com.blackducksoftware.integration.hub.alert.NotificationManager) NotificationModel(com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel) Test(org.junit.Test)

Example 27 with NotificationModel

use of com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel in project hub-alert by blackducksoftware.

the class DailyItemReaderTest method testUnknownVersionPhoneHome.

@Test
public void testUnknownVersionPhoneHome() throws Exception {
    globalProperties.setProductVersionOverride(GlobalProperties.PRODUCT_VERSION_UNKNOWN);
    final NotificationManager notificationManager = Mockito.mock(NotificationManager.class);
    final DailyItemReader dailyItemReader = new DailyItemReader(notificationManager, globalProperties);
    Mockito.when(notificationManager.findByCreatedAtBetween(Mockito.any(), Mockito.any())).thenReturn(Arrays.asList(new NotificationModel(null, null)));
    final List<NotificationModel> notificationList = dailyItemReader.read();
    assertTrue(!notificationList.isEmpty());
    Mockito.when(notificationManager.findByCreatedAtBetween(Mockito.any(), Mockito.any())).thenReturn(Arrays.asList());
    final List<NotificationModel> hasReadNotificationList = dailyItemReader.read();
    assertNull(hasReadNotificationList);
}
Also used : NotificationManager(com.blackducksoftware.integration.hub.alert.NotificationManager) NotificationModel(com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel) Test(org.junit.Test)

Example 28 with NotificationModel

use of com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel in project hub-alert by blackducksoftware.

the class DigestRemovalProcessorTest method createPolicyNotifications.

private List<NotificationModel> createPolicyNotifications() {
    final String key = "key";
    final String projectName = "Project Name";
    final String projectVersion = "Project Version";
    final NotificationEntity notification1 = new NotificationEntity(key, null, NotificationCategoryEnum.POLICY_VIOLATION, projectName, "", projectVersion, "", "", "", "", "");
    final NotificationEntity notification2 = new NotificationEntity(key, null, NotificationCategoryEnum.POLICY_VIOLATION_CLEARED, projectName, "", projectVersion, "", "", "", "", "");
    final NotificationEntity notification3 = new NotificationEntity(key, null, NotificationCategoryEnum.POLICY_VIOLATION_OVERRIDE, projectName, "", projectVersion, "", "", "", "", "");
    final NotificationEntity notification4 = new NotificationEntity(key, null, NotificationCategoryEnum.POLICY_VIOLATION, projectName, "", projectVersion, "", "", "", "", "");
    final NotificationEntity notification5 = new NotificationEntity(key, null, NotificationCategoryEnum.POLICY_VIOLATION_CLEARED, projectName, "", projectVersion, "", "", "", "", "");
    final NotificationModel model1 = new NotificationModel(notification1, createVulnerabilityList());
    final NotificationModel model2 = new NotificationModel(notification2, createVulnerabilityList());
    final NotificationModel model3 = new NotificationModel(notification3, createVulnerabilityList());
    final NotificationModel model4 = new NotificationModel(notification4, createVulnerabilityList());
    final NotificationModel model5 = new NotificationModel(notification5, createVulnerabilityList());
    return Arrays.asList(model1, model2, model1, model3, model2, model4, model5);
}
Also used : NotificationModel(com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel) NotificationEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationEntity)

Example 29 with NotificationModel

use of com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel 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 30 with NotificationModel

use of com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel 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

NotificationModel (com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel)39 Test (org.junit.Test)25 NotificationEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationEntity)21 Date (java.util.Date)15 DatabaseConnectionTest (com.blackducksoftware.integration.test.annotation.DatabaseConnectionTest)14 VulnerabilityEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.VulnerabilityEntity)13 ArrayList (java.util.ArrayList)10 NotificationManager (com.blackducksoftware.integration.hub.alert.NotificationManager)6 CommonDistributionConfigEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity)5 DigestTypeEnum (com.blackducksoftware.integration.hub.alert.enumeration.DigestTypeEnum)5 AbstractChannelEvent (com.blackducksoftware.integration.hub.alert.event.AbstractChannelEvent)5 CommonDistributionConfigRestModel (com.blackducksoftware.integration.hub.alert.web.model.distribution.CommonDistributionConfigRestModel)5 NotificationCategoryEnum (com.blackducksoftware.integration.hub.notification.NotificationCategoryEnum)5 ChannelTemplateManager (com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager)4 ProjectDataFactory (com.blackducksoftware.integration.hub.alert.digest.model.ProjectDataFactory)4 LocalDateTime (java.time.LocalDateTime)4 List (java.util.List)4 AuditEntryRepositoryWrapper (com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryRepositoryWrapper)3 AuditNotificationRepositoryWrapper (com.blackducksoftware.integration.hub.alert.audit.repository.AuditNotificationRepositoryWrapper)3 AuditNotificationRelation (com.blackducksoftware.integration.hub.alert.audit.repository.relation.AuditNotificationRelation)3