Search in sources :

Example 1 with BdioExternalIdentifier

use of com.synopsys.integration.bdio.model.BdioExternalIdentifier in project hub-detect by blackducksoftware.

the class NugetInspectorPackagerTest method createCodeLocationDWService.

@Test(timeout = 5000L)
public void createCodeLocationDWService() throws IOException {
    final File dependencyNodeFile = new File(getClass().getResource("/nuget/dwCheckApi_inspection_martin.json").getFile());
    final ExternalIdFactory externalIdFactory = new ExternalIdFactory();
    final NugetInspectorPackager packager = new NugetInspectorPackager(gson, externalIdFactory);
    final NugetParseResult result = packager.createDetectCodeLocation(dependencyNodeFile);
    for (final DetectCodeLocation codeLocation : result.codeLocations) {
        final BdioPropertyHelper bdioPropertyHelper = new BdioPropertyHelper();
        final BdioNodeFactory bdioNodeFactory = new BdioNodeFactory(bdioPropertyHelper);
        final DependencyGraphTransformer dependencyNodeTransformer = new DependencyGraphTransformer(bdioPropertyHelper, bdioNodeFactory);
        final BdioExternalIdentifier projectId = bdioPropertyHelper.createExternalIdentifier(codeLocation.getExternalId());
        final BdioProject project = bdioNodeFactory.createProject(result.projectName, result.projectVersion, Forge.NUGET.toString(), projectId);
        final Map<ExternalId, BdioNode> components = new HashMap<>();
        components.put(codeLocation.getExternalId(), project);
        final List<BdioComponent> bdioComponents = dependencyNodeTransformer.transformDependencyGraph(codeLocation.getDependencyGraph(), project, codeLocation.getDependencyGraph().getRootDependencies(), components);
        assertEquals(bdioComponents.size(), bdioComponents.size());
    }
}
Also used : BdioNode(com.synopsys.integration.bdio.model.BdioNode) HashMap(java.util.HashMap) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) BdioComponent(com.synopsys.integration.bdio.model.BdioComponent) BdioExternalIdentifier(com.synopsys.integration.bdio.model.BdioExternalIdentifier) BdioProject(com.synopsys.integration.bdio.model.BdioProject) BdioNodeFactory(com.synopsys.integration.bdio.BdioNodeFactory) DetectCodeLocation(com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation) DependencyGraphTransformer(com.synopsys.integration.bdio.graph.DependencyGraphTransformer) BdioPropertyHelper(com.synopsys.integration.bdio.BdioPropertyHelper) File(java.io.File) Test(org.junit.Test)

Aggregations

DetectCodeLocation (com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation)1 BdioNodeFactory (com.synopsys.integration.bdio.BdioNodeFactory)1 BdioPropertyHelper (com.synopsys.integration.bdio.BdioPropertyHelper)1 DependencyGraphTransformer (com.synopsys.integration.bdio.graph.DependencyGraphTransformer)1 BdioComponent (com.synopsys.integration.bdio.model.BdioComponent)1 BdioExternalIdentifier (com.synopsys.integration.bdio.model.BdioExternalIdentifier)1 BdioNode (com.synopsys.integration.bdio.model.BdioNode)1 BdioProject (com.synopsys.integration.bdio.model.BdioProject)1 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)1 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)1 File (java.io.File)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1