use of com.synopsys.integration.blackduck.api.generated.view.CodeLocationView in project blackduck-common by blackducksoftware.
the class CodeLocationServiceTestIT method testMappingWithProjectCodeCreator.
@Test
@Disabled
// ejk 2020-09-17 disabling this until I can figure out a better way to create the required elements for the test to pass
void testMappingWithProjectCodeCreator() throws IntegrationException, InterruptedException {
/*
This test requires a project/version: code_location_mapping_test_donotdelete/code_location_mapping_test_donotdelete
Also, it requires a user, project_code_scanner, with the Project Code Scanner role on the above project.
*/
String codeLocationName = "bdio to be mapped";
File bdioFile = new File(getClass().getResource("/bdio/bdio_without_project.jsonld").getFile());
UploadTarget uploadTarget = UploadTarget.createDefault(new NameVersion("inaccurate", "inaccurate"), codeLocationName, bdioFile);
BdioUploadService bdioUploadService = blackDuckServices.blackDuckServicesFactory.createBdioUploadService();
bdioUploadService.uploadBdio(uploadTarget);
UserView projectCodeScanner = blackDuckServices.blackDuckServicesFactory.createUserGroupService().getUserByUsername("project_code_scanner").get();
Optional<CodeLocationView> codeLocationView = blackDuckServices.codeLocationService.getCodeLocationByName(codeLocationName);
int attempts = 0;
while (!codeLocationView.isPresent()) {
attempts++;
if (attempts > 15) {
fail("code location not created fast enough");
}
Thread.sleep(5000);
codeLocationView = blackDuckServices.codeLocationService.getCodeLocationByName(codeLocationName);
}
assertTrue(StringUtils.isBlank(codeLocationView.get().getMappedProjectVersion()));
HttpUrl codeLocationUrl = codeLocationView.get().getHref();
// now use the project code scanner user
BufferedIntLogger logger = new BufferedIntLogger();
BlackDuckServerConfigBuilder projectCodeScannerBuilder = BlackDuckServerConfig.newBuilder();
projectCodeScannerBuilder.setUrl(intHttpClientTestHelper.getProperty(TestingPropertyKey.TEST_BLACK_DUCK_SERVER_URL));
projectCodeScannerBuilder.setUsername("project_code_scanner");
projectCodeScannerBuilder.setPassword("super_secure_password");
projectCodeScannerBuilder.setTrustCert(true);
BlackDuckServicesFactory specialFactory = projectCodeScannerBuilder.build().createBlackDuckServicesFactory(logger);
Optional<ProjectVersionWrapper> projectVersionWrapper = specialFactory.createProjectService().getProjectVersion(new NameVersion("code_location_mapping_test_donotdelete", "code_location_mapping_test_donotdelete"));
assertTrue(projectVersionWrapper.isPresent());
CodeLocationService specialCodeLocationService = specialFactory.createCodeLocationService();
specialCodeLocationService.mapCodeLocation(codeLocationUrl, projectVersionWrapper.get().getProjectVersionView());
codeLocationView = blackDuckServices.codeLocationService.getCodeLocationByName(codeLocationName);
assertTrue(codeLocationView.isPresent());
assertEquals(projectVersionWrapper.get().getProjectVersionView().getHref().string(), codeLocationView.get().getMappedProjectVersion());
blackDuckServices.blackDuckApiClient.delete(codeLocationView.get());
}
Aggregations