use of com.synopsys.integration.blackduck.codelocation.upload.UploadBatchOutput in project blackduck-common by blackducksoftware.
the class ComprehensiveCookbookTestIT method testPolicyStatusFromBdioImport.
@Test
public void testPolicyStatusFromBdioImport() throws Exception {
String projectName = "ek_mtglist";
String projectVersionName = "0.0.1";
String codeLocationName = "ek_mtglist Black Duck I/O Export";
String policyRuleName = "Test Rule for comprehensive policy status/bdio";
String componentName = "Apache POI";
String componentVersion = "3.9";
String groupId = "org.apache.poi";
String artifact = "poi";
CheckPolicyData checkPolicyData = new CheckPolicyData(projectName, projectVersionName, codeLocationName, policyRuleName, componentName, componentVersion, groupId, artifact);
BlackDuckServices blackDuckServices = new BlackDuckServices(intHttpClientTestHelper);
setupPolicyCheck(blackDuckServices, checkPolicyData);
UserView currentUser = blackDuckServices.userService.findCurrentUser();
Date userStartDate = blackDuckServices.notificationService.getLatestUserNotificationDate(currentUser);
Date systemStartDate = blackDuckServices.notificationService.getLatestNotificationDate();
// import the bdio
File file = intHttpClientTestHelper.getFile("bdio/mtglist_bdio.jsonld");
UploadBatch uploadBatch = new UploadBatch(UploadTarget.createDefault(new NameVersion(projectName, projectVersionName), codeLocationName, file));
BdioUploadService bdioUploadService = blackDuckServices.blackDuckServicesFactory.createBdioUploadService();
UploadBatchOutput uploadBatchOutput = bdioUploadService.uploadBdioAndWait(uploadBatch, 15 * 60);
for (UploadOutput uploadOutput : uploadBatchOutput) {
assertEquals(Result.SUCCESS, uploadOutput.getResult());
}
VerifyNotifications.verify(currentUser, blackDuckServices.blackDuckRegistrationService, blackDuckServices.notificationService, userStartDate, systemStartDate);
completePolicyCheck(blackDuckServices, checkPolicyData);
}
use of com.synopsys.integration.blackduck.codelocation.upload.UploadBatchOutput in project blackduck-common by blackducksoftware.
the class CodeLocationServiceTestIT method createAndUploadSimpleBdioObject.
private void createAndUploadSimpleBdioObject(List<String> codeLocationNames) throws IOException, IntegrationException {
UploadBatch uploadBatch = new UploadBatch();
for (String codeLocationName : codeLocationNames) {
File bdioFile = File.createTempFile("bdio", "jsonld");
bdioFile.deleteOnExit();
ProjectDependencyGraph dependencyGraph = new ProjectDependencyGraph(Dependency.FACTORY.createMavenDependency(GROUP, PROJECT_NAME, VERSION));
Dependency bdioTestDependency = Dependency.FACTORY.createMavenDependency(GROUP, COMPONENT_NAME, VERSION);
dependencyGraph.addChildrenToRoot(bdioTestDependency);
SimpleBdioDocument simpleBdioDocument = simpleBdioFactory.createPopulatedBdioDocument(codeLocationName, dependencyGraph);
simpleBdioFactory.writeSimpleBdioDocumentToFile(bdioFile, simpleBdioDocument);
uploadBatch.addUploadTarget(UploadTarget.createDefault(new NameVersion(PROJECT_NAME, VERSION), codeLocationName, bdioFile));
}
BdioUploadService bdioUploadService = blackDuckServices.blackDuckServicesFactory.createBdioUploadService();
BdioUploadCodeLocationCreationRequest uploadRequest = bdioUploadService.createUploadRequest(uploadBatch);
UploadBatchOutput uploadBatchOutput = bdioUploadService.uploadBdio(uploadRequest).getOutput();
for (UploadOutput uploadOutput : uploadBatchOutput) {
assertEquals(Result.SUCCESS, uploadOutput.getResult(), String.format("Upload result for %s was not successful", uploadOutput.getCodeLocationName()));
}
}
use of com.synopsys.integration.blackduck.codelocation.upload.UploadBatchOutput in project blackduck-docker-inspector by blackducksoftware.
the class BlackDuckClient method uploadBdio.
public void uploadBdio(File bdioFile, String codeLocationName, NameVersion projectAndVersion) throws IntegrationException {
if (config.isOfflineMode()) {
logger.info("Upload of BDIO has been disabled by offline mode");
return;
}
logger.info("Uploading BDIO files.");
BlackDuckHttpClient httpConnection = createHttpConnection(intLogger);
BlackDuckServicesFactory blackDuckServicesFactory = createBlackDuckServicesFactory(intLogger, httpConnection);
BdioUploadService bdioUploadService = blackDuckServicesFactory.createBdioUploadService();
UploadBatch uploadBatch = new UploadBatch();
UploadTarget uploadTarget = UploadTarget.createDefault(projectAndVersion, codeLocationName, bdioFile);
logger.info(String.format("uploading %s", uploadTarget.getUploadFile().getName()));
uploadBatch.addUploadTarget(uploadTarget);
BdioUploadCodeLocationCreationRequest uploadRequest = bdioUploadService.createUploadRequest(uploadBatch);
CodeLocationCreationData<UploadBatchOutput> bdioUploadResults = bdioUploadService.uploadBdio(uploadRequest);
bdioUploadResults.getOutput().getOutputs().stream().forEach(o -> logger.debug(String.format("\tUpload %s: output: %s%n", o.getCodeLocationName(), o.getResponse().orElse("unknown"))));
logger.info(String.format("Uploaded bdio file %s to %s", bdioFile.getName(), config.getBlackDuckUrl()));
}
Aggregations