use of com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel in project hub-alert by blackducksoftware.
the class DigestRemovalProcessorTest method createVulnerabilityNotifications.
private List<NotificationModel> createVulnerabilityNotifications() {
final String keyPrefix = "key";
final String projectName = "Project Name";
final String projectVersion = "Project Version";
final NotificationEntity notification1 = new NotificationEntity(keyPrefix + "1", null, NotificationCategoryEnum.HIGH_VULNERABILITY, projectName, "", projectVersion, "", "", "", "", "");
final NotificationEntity notification2 = new NotificationEntity(keyPrefix + "2", null, NotificationCategoryEnum.MEDIUM_VULNERABILITY, projectName, "", projectVersion, "", "", "", "", "");
final NotificationEntity notification3 = new NotificationEntity(keyPrefix + "3", null, NotificationCategoryEnum.LOW_VULNERABILITY, projectName, "", projectVersion, "", "", "", "", "");
final NotificationEntity notification4 = new NotificationEntity(keyPrefix + "4", null, NotificationCategoryEnum.VULNERABILITY, 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, Collections.emptyList());
return Arrays.asList(model1, model2, model1, model3, model2, model4);
}
use of com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel in project hub-alert by blackducksoftware.
the class ProjectDataFactoryTest method createProjectDataTest.
@Test
public void createProjectDataTest() {
final NotificationModel notification = createVulnerabilityNotification();
final ProjectDataFactory projectDataFactory = new ProjectDataFactory();
final ProjectData projectData = projectDataFactory.createProjectData(notification);
assertFields(notification, projectData);
assertEquals(DigestTypeEnum.REAL_TIME, projectData.getDigestType());
}
use of com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel in project hub-alert by blackducksoftware.
the class ProjectDataFactoryTest method createVulnerabilityNotification.
private NotificationModel createVulnerabilityNotification(final String projectName, final String projectVersion) {
final String eventKey = "key";
final Date createdAt = new Date();
final NotificationCategoryEnum notificationType = NotificationCategoryEnum.MEDIUM_VULNERABILITY;
final String projectUrl = "http://localhost:8080";
final String projectVersionUrl = "http://localhost:8080";
final String componentName = "Component";
final String componentVersion = "Component Version";
final String policyRuleName = null;
final String policyRuleUser = null;
final String vulnerabilityId = NotificationCategoryEnum.VULNERABILITY.name();
final VulnerabilityOperationEnum vulnerabilityOperation = VulnerabilityOperationEnum.ADD;
final NotificationEntity notification = new NotificationEntity(eventKey, createdAt, notificationType, projectName, projectUrl, projectVersion, projectVersionUrl, componentName, componentVersion, policyRuleName, policyRuleUser);
notification.setId(1L);
final Collection<VulnerabilityEntity> vulnerabilityList = Arrays.asList(new VulnerabilityEntity(vulnerabilityId, vulnerabilityOperation, notification.getId()));
return new NotificationModel(notification, vulnerabilityList);
}
use of com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel in project hub-alert by blackducksoftware.
the class NotificationModelTest method testNotificationNull.
@Test
public void testNotificationNull() {
final NotificationEntity entity = null;
final VulnerabilityEntity vuln1 = new VulnerabilityEntity("id1", VulnerabilityOperationEnum.ADD, 1L);
final List<VulnerabilityEntity> vulnerabilityList = Arrays.asList(vuln1);
final NotificationModel model = new NotificationModel(entity, vulnerabilityList);
assertNull(model.getComponentName());
assertNull(model.getComponentVersion());
assertNull(model.getCreatedAt());
assertNull(model.getEventKey());
assertNull(model.getNotificationEntity());
assertNull(model.getNotificationType());
assertNull(model.getPolicyRuleName());
assertNull(model.getPolicyRuleUser());
assertNull(model.getProjectName());
assertNull(model.getProjectUrl());
assertNull(model.getProjectVersion());
assertNull(model.getProjectVersionUrl());
assertEquals(vulnerabilityList.size(), model.getVulnerabilityList().size());
final boolean allEqual = model.getVulnerabilityList().stream().allMatch(vuln1::equals);
assertTrue(allEqual);
}
use of com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel in project hub-alert by blackducksoftware.
the class NotificationModelTest method testModel.
@Test
public void testModel() {
final NotificationEntity entity = createNotificationEntity();
final VulnerabilityEntity vuln1 = new VulnerabilityEntity("id1", VulnerabilityOperationEnum.ADD, 1L);
final List<VulnerabilityEntity> vulnerabilityList = Arrays.asList(vuln1);
final NotificationModel model = new NotificationModel(entity, vulnerabilityList);
assertEquals(entity.getComponentName(), model.getComponentName());
assertEquals(entity.getComponentVersion(), model.getComponentVersion());
assertEquals(entity.getCreatedAt(), model.getCreatedAt());
assertEquals(entity.getEventKey(), model.getEventKey());
assertEquals(entity, model.getNotificationEntity());
assertEquals(entity.getNotificationType(), model.getNotificationType());
assertEquals(entity.getPolicyRuleName(), model.getPolicyRuleName());
assertEquals(entity.getPolicyRuleUser(), model.getPolicyRuleUser());
assertEquals(entity.getProjectName(), model.getProjectName());
assertEquals(entity.getProjectUrl(), model.getProjectUrl());
assertEquals(entity.getProjectVersion(), model.getProjectVersion());
assertEquals(entity.getProjectVersionUrl(), model.getProjectVersionUrl());
assertEquals(vulnerabilityList.size(), model.getVulnerabilityList().size());
final boolean allEqual = model.getVulnerabilityList().stream().allMatch(vuln1::equals);
assertTrue(allEqual);
}
Aggregations