use of com.synopsys.integration.blackduck.api.manual.view.PolicyOverrideNotificationView in project hub-alert by blackducksoftware.
the class PolicyOverrideNotificationDetailExtractorTest method extractDetailedContentTest.
@Test
public void extractDetailedContentTest() throws IOException {
String notificationString = TestResourceUtils.readFileToString(POLICY_OVERRIDE_JSON_PATH);
PolicyOverrideNotificationView notificationView = gson.fromJson(notificationString, PolicyOverrideNotificationView.class);
PolicyOverrideNotificationContent notificationContent = notificationView.getContent();
AlertNotificationModel notification = new AlertNotificationModel(0L, 0L, "BlackDuck", "Config 1", null, null, null, null, false);
PolicyOverrideNotificationDetailExtractor extractor = new PolicyOverrideNotificationDetailExtractor();
List<DetailedNotificationContent> detailedNotificationContents = extractor.extractDetailedContent(notification, notificationView);
assertEquals(2, detailedNotificationContents.size());
for (DetailedNotificationContent detailedNotificationContent : detailedNotificationContents) {
Optional<String> detailedProjectName = detailedNotificationContent.getProjectName();
assertTrue(detailedProjectName.isPresent(), "Expected project name to be present");
assertEquals(notificationContent.getProjectName(), detailedProjectName.get());
}
Set<String> detailedPolicyNames = detailedNotificationContents.stream().map(DetailedNotificationContent::getPolicyName).flatMap(Optional::stream).collect(Collectors.toSet());
for (PolicyInfo policyInfo : notificationContent.getPolicyInfos()) {
assertTrue(detailedPolicyNames.contains(policyInfo.getPolicyName()), "Expected extracted policy name to be present in notification policy infos");
}
}
Aggregations