use of com.synopsys.integration.blackduck.api.manual.view.BomEditNotificationView in project hub-alert by blackducksoftware.
the class BomEditNotificationDetailExtractorTest method extractDetailedContentTest.
@Test
public void extractDetailedContentTest() throws IOException, IntegrationException {
String projectName = "project-name";
String projectVersionName = "project-version-name";
Long blackDuckConfigId = 0L;
String notificationString = TestResourceUtils.readFileToString(BOM_EDIT_JSON_PATH);
BomEditNotificationView notificationView = gson.fromJson(notificationString, BomEditNotificationView.class);
NotificationExtractorBlackDuckServicesFactoryCache cache = createCache(blackDuckConfigId, projectName, projectVersionName);
BomEditNotificationDetailExtractor extractor = new BomEditNotificationDetailExtractor(cache);
AlertNotificationModel notification = new AlertNotificationModel(0L, blackDuckConfigId, "BlackDuck", "Config 1", null, null, null, null, false);
List<DetailedNotificationContent> detailedNotificationContents = extractor.extractDetailedContent(notification, notificationView);
assertEquals(1, detailedNotificationContents.size());
DetailedNotificationContent detailedNotificationContent = detailedNotificationContents.get(0);
Optional<String> detailedProjectName = detailedNotificationContent.getProjectName();
assertTrue(detailedProjectName.isPresent(), "Expected project name to be present");
assertEquals(projectName, detailedProjectName.get());
assertTrue(detailedNotificationContent.getPolicyName().isEmpty(), "Expected no policy name to be present");
assertEquals(0, detailedNotificationContent.getVulnerabilitySeverities().size());
}
use of com.synopsys.integration.blackduck.api.manual.view.BomEditNotificationView in project hub-alert by blackducksoftware.
the class BomEditNotificationDetailExtractorTest method extractDetailedContentErrorTest.
@Test
public void extractDetailedContentErrorTest() throws IOException, IntegrationException {
Long blackDuckConfigId = 0L;
String notificationString = TestResourceUtils.readFileToString(BOM_EDIT_JSON_PATH);
BomEditNotificationView notificationView = gson.fromJson(notificationString, BomEditNotificationView.class);
NotificationExtractorBlackDuckServicesFactoryCache cache = Mockito.mock(NotificationExtractorBlackDuckServicesFactoryCache.class);
Mockito.doThrow(new AlertConfigurationException("Expected Exception thrown creating BlackDuckServicesFactory")).when(cache).retrieveBlackDuckServicesFactory(Mockito.anyLong());
BomEditNotificationDetailExtractor extractor = new BomEditNotificationDetailExtractor(cache);
AlertNotificationModel notification = new AlertNotificationModel(0L, blackDuckConfigId, "BlackDuck", "Config 1", null, null, null, null, false);
List<DetailedNotificationContent> detailedNotificationContents = extractor.extractDetailedContent(notification, notificationView);
assertEquals(0, detailedNotificationContents.size());
}
Aggregations