use of com.synopsys.integration.blackduck.api.generated.view.CodeLocationView in project blackduck-common by blackducksoftware.
the class CodeLocationServiceTestIT method uploadAndVerifyCodeLocation.
private void uploadAndVerifyCodeLocation(int numberOfCodeLocations, int codeLocationToTest) throws IntegrationException, IOException {
List<String> codeLocationNames = populateCodeLocationNames(numberOfCodeLocations);
String codeLocationToValidate = codeLocationNames.get(codeLocationToTest - 1);
// Pre-clean test data
deleteCodeLocationByName(blackDuckServices, codeLocationNames);
deleteProjectByName(blackDuckServices);
// Verify code location does not exist
assertEquals(Optional.empty(), blackDuckServices.codeLocationService.getCodeLocationByName(codeLocationToValidate), String.format("Code location %s should not exist", codeLocationToValidate));
try {
createAndUploadSimpleBdioObject(codeLocationNames);
// Verify code location now exists using getSomeMatchingResponses()
Predicate<CodeLocationView> nameMatcherPredicate = codeLocationView -> CodeLocationService.NAME_MATCHER.test(codeLocationToValidate, codeLocationView);
BlackDuckRequestBuilder blackDuckRequestBuilder = new BlackDuckRequestBuilder().commonGet().setLimit(2);
BlackDuckMultipleRequest<CodeLocationView> requestMultiple = blackDuckRequestBuilder.buildBlackDuckRequest(blackDuckServices.apiDiscovery.metaCodelocationsLink());
List<CodeLocationView> foundCodeLocation = blackDuckServices.blackDuckApiClient.getSomeMatchingResponses(requestMultiple, nameMatcherPredicate, 1);
assertEquals(1, foundCodeLocation.size(), String.format("Matching code locations should be 1 but is %d", foundCodeLocation.size()));
assertEquals(codeLocationToValidate, foundCodeLocation.get(0).getName(), "Found code location does not equal expected");
// Verify code location now exists using getCodeLocationByName()
assertTrue(blackDuckServices.codeLocationService.getCodeLocationByName(codeLocationToValidate).isPresent(), "Code location is empty after uploading.");
assertEquals(codeLocationToValidate, blackDuckServices.codeLocationService.getCodeLocationByName(codeLocationToValidate).get().getName(), "Found code location does not equal expected");
} finally {
// Post-clean test data
deleteCodeLocationByName(blackDuckServices, codeLocationNames);
deleteProjectByName(blackDuckServices);
}
}
use of com.synopsys.integration.blackduck.api.generated.view.CodeLocationView in project blackduck-common by blackducksoftware.
the class CodeLocationServiceTestIT method deleteCodeLocationByName.
private void deleteCodeLocationByName(BlackDuckServices blackDuckServices, List<String> codeLocationNames) throws IntegrationException {
Predicate<CodeLocationView> toDelete = (codeLocationView -> codeLocationNames.contains(codeLocationView.getName()));
List<CodeLocationView> codeLocationsToDelete = blackDuckServices.blackDuckApiClient.getSomeMatchingResponses(blackDuckServices.apiDiscovery.metaCodelocationsLink(), toDelete, codeLocationNames.size());
for (CodeLocationView codeLocationToDelete : codeLocationsToDelete) {
blackDuckServices.blackDuckApiClient.delete(codeLocationToDelete);
}
}
use of com.synopsys.integration.blackduck.api.generated.view.CodeLocationView in project blackduck-common by blackducksoftware.
the class CodeLocationService method getCodeLocationById.
public CodeLocationView getCodeLocationById(String codeLocationId) throws IntegrationException {
BlackDuckPath blackDuckPath = new BlackDuckPath(ApiDiscovery.CODELOCATIONS_PATH.getPath() + "/" + codeLocationId, CodeLocationView.class, false);
UrlSingleResponse<CodeLocationView> codeLocationResponse = apiDiscovery.metaSingleResponse(blackDuckPath);
return blackDuckApiClient.getResponse(codeLocationResponse);
}
use of com.synopsys.integration.blackduck.api.generated.view.CodeLocationView in project blackduck-common by blackducksoftware.
the class CodeLocationService method getCodeLocationByName.
public Optional<CodeLocationView> getCodeLocationByName(String codeLocationName) throws IntegrationException {
BlackDuckQuery blackDuckQuery = new BlackDuckQuery("name", codeLocationName);
BlackDuckRequestBuilder blackDuckRequestBuilder = new BlackDuckRequestBuilder().commonGet().addBlackDuckQuery(blackDuckQuery);
Predicate<CodeLocationView> predicate = codeLocationView -> NAME_MATCHER.test(codeLocationName, codeLocationView);
BlackDuckMultipleRequest<CodeLocationView> requestMultiple = blackDuckRequestBuilder.buildBlackDuckRequest(codeLocationsResponses);
return blackDuckApiClient.getSomeMatchingResponses(requestMultiple, predicate, 1).stream().findFirst();
}
use of com.synopsys.integration.blackduck.api.generated.view.CodeLocationView in project blackduck-common by blackducksoftware.
the class CodeLocationService method mapCodeLocation.
public void mapCodeLocation(HttpUrl codeLocationUrl, ProjectVersionView projectVersionView) throws IntegrationException {
CodeLocationView codeLocationView = createFakeCodeLocationView(codeLocationUrl);
mapCodeLocation(codeLocationView, projectVersionView);
}
Aggregations