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);
}
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);
}
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);
}
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());
}
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);
}
Aggregations