Search in sources :

Example 1 with DependencyGraphTransformer

use of com.synopsys.integration.bdio.graph.DependencyGraphTransformer 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)

Example 2 with DependencyGraphTransformer

use of com.synopsys.integration.bdio.graph.DependencyGraphTransformer in project hub-detect by blackducksoftware.

the class NugetInspectorPackagerPerfTest method performanceTestNuget.

@Test(timeout = 120000L)
public void performanceTestNuget() throws IOException {
    final File dependencyGraphFile = new File(getClass().getResource("/nuget/dwCheckApi_inspection.json").getFile());
    final NugetInspectorPackager packager = new NugetInspectorPackager(gson, externalIdFactory);
    final NugetParseResult result = packager.createDetectCodeLocation(dependencyGraphFile);
    final DetectCodeLocation codeLocation = result.codeLocations.get(0);
    final BdioPropertyHelper bdioPropertyHelper = new BdioPropertyHelper();
    final BdioNodeFactory bdioNodeFactory = new BdioNodeFactory(bdioPropertyHelper);
    final DependencyGraphTransformer dependencyGraphTransformer = new DependencyGraphTransformer(bdioPropertyHelper, bdioNodeFactory);
    final BdioProject bdioNode = bdioNodeFactory.createProject("test", "1.0.0", "bdioId", externalIdFactory.createMavenExternalId("group", "name", "version"));
    final List<BdioComponent> components = dependencyGraphTransformer.transformDependencyGraph(codeLocation.getDependencyGraph(), bdioNode, codeLocation.getDependencyGraph().getRootDependencies(), new HashMap<ExternalId, BdioNode>());
    assertEquals(211, components.size());
}
Also used : BdioNode(com.synopsys.integration.bdio.model.BdioNode) BdioComponent(com.synopsys.integration.bdio.model.BdioComponent) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) 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)2 BdioNodeFactory (com.synopsys.integration.bdio.BdioNodeFactory)2 BdioPropertyHelper (com.synopsys.integration.bdio.BdioPropertyHelper)2 DependencyGraphTransformer (com.synopsys.integration.bdio.graph.DependencyGraphTransformer)2 BdioComponent (com.synopsys.integration.bdio.model.BdioComponent)2 BdioNode (com.synopsys.integration.bdio.model.BdioNode)2 BdioProject (com.synopsys.integration.bdio.model.BdioProject)2 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)2 File (java.io.File)2 Test (org.junit.Test)2 BdioExternalIdentifier (com.synopsys.integration.bdio.model.BdioExternalIdentifier)1 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)1 HashMap (java.util.HashMap)1