Search in sources :

Example 6 with UploadOutput

use of com.synopsys.integration.blackduck.codelocation.upload.UploadOutput 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()));
    }
}
Also used : UploadBatchOutput(com.synopsys.integration.blackduck.codelocation.upload.UploadBatchOutput) NameVersion(com.synopsys.integration.util.NameVersion) BdioUploadService(com.synopsys.integration.blackduck.codelocation.bdiolegacy.BdioUploadService) BdioUploadCodeLocationCreationRequest(com.synopsys.integration.blackduck.codelocation.bdiolegacy.BdioUploadCodeLocationCreationRequest) UploadBatch(com.synopsys.integration.blackduck.codelocation.upload.UploadBatch) ProjectDependencyGraph(com.synopsys.integration.bdio.graph.ProjectDependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) UploadOutput(com.synopsys.integration.blackduck.codelocation.upload.UploadOutput) File(java.io.File) SimpleBdioDocument(com.synopsys.integration.bdio.model.SimpleBdioDocument)

Aggregations

UploadOutput (com.synopsys.integration.blackduck.codelocation.upload.UploadOutput)6 UploadBatchOutput (com.synopsys.integration.blackduck.codelocation.upload.UploadBatchOutput)5 BlackDuckIntegrationException (com.synopsys.integration.blackduck.exception.BlackDuckIntegrationException)3 ArrayList (java.util.ArrayList)3 Future (java.util.concurrent.Future)3 BdioUploadService (com.synopsys.integration.blackduck.codelocation.bdiolegacy.BdioUploadService)2 UploadBatch (com.synopsys.integration.blackduck.codelocation.upload.UploadBatch)2 NameVersion (com.synopsys.integration.util.NameVersion)2 File (java.io.File)2 ProjectDependencyGraph (com.synopsys.integration.bdio.graph.ProjectDependencyGraph)1 SimpleBdioDocument (com.synopsys.integration.bdio.model.SimpleBdioDocument)1 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)1 UserView (com.synopsys.integration.blackduck.api.generated.view.UserView)1 BdioUploadCodeLocationCreationRequest (com.synopsys.integration.blackduck.codelocation.bdiolegacy.BdioUploadCodeLocationCreationRequest)1 DetectUserFriendlyException (com.synopsys.integration.detect.configuration.DetectUserFriendlyException)1 Date (java.util.Date)1 Test (org.junit.jupiter.api.Test)1