use of com.synopsys.integration.blackduck.api.generated.view.ProjectVersionComponentVersionView in project hub-alert by blackducksoftware.
the class BlackDuckMessageAttributesUtilsTest method testGetLicenseLinkableItemsNullIncluded.
@Test
public void testGetLicenseLinkableItemsNullIncluded() {
String licenseValue = "License Display";
ProjectVersionComponentVersionView projectVersionComponentView = new ProjectVersionComponentVersionView();
List<ProjectVersionComponentVersionLicensesView> projectVersionComponentLicensesViews = new ArrayList<>();
ProjectVersionComponentVersionLicensesView projectVersionComponentLicensesView = new ProjectVersionComponentVersionLicensesView();
projectVersionComponentLicensesView.setLicenseDisplay(licenseValue);
projectVersionComponentLicensesViews.add(projectVersionComponentLicensesView);
projectVersionComponentLicensesViews.add(null);
projectVersionComponentView.setLicenses(projectVersionComponentLicensesViews);
LinkableItem licenseLinkableItem = BlackDuckMessageAttributesUtils.extractLicense(projectVersionComponentView);
assertEquals(licenseValue, licenseLinkableItem.getValue());
}
use of com.synopsys.integration.blackduck.api.generated.view.ProjectVersionComponentVersionView in project hub-alert by blackducksoftware.
the class BlackDuckMessageAttributesUtilsTest method testGetLicenseLinkableItems.
@Test
public void testGetLicenseLinkableItems() {
String licenseValue = "License Display 1";
ProjectVersionComponentVersionView projectVersionComponentView = new ProjectVersionComponentVersionView();
List<ProjectVersionComponentVersionLicensesView> projectVersionComponentLicensesViews = new ArrayList<>();
ProjectVersionComponentVersionLicensesView projectVersionComponentLicensesView1 = new ProjectVersionComponentVersionLicensesView();
projectVersionComponentLicensesView1.setLicenseDisplay(licenseValue);
projectVersionComponentLicensesViews.add(projectVersionComponentLicensesView1);
ProjectVersionComponentVersionLicensesView projectVersionComponentLicensesView2 = new ProjectVersionComponentVersionLicensesView();
projectVersionComponentLicensesView2.setLicenseDisplay("License Display 2");
projectVersionComponentLicensesViews.add(projectVersionComponentLicensesView2);
projectVersionComponentView.setLicenses(projectVersionComponentLicensesViews);
LinkableItem licenseLinkableItem = BlackDuckMessageAttributesUtils.extractLicense(projectVersionComponentView);
assertEquals(licenseValue, licenseLinkableItem.getValue());
}
use of com.synopsys.integration.blackduck.api.generated.view.ProjectVersionComponentVersionView in project hub-alert by blackducksoftware.
the class BlackDuckResponseTestUtility method createProjectVersionComponentVersionView.
public ProjectVersionComponentVersionView createProjectVersionComponentVersionView() throws IntegrationException {
ProjectVersionComponentVersionView projectVersionComponentVersionView = new ProjectVersionComponentVersionView();
projectVersionComponentVersionView.setComponentName("component name");
projectVersionComponentVersionView.setComponentVersion("http://component-version-url");
projectVersionComponentVersionView.setComponentVersionName("component version name");
projectVersionComponentVersionView.setPolicyStatus(ProjectVersionComponentPolicyStatusType.IN_VIOLATION);
projectVersionComponentVersionView.setUsages(List.of(UsageType.DYNAMICALLY_LINKED));
ProjectVersionComponentVersionLicensesView projectVersionComponentVersionLicensesView = new ProjectVersionComponentVersionLicensesView();
projectVersionComponentVersionLicensesView.setLicense("http://license-link");
projectVersionComponentVersionLicensesView.setLicenseDisplay("license-display");
projectVersionComponentVersionView.setLicenses(List.of(projectVersionComponentVersionLicensesView));
ResourceLink resourceLink = new ResourceLink();
resourceLink.setHref(new HttpUrl("https://resource-url"));
resourceLink.setRel("policy-rules");
ResourceMetadata meta = new ResourceMetadata();
meta.setHref(new HttpUrl("https://meta-url"));
meta.setLinks(List.of(resourceLink));
projectVersionComponentVersionView.setMeta(meta);
return projectVersionComponentVersionView;
}
use of com.synopsys.integration.blackduck.api.generated.view.ProjectVersionComponentVersionView in project hub-alert by blackducksoftware.
the class PolicyOverrideNotificationMessageExtractor method createBomComponentDetails.
@Override
protected List<BomComponentDetails> createBomComponentDetails(PolicyOverrideUniquePolicyNotificationContent notificationContent, BlackDuckServicesFactory blackDuckServicesFactory) throws IntegrationException {
BlackDuckApiClient blackDuckApiClient = blackDuckServicesFactory.getBlackDuckApiClient();
BlackDuckMessageBomComponentDetailsCreator bomComponentDetailsCreator = detailsCreatorFactory.createBomComponentDetailsCreator(blackDuckServicesFactory);
ComponentConcern policyConcern = policyComponentConcernCreator.fromPolicyInfo(notificationContent.getPolicyInfo(), ItemOperation.DELETE);
String overriderName = String.format("%s %s", notificationContent.getFirstName(), notificationContent.getLastName());
LinkableItem overrider = new LinkableItem(BlackDuckMessageLabels.LABEL_OVERRIDER, overriderName);
BomComponentDetails bomComponentDetails;
try {
ProjectVersionComponentVersionView bomComponent = blackDuckApiClient.getResponse(new HttpUrl(notificationContent.getBomComponent()), ProjectVersionComponentVersionView.class);
bomComponentDetails = bomComponentDetailsCreator.createBomComponentDetails(bomComponent, policyConcern, ComponentUpgradeGuidance.none(), List.of(overrider));
} catch (IntegrationRestException e) {
bomComponent404Handler.logIf404OrThrow(e, notificationContent.getComponentName(), notificationContent.getComponentVersionName());
bomComponentDetails = bomComponentDetailsCreator.createMissingBomComponentDetails(notificationContent.getComponentName(), notificationContent.getBomComponent(), notificationContent.getComponentVersionName(), notificationContent.getBomComponent(), List.of(policyConcern), ComponentUpgradeGuidance.none(), List.of(overrider));
}
return List.of(bomComponentDetails);
}
use of com.synopsys.integration.blackduck.api.generated.view.ProjectVersionComponentVersionView in project hub-alert by blackducksoftware.
the class VulnerabilityNotificationMessageExtractor method createBomComponentDetails.
@Override
protected List<BomComponentDetails> createBomComponentDetails(VulnerabilityUniqueProjectNotificationContent notificationContent, BlackDuckServicesFactory blackDuckServicesFactory) throws IntegrationException {
BlackDuckApiClient blackDuckApiClient = blackDuckServicesFactory.getBlackDuckApiClient();
BlackDuckMessageBomComponentDetailsCreator bomComponentDetailsCreator = detailsCreatorFactory.createBomComponentDetailsCreator(blackDuckServicesFactory);
AffectedProjectVersion affectedProjectVersion = notificationContent.getAffectedProjectVersion();
String bomComponentUrl = affectedProjectVersion.getBomComponent();
List<ComponentConcern> componentConcerns = createComponentConcerns(notificationContent);
BomComponentDetails bomComponentDetails;
try {
ProjectVersionComponentVersionView bomComponent = blackDuckApiClient.getResponse(new HttpUrl(bomComponentUrl), ProjectVersionComponentVersionView.class);
ComponentUpgradeGuidance componentUpgradeGuidance = createComponentUpgradeGuidance(blackDuckApiClient, bomComponent);
bomComponentDetails = bomComponentDetailsCreator.createBomComponentDetails(bomComponent, componentConcerns, componentUpgradeGuidance, List.of());
} catch (IntegrationRestException e) {
bomComponent404Handler.logIf404OrThrow(e, notificationContent.getComponentName(), notificationContent.getVersionName());
ComponentUpgradeGuidance componentUpgradeGuidance = createComponentUpgradeGuidance(blackDuckApiClient, notificationContent);
bomComponentDetails = bomComponentDetailsCreator.createMissingBomComponentDetailsForVulnerability(notificationContent.getComponentName(), bomComponentUrl, notificationContent.getVersionName(), componentConcerns, componentUpgradeGuidance, List.of());
}
return List.of(bomComponentDetails);
}
Aggregations