use of com.blackducksoftware.integration.hub.alert.datasource.entity.VulnerabilityEntity in project hub-alert by blackducksoftware.
the class NotificationManagerTestIT method testSave.
@Test
public void testSave() {
final NotificationEntity notificationEntity = createNotificationEntity();
final VulnerabilityEntity vulnerabilityEntity = new VulnerabilityEntity("id1", VulnerabilityOperationEnum.ADD, null);
final List<VulnerabilityEntity> vulnerabilityList = Arrays.asList(vulnerabilityEntity);
NotificationModel model = new NotificationModel(notificationEntity, vulnerabilityList);
NotificationModel savedModel = notificationManager.saveNotification(model);
assertNotNull(savedModel.getNotificationEntity().getId());
assertNotificationModel(notificationEntity, savedModel);
assertEquals(vulnerabilityList.size(), model.getVulnerabilityList().size());
model = new NotificationModel(notificationEntity, null);
savedModel = notificationManager.saveNotification(model);
assertNotNull(savedModel.getNotificationEntity().getId());
assertNotificationModel(notificationEntity, savedModel);
assertTrue(model.getVulnerabilityList().isEmpty());
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.VulnerabilityEntity in project hub-alert by blackducksoftware.
the class NotificationManagerTestIT method testFindByIds.
@Test
public void testFindByIds() {
final NotificationEntity notificationEntity = createNotificationEntity();
final VulnerabilityEntity vulnerabilityEntity = new VulnerabilityEntity("id1", VulnerabilityOperationEnum.ADD, null);
final List<VulnerabilityEntity> vulnerabilityList = Arrays.asList(vulnerabilityEntity);
final NotificationModel model = new NotificationModel(notificationEntity, vulnerabilityList);
final NotificationModel savedModel = notificationManager.saveNotification(model);
final List<Long> notificationIds = Arrays.asList(savedModel.getNotificationEntity().getId());
final List<NotificationModel> notificationModelList = notificationManager.findByIds(notificationIds);
assertEquals(1, notificationModelList.size());
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.VulnerabilityEntity in project hub-alert by blackducksoftware.
the class VulnerabilityRepositoryTestIT method testFindByNotificationId.
@Test
public void testFindByNotificationId() {
final VulnerabilityEntity entity1 = createVulnerabilityEntity(1);
final VulnerabilityEntity entity2 = createVulnerabilityEntity(2);
final VulnerabilityEntity entity3 = createVulnerabilityEntity(3);
final VulnerabilityEntity doNotFindEntity = new VulnerabilityEntity("id4", VulnerabilityOperationEnum.DELETE, 2L);
final List<VulnerabilityEntity> vulnerabilityList = Arrays.asList(entity1, entity2, entity3, doNotFindEntity);
repository.save(vulnerabilityList);
final long count = repository.count();
assertEquals(vulnerabilityList.size(), count);
final List<VulnerabilityEntity> foundEntityList = repository.findByNotificationId(1L);
final boolean entity1Found = foundEntityList.stream().anyMatch(entity1::equals);
final boolean entity2Found = foundEntityList.stream().anyMatch(entity1::equals);
final boolean entity3Found = foundEntityList.stream().anyMatch(entity1::equals);
final boolean noneMatchNotFound = foundEntityList.stream().noneMatch(doNotFindEntity::equals);
assertTrue(entity1Found);
assertTrue(entity2Found);
assertTrue(entity3Found);
assertTrue(noneMatchNotFound);
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.VulnerabilityEntity in project hub-alert by blackducksoftware.
the class DigestRemovalProcessorTest method createVulnerabilityList.
private List<VulnerabilityEntity> createVulnerabilityList() {
final VulnerabilityEntity vuln1 = new VulnerabilityEntity("id1", VulnerabilityOperationEnum.ADD, 1L);
final VulnerabilityEntity vuln2 = new VulnerabilityEntity("id2", VulnerabilityOperationEnum.DELETE, 2L);
final VulnerabilityEntity vuln3 = new VulnerabilityEntity("id3", VulnerabilityOperationEnum.UPDATE, 1L);
return Arrays.asList(vuln1, vuln2, vuln1, vuln3, vuln2);
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.VulnerabilityEntity 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);
}
Aggregations