use of com.synopsys.integration.blackduck.api.generated.response.ComponentsView in project blackduck-common by blackducksoftware.
the class ComponentServiceTestIT method testOriginIdMismatch.
@Test
public void testOriginIdMismatch() throws Exception {
ExternalId cyclerExternalId = externalIdFactory.createNameVersionExternalId(Forge.PYPI, "cycler", "0.10.0");
List<ComponentsView> searchResults = componentService.getAllSearchResults(cyclerExternalId);
assertEquals(1, searchResults.size());
assertTrue(searchResults.get(0).getComponentName().equalsIgnoreCase("cycler"));
assertTrue(searchResults.get(0).getVersionName().equals("0.10.0"));
Optional<ComponentsView> componentView = componentService.getFirstOrEmptyResult(cyclerExternalId);
assertTrue(componentView.isPresent());
assertTrue(componentView.get().getComponentName().equalsIgnoreCase("cycler"));
assertTrue(componentView.get().getVersionName().equals("0.10.0"));
componentView = componentService.getSingleOrEmptyResult(cyclerExternalId);
assertTrue(componentView.isPresent());
assertTrue(componentView.get().getComponentName().equalsIgnoreCase("cycler"));
assertTrue(componentView.get().getVersionName().equals("0.10.0"));
}
use of com.synopsys.integration.blackduck.api.generated.response.ComponentsView in project blackduck-common by blackducksoftware.
the class ComponentServiceTestIT method retrieveCommonsFileupload.
@NotNull
private ComponentVersionView retrieveCommonsFileupload(ComponentService componentService) throws IntegrationException {
ExternalId commonsFileuploadExternalId = externalIdFactory.createMavenExternalId("commons-fileupload", "commons-fileupload", "1.2.1");
Optional<ComponentsView> componentsView = componentService.getFirstOrEmptyResult(commonsFileuploadExternalId);
return componentService.getComponentVersionView(componentsView.get()).get();
}
use of com.synopsys.integration.blackduck.api.generated.response.ComponentsView in project blackduck-common by blackducksoftware.
the class VulnerabilityDataServiceTestIT method testGetCommonsFileUploadVulns.
@Test
public void testGetCommonsFileUploadVulns() throws Exception {
BlackDuckServicesFactory blackDuckServicesFactory = intHttpClientTestHelper.createBlackDuckServicesFactory();
ComponentService componentService = blackDuckServicesFactory.createComponentService();
SimpleBdioFactory simpleBdioFactory = new SimpleBdioFactory();
ExternalIdFactory externalIdFactory = simpleBdioFactory.getExternalIdFactory();
ExternalId commonsFileUploadExternalId = externalIdFactory.createMavenExternalId("commons-fileupload", "commons-fileupload", "1.2.2");
Optional<ComponentsView> searchResult = componentService.getFirstOrEmptyResult(commonsFileUploadExternalId);
Optional<ComponentVersionView> componentVersionView = componentService.getComponentVersionView(searchResult.get());
ComponentVersionVulnerabilities componentVersionVulnerabilities = componentService.getComponentVersionVulnerabilities(componentVersionView.get());
List<VulnerabilityView> vulnerabilities = componentVersionVulnerabilities.getVulnerabilities();
System.out.println(vulnerabilities);
assertNotNull(vulnerabilities);
assertFalse(vulnerabilities.isEmpty());
ExternalId integrationCommonExternalId = externalIdFactory.createMavenExternalId("com.blackducksoftware.integration", "integration-common", "15.0.0");
searchResult = componentService.getFirstOrEmptyResult(integrationCommonExternalId);
componentVersionView = componentService.getComponentVersionView(searchResult.get());
componentVersionVulnerabilities = componentService.getComponentVersionVulnerabilities(componentVersionView.get());
vulnerabilities = componentVersionVulnerabilities.getVulnerabilities();
System.out.println(vulnerabilities);
assertNotNull(vulnerabilities);
assertTrue(vulnerabilities.isEmpty());
}
use of com.synopsys.integration.blackduck.api.generated.response.ComponentsView in project blackduck-common by blackducksoftware.
the class CheckPolicyForProjectVersionRecipeTest method constructTestPolicy.
private PolicyRuleView constructTestPolicy(ComponentService componentService) throws IntegrationException {
ExternalId externalId = constructExternalId();
Optional<ComponentsView> searchResult = componentService.getSingleOrEmptyResult(externalId);
ComponentVersionView componentVersionView = componentService.getComponentVersionView(searchResult.get()).get();
/*
* using the PolicyRuleExpressionSetBuilder we can build the expression
* set for a PolicyRuleView
*/
PolicyRuleExpressionSetBuilder builder = new PolicyRuleExpressionSetBuilder();
builder.addComponentVersionCondition(PolicyRuleConditionOperatorType.EQ, componentVersionView);
PolicyRuleExpressionView expressionSet = builder.createPolicyRuleExpressionView();
PolicyRuleView policyRuleView = new PolicyRuleView();
policyRuleView.setName("Test Rule" + System.currentTimeMillis());
policyRuleView.setEnabled(true);
policyRuleView.setOverridable(true);
policyRuleView.setExpression(expressionSet);
return policyRuleView;
}
use of com.synopsys.integration.blackduck.api.generated.response.ComponentsView in project hub-alert by blackducksoftware.
the class BlackDuckProviderService method createBlackDuckPolicyRuleView.
public PolicyRuleView createBlackDuckPolicyRuleView(String policyName, Supplier<ExternalId> externalIdSupplier) throws IntegrationException {
setupBlackDuckServicesFactory();
ComponentService componentService = blackDuckServicesFactory.createComponentService();
ExternalId externalId = externalIdSupplier.get();
ComponentsView searchResult = componentService.getSingleOrEmptyResult(externalId).orElseThrow(() -> new IntegrationException(String.format("Could not find the ComponentsView for component: %s", externalId.getName())));
ComponentVersionView componentVersionView = componentService.getComponentVersionView(searchResult).orElseThrow(() -> new IntegrationException(String.format("Could not find the ComponentVersionView for component: %s", searchResult.getComponentName())));
PolicyRuleExpressionSetBuilder builder = new PolicyRuleExpressionSetBuilder();
builder.addComponentVersionCondition(PolicyRuleConditionOperatorType.EQ, componentVersionView);
PolicyRuleExpressionView expressionSet = builder.createPolicyRuleExpressionView();
PolicyRuleView policyRuleView = new PolicyRuleView();
policyRuleView.setName(policyName);
policyRuleView.setEnabled(true);
policyRuleView.setOverridable(true);
policyRuleView.setExpression(expressionSet);
return policyRuleView;
}
Aggregations