use of com.synopsys.integration.blackduck.comprehensive.BlackDuckServices 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.comprehensive.BlackDuckServices in project blackduck-common by blackducksoftware.
the class BinaryScanUploadServiceTestIT method testCodeLocationFromBinaryScanUpload.
@Test
@Disabled
public // disabled because special config is needed to support /api/uploads (binary scan)
void testCodeLocationFromBinaryScanUpload() throws Exception {
BlackDuckServices blackDuckServices = new BlackDuckServices(intHttpClientTestHelper);
BinaryScanData binaryScanData = createBinaryScanData(blackDuckServices, createTestBinaryScan());
assertBinaryUploadCompleted(blackDuckServices, binaryScanData);
}
use of com.synopsys.integration.blackduck.comprehensive.BlackDuckServices in project blackduck-common by blackducksoftware.
the class BinaryScanUploadServiceTestIT method testCodeLocationFromBinaryScanUploadWhenNotConfigured.
@Test
public void testCodeLocationFromBinaryScanUploadWhenNotConfigured() throws Exception {
BlackDuckServices blackDuckServices = new BlackDuckServices(intHttpClientTestHelper);
BinaryScanData binaryScanData = createBinaryScanData(blackDuckServices, createTestBinaryScan());
BinaryScanUploadService binaryScanUploadService = blackDuckServices.blackDuckServicesFactory.createBinaryScanUploadService();
BinaryScanBatchOutput binaryScanBatchOutput = binaryScanUploadService.uploadBinaryScanAndWait(binaryScanData.binaryScan, 15 * 60);
BufferedIntLogger logger = new BufferedIntLogger();
try {
binaryScanBatchOutput.throwExceptionForError(logger);
} catch (Exception e) {
assertTrue(e instanceof BlackDuckIntegrationException);
assertTrue(e.getMessage().startsWith("Error when uploading binary scan"));
assertTrue(logger.getOutputString(LogLevel.ERROR).contains(e.getMessage()));
}
}
use of com.synopsys.integration.blackduck.comprehensive.BlackDuckServices in project blackduck-common by blackducksoftware.
the class BinaryScanUploadServiceTestIT method testJapaneseCharactersForBinaryUpload.
@Test
@Disabled
public // also, because as of 2020.8.0, binary upload doesn't support utf-8
void testJapaneseCharactersForBinaryUpload() throws IntegrationException, InterruptedException {
BlackDuckServices blackDuckServices = new BlackDuckServices(intHttpClientTestHelper);
File binaryFile = getTestBinaryFile();
BinaryScan binaryScan = new BinaryScan(binaryFile, JAPANESE_PROJECT_NAME, JAPANESE_VERSION_NAME, JAPANESE_CODE_LOCATION_NAME);
BinaryScanData binaryScanData = createBinaryScanData(blackDuckServices, binaryScan);
assertBinaryUploadCompleted(blackDuckServices, binaryScanData);
Optional<ProjectVersionWrapper> optionalProjectVersionWrapper = blackDuckServices.projectService.getProjectVersion(JAPANESE_PROJECT_NAME, JAPANESE_VERSION_NAME);
Optional<CodeLocationView> optionalCodeLocationView = blackDuckServices.codeLocationService.getCodeLocationByName(JAPANESE_CODE_LOCATION_NAME);
assertTrue(optionalProjectVersionWrapper.isPresent());
assertTrue(optionalCodeLocationView.isPresent());
}
Aggregations