use of com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationEntity 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.datasource.entity.NotificationEntity 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);
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationEntity in project hub-alert by blackducksoftware.
the class PurgeJobIT method testReaderWithData.
@Test
public void testReaderWithData() throws Exception {
final List<NotificationEntity> entityList = new ArrayList<>();
final String eventKey = "eventKey";
final NotificationCategoryEnum notificationType = NotificationCategoryEnum.VULNERABILITY;
final String projectName = "ProjectName";
final String projectUrl = "ProjectUrl";
final String projectVersion = "ProjectVersion";
final String projectVersionUrl = "ProjectVersionUrl";
final String componentName = "ComponentName";
final String componentVersion = "ComponentVersion";
final String policyRuleName = "PolicyRuleName";
final String person = "PolicyPerson";
ZonedDateTime zonedDateTime = ZonedDateTime.now().withZoneSameInstant(ZoneOffset.UTC);
zonedDateTime = zonedDateTime.minusDays(1);
Date createdAt = Date.from(zonedDateTime.toInstant());
entityList.add(new NotificationEntity(eventKey, createdAt, notificationType, projectName, projectUrl, projectVersion, projectVersionUrl, componentName, componentVersion, policyRuleName, person));
zonedDateTime = ZonedDateTime.now().withZoneSameInstant(ZoneOffset.UTC);
zonedDateTime = zonedDateTime.minusDays(3);
createdAt = Date.from(zonedDateTime.toInstant());
entityList.add(new NotificationEntity(eventKey, createdAt, notificationType, projectName, projectUrl, projectVersion, projectVersionUrl, componentName, componentVersion, policyRuleName, person));
zonedDateTime = ZonedDateTime.now().withZoneSameInstant(ZoneOffset.UTC);
zonedDateTime = zonedDateTime.plusDays(1);
createdAt = Date.from(zonedDateTime.toInstant());
entityList.add(new NotificationEntity(eventKey, createdAt, notificationType, projectName, projectUrl, projectVersion, projectVersionUrl, componentName, componentVersion, policyRuleName, person));
notificationRepository.save(entityList);
final PurgeReader reader = purgeConfig.reader();
final List<NotificationModel> resultList = reader.read();
assertEquals(2, resultList.size());
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationEntity in project hub-alert by blackducksoftware.
the class NotificationRepositoryTestIT method createEntity.
private NotificationEntity createEntity(final String dateString) throws ParseException {
final Date createdAt = RestConnection.parseDateString(dateString);
final NotificationEntity entity = createNotificationEntity(createdAt);
final NotificationEntity savedEntity = repository.save(entity);
return savedEntity;
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationEntity in project hub-alert by blackducksoftware.
the class NotificationRepositoryTestIT method createNotificationEntity.
private NotificationEntity createNotificationEntity(final Date createdAt) {
final String eventKey = "event_key_for_notification";
final NotificationCategoryEnum notificationType = NotificationCategoryEnum.VULNERABILITY;
final String projectName = "projectName";
final String projectVersion = "projectVersion";
final String componentName = "componentName";
final String componentVersion = "componentVersion";
final String policyRuleName = "policyRuleName";
final String person = "person";
final NotificationEntity entity = new NotificationEntity(eventKey, createdAt, notificationType, projectName, null, projectVersion, null, componentName, componentVersion, policyRuleName, person);
return entity;
}
Aggregations