use of com.synopsys.integration.alert.provider.blackduck.processor.model.VulnerabilityUniqueProjectNotificationContent in project hub-alert by blackducksoftware.
the class JobNotificationMapperTestIT method testProjectJob.
private void testProjectJob() {
JobNotificationMapper defaultJobNotificationExtractor = new JobNotificationMapper(processingJobAccessor);
List<DetailedNotificationContent> notificationWrappers = createNotificationWrappers();
StatefulAlertPage<FilteredJobNotificationWrapper, RuntimeException> pageMappedNotifications = defaultJobNotificationExtractor.mapJobsToNotifications(notificationWrappers, List.of(FrequencyType.REAL_TIME));
List<FilteredJobNotificationWrapper> filteredJobNotificationWrappers = pageMappedNotifications.getCurrentModels();
assertEquals(1, filteredJobNotificationWrappers.size());
List<NotificationContentWrapper> filterableNotificationWrappers = filteredJobNotificationWrappers.get(0).getJobNotifications();
assertEquals(1, filterableNotificationWrappers.size());
NotificationContentWrapper filterableNotificationWrapper = filterableNotificationWrappers.get(0);
assertEquals(NotificationType.VULNERABILITY.name(), filterableNotificationWrapper.extractNotificationType());
VulnerabilityUniqueProjectNotificationContent vulnerabilityUniqueProjectNotificationContent = (VulnerabilityUniqueProjectNotificationContent) filterableNotificationWrapper.getNotificationContent();
assertEquals(PROJECT_NAME_1, vulnerabilityUniqueProjectNotificationContent.getAffectedProjectVersion().getProjectName());
}
use of com.synopsys.integration.alert.provider.blackduck.processor.model.VulnerabilityUniqueProjectNotificationContent in project hub-alert by blackducksoftware.
the class VulnerabilityNotificationMessageExtractorTest method createBomComponentDetailsTest.
@Test
public void createBomComponentDetailsTest() throws IntegrationException {
BlackDuckServicesFactory blackDuckServicesFactory = Mockito.mock(BlackDuckServicesFactory.class);
BlackDuckApiClient blackDuckApiClient = Mockito.mock(BlackDuckApiClient.class);
Mockito.when(blackDuckServicesFactory.getBlackDuckApiClient()).thenReturn(blackDuckApiClient);
ProjectVersionComponentVersionView projectVersionComponentVersionView = createProjectVersionComponentVersionView(true);
Mockito.when(blackDuckApiClient.getResponse(Mockito.any(), Mockito.eq(ProjectVersionComponentVersionView.class))).thenReturn(projectVersionComponentVersionView);
ComponentVersionUpgradeGuidanceView componentVersionUpgradeGuidanceView = createComponentVersionUpgradeGuidanceView();
// A UrlSingleResponse is needed to Mock the blackDuckApiClient in BlackDuckMessageComponentVersionUpgradeGuidanceService::requestUpgradeGuidanceItems
UrlSingleResponse<ComponentVersionUpgradeGuidanceView> urlSingleResponse = new UrlSingleResponse<>(new HttpUrl(UPGRADE_GUIDANCE_URL), ComponentVersionUpgradeGuidanceView.class);
Mockito.when(blackDuckApiClient.getResponse(Mockito.eq(urlSingleResponse))).thenReturn(componentVersionUpgradeGuidanceView);
VulnerabilityUniqueProjectNotificationContent notificationContent = createVulnerabilityUniqueProjectNotificationContent();
List<BomComponentDetails> bomComponentDetailsList = extractor.createBomComponentDetails(notificationContent, blackDuckServicesFactory);
assertEquals(1, bomComponentDetailsList.size());
BomComponentDetails testBomComponentDetails = bomComponentDetailsList.get(0);
assertEquals(COMPONENT, testBomComponentDetails.getComponent());
assertTrue(testBomComponentDetails.getComponentVersion().isPresent());
assertEquals(COMPONENT_VERSION.getValue(), testBomComponentDetails.getComponentVersion().get().getValue());
assertEquals(LICENSE_DISPLAY, testBomComponentDetails.getLicense().getValue());
assertEquals(UsageType.DYNAMICALLY_LINKED.prettyPrint(), testBomComponentDetails.getUsage());
assertTrue(testBomComponentDetails.getAdditionalAttributes().isEmpty());
assertTrue(testBomComponentDetails.getRelevantPolicies().isEmpty());
assertNotNull(testBomComponentDetails.getComponentVulnerabilities());
assertEquals(3, testBomComponentDetails.getComponentConcerns().size());
ComponentUpgradeGuidance componentUpgradeGuidance = testBomComponentDetails.getComponentUpgradeGuidance();
assertTrue(componentUpgradeGuidance.getLongTermUpgradeGuidance().isPresent());
assertTrue(componentUpgradeGuidance.getShortTermUpgradeGuidance().isPresent());
}
use of com.synopsys.integration.alert.provider.blackduck.processor.model.VulnerabilityUniqueProjectNotificationContent in project hub-alert by blackducksoftware.
the class VulnerabilityNotificationMessageExtractorTest method createVulnerabilityUniqueProjectNotificationContent.
private VulnerabilityUniqueProjectNotificationContent createVulnerabilityUniqueProjectNotificationContent() {
AffectedProjectVersion affectedProjectVersion = new AffectedProjectVersion();
affectedProjectVersion.setProjectName(PROJECT);
affectedProjectVersion.setProjectVersionName(PROJECT_VERSION);
affectedProjectVersion.setProjectVersion(PROJECT_VERSION_URL);
affectedProjectVersion.setComponentIssueUrl(COMPONENT_URL);
affectedProjectVersion.setBomComponent(COMPONENT_URL);
VulnerabilitySourceQualifiedId vulnerabilityNew = new VulnerabilitySourceQualifiedId();
vulnerabilityNew.setSeverity(VulnerabilitySeverityType.CRITICAL.name());
vulnerabilityNew.setVulnerability(VULNERABILITY_URL);
VulnerabilitySourceQualifiedId vulnerabilityUpdated = new VulnerabilitySourceQualifiedId();
vulnerabilityUpdated.setVulnerability(VULNERABILITY_URL);
VulnerabilitySourceQualifiedId vulnerabilityDeleted = new VulnerabilitySourceQualifiedId();
vulnerabilityDeleted.setSeverity(VulnerabilitySeverityType.LOW.name());
vulnerabilityDeleted.setVulnerability(VULNERABILITY_URL);
VulnerabilityNotificationContent vulnerabilityNotificationContent = new VulnerabilityNotificationContent();
vulnerabilityNotificationContent.setAffectedProjectVersions(List.of(affectedProjectVersion));
vulnerabilityNotificationContent.setComponentName(COMPONENT.getValue());
vulnerabilityNotificationContent.setVersionName(COMPONENT_VERSION.getValue());
vulnerabilityNotificationContent.setNewVulnerabilityCount(1);
vulnerabilityNotificationContent.setNewVulnerabilityIds(List.of(vulnerabilityNew));
vulnerabilityNotificationContent.setUpdatedVulnerabilityCount(1);
vulnerabilityNotificationContent.setUpdatedVulnerabilityIds(List.of(vulnerabilityUpdated));
vulnerabilityNotificationContent.setDeletedVulnerabilityCount(1);
vulnerabilityNotificationContent.setDeletedVulnerabilityIds(List.of(vulnerabilityDeleted));
VulnerabilityUniqueProjectNotificationContent notificationContent = new VulnerabilityUniqueProjectNotificationContent(vulnerabilityNotificationContent, affectedProjectVersion);
notificationContent.setComponentVersion(COMPONENT_VERSION_URL);
return notificationContent;
}
use of com.synopsys.integration.alert.provider.blackduck.processor.model.VulnerabilityUniqueProjectNotificationContent in project hub-alert by blackducksoftware.
the class JobNotificationMapperTestIT method createVulnerabilityUniqueProjectNotificationContent.
private VulnerabilityUniqueProjectNotificationContent createVulnerabilityUniqueProjectNotificationContent(String projectName) {
AffectedProjectVersion affectedProjectVersion = new AffectedProjectVersion();
affectedProjectVersion.setProjectName(projectName);
return new VulnerabilityUniqueProjectNotificationContent(new VulnerabilityNotificationContent(), affectedProjectVersion);
}
use of com.synopsys.integration.alert.provider.blackduck.processor.model.VulnerabilityUniqueProjectNotificationContent in project hub-alert by blackducksoftware.
the class ProcessingJobAccessorTestIT method createVulnerabilityUniqueProjectNotificationContent.
private VulnerabilityUniqueProjectNotificationContent createVulnerabilityUniqueProjectNotificationContent(String projectName) {
AffectedProjectVersion affectedProjectVersion = new AffectedProjectVersion();
affectedProjectVersion.setProjectName(projectName);
return new VulnerabilityUniqueProjectNotificationContent(new VulnerabilityNotificationContent(), affectedProjectVersion);
}
Aggregations