use of com.blackducksoftware.integration.hub.notification.NotificationCategoryEnum in project hub-alert by blackducksoftware.
the class SlackChannelTestIT method createSlackProjectData.
private ProjectData createSlackProjectData() {
final Map<NotificationCategoryEnum, CategoryData> categoryMap = new HashMap<>();
categoryMap.put(NotificationCategoryEnum.HIGH_VULNERABILITY, createCategoryData());
final ProjectData projectData = new ProjectData(DigestTypeEnum.DAILY, "Slack", "1", null, categoryMap);
return projectData;
}
use of com.blackducksoftware.integration.hub.notification.NotificationCategoryEnum in project hub-alert by blackducksoftware.
the class ChannelTest method createProjectData.
public ProjectData createProjectData(final String testName) {
final HashMap<NotificationCategoryEnum, CategoryData> categoryMap = new HashMap<>();
categoryMap.put(NotificationCategoryEnum.POLICY_VIOLATION, createMockPolicyViolation());
categoryMap.put(NotificationCategoryEnum.MEDIUM_VULNERABILITY, createMockVulnerability());
final ProjectData projectData = new ProjectData(DigestTypeEnum.REAL_TIME, testName, testName + " Version", Collections.emptyList(), categoryMap);
return projectData;
}
use of com.blackducksoftware.integration.hub.notification.NotificationCategoryEnum in project hub-alert by blackducksoftware.
the class NotificationModelTest method createNotificationEntity.
private NotificationEntity createNotificationEntity() {
final String eventKey = "event_key_for_notification";
final Date createdAt = Date.from(LocalDateTime.now().toInstant(ZoneOffset.UTC));
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 String projectUrl = "projectURL";
final String projectVersionUrl = "projectVersionUrl";
final NotificationEntity entity = new NotificationEntity(eventKey, createdAt, notificationType, projectName, projectUrl, projectVersion, projectVersionUrl, componentName, componentVersion, policyRuleName, person);
return entity;
}
use of com.blackducksoftware.integration.hub.notification.NotificationCategoryEnum in project hub-alert by blackducksoftware.
the class PurgeJobIT method testWriterWithData.
@Test
public void testWriterWithData() throws Exception {
final List<NotificationModel> 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";
final Collection<VulnerabilityEntity> vulnerabilityList = null;
ZonedDateTime zonedDateTime = ZonedDateTime.now().withZoneSameInstant(ZoneOffset.UTC);
zonedDateTime = zonedDateTime.minusDays(1);
Date createdAt = Date.from(zonedDateTime.toInstant());
NotificationEntity notification = new NotificationEntity(eventKey, createdAt, notificationType, projectName, projectUrl, projectVersion, projectVersionUrl, componentName, componentVersion, policyRuleName, person);
notificationRepository.save(notification);
entityList.add(new NotificationModel(notification, vulnerabilityList));
zonedDateTime = ZonedDateTime.now().withZoneSameInstant(ZoneOffset.UTC);
zonedDateTime = zonedDateTime.minusDays(3);
createdAt = Date.from(zonedDateTime.toInstant());
notification = new NotificationEntity(eventKey, createdAt, notificationType, projectName, projectUrl, projectVersion, projectVersionUrl, componentName, componentVersion, policyRuleName, person);
notificationRepository.save(notification);
entityList.add(new NotificationModel(notification, vulnerabilityList));
zonedDateTime = ZonedDateTime.now().withZoneSameInstant(ZoneOffset.UTC);
zonedDateTime = zonedDateTime.plusDays(1);
createdAt = Date.from(zonedDateTime.toInstant());
notification = new NotificationEntity(eventKey, createdAt, notificationType, projectName, projectUrl, projectVersion, projectVersionUrl, componentName, componentVersion, policyRuleName, person);
notificationRepository.save(notification);
entityList.add(new NotificationModel(notification, vulnerabilityList));
assertEquals(3, notificationRepository.count());
final List<List<NotificationModel>> itemList = new ArrayList<>();
itemList.add(entityList);
final PurgeWriter writer = purgeConfig.writer();
writer.write(itemList);
assertEquals(0, notificationRepository.count());
}
use of com.blackducksoftware.integration.hub.notification.NotificationCategoryEnum in project hub-alert by blackducksoftware.
the class ProjectDataFactoryTest method createPolicyNotification.
private NotificationModel createPolicyNotification(final String projectName, final String projectVersion) {
final String eventKey = "key";
final Date createdAt = new Date();
final NotificationCategoryEnum notificationType = NotificationCategoryEnum.POLICY_VIOLATION;
final String projectUrl = "http://localhost:8080";
final String projectVersionUrl = "http://localhost:8080";
final String componentName = "Other Component";
final String componentVersion = "Other Component Version";
final String policyRuleName = "Policy Rule Name";
final String person = "Person";
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, person);
notification.setId(1L);
final Collection<VulnerabilityEntity> vulnerabilityList = Arrays.asList(new VulnerabilityEntity(vulnerabilityId, vulnerabilityOperation, notification.getId()));
return new NotificationModel(notification, vulnerabilityList);
}
Aggregations