Search in sources :

Example 1 with NugetInspectorParser

use of com.synopsys.integration.detectable.detectables.nuget.parse.NugetInspectorParser in project synopsys-detect by blackducksoftware.

the class NugetInspectorParserTest method createCodeLocationDWService.

@Test
public void createCodeLocationDWService() {
    Assertions.assertTimeout(Duration.ofMillis(5000L), () -> {
        String dependencyNodeFile = FunctionalTestFiles.asString("/nuget/dwCheckApi_inspection_martin.json");
        ExternalIdFactory externalIdFactory = new ExternalIdFactory();
        NugetInspectorParser packager = new NugetInspectorParser(gson, externalIdFactory);
        NugetParseResult result = packager.createCodeLocation(dependencyNodeFile);
        for (CodeLocation codeLocation : result.getCodeLocations()) {
            BdioPropertyHelper bdioPropertyHelper = new BdioPropertyHelper();
            BdioNodeFactory bdioNodeFactory = new BdioNodeFactory(bdioPropertyHelper);
            DependencyGraphTransformer dependencyNodeTransformer = new DependencyGraphTransformer(bdioPropertyHelper, bdioNodeFactory);
            BdioExternalIdentifier projectId = bdioPropertyHelper.createExternalIdentifier(codeLocation.getExternalId().get());
            BdioProject project = bdioNodeFactory.createProject(result.getProjectName(), result.getProjectVersion(), BdioId.createFromPieces(Forge.NUGET.toString()), projectId);
            Map<ExternalId, BdioNode> components = new HashMap<>();
            components.put(codeLocation.getExternalId().get(), project);
            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) CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) 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) NugetInspectorParser(com.synopsys.integration.detectable.detectables.nuget.parse.NugetInspectorParser) BdioExternalIdentifier(com.synopsys.integration.bdio.model.BdioExternalIdentifier) BdioProject(com.synopsys.integration.bdio.model.BdioProject) BdioNodeFactory(com.synopsys.integration.bdio.BdioNodeFactory) DependencyGraphTransformer(com.synopsys.integration.bdio.graph.DependencyGraphTransformer) NugetParseResult(com.synopsys.integration.detectable.detectables.nuget.parse.NugetParseResult) BdioPropertyHelper(com.synopsys.integration.bdio.BdioPropertyHelper) Test(org.junit.jupiter.api.Test)

Example 2 with NugetInspectorParser

use of com.synopsys.integration.detectable.detectables.nuget.parse.NugetInspectorParser in project synopsys-detect by blackducksoftware.

the class NugetInspectorParserTest method createCodeLocation.

private void createCodeLocation(String dependencyNodeFile, List<String> expectedOutputFiles) {
    ExternalIdFactory externalIdFactory = new ExternalIdFactory();
    NugetInspectorParser packager = new NugetInspectorParser(gson, externalIdFactory);
    NugetParseResult result = packager.createCodeLocation(dependencyNodeFile);
    for (int i = 0; i < expectedOutputFiles.size(); i++) {
        CodeLocation codeLocation = result.getCodeLocations().get(i);
        String expectedOutputFile = expectedOutputFiles.get(i);
        GraphCompare.assertEqualsResource(expectedOutputFile, codeLocation.getDependencyGraph());
    }
}
Also used : CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) NugetParseResult(com.synopsys.integration.detectable.detectables.nuget.parse.NugetParseResult) NugetInspectorParser(com.synopsys.integration.detectable.detectables.nuget.parse.NugetInspectorParser)

Example 3 with NugetInspectorParser

use of com.synopsys.integration.detectable.detectables.nuget.parse.NugetInspectorParser in project synopsys-detect by blackducksoftware.

the class NugetInspectorParserPerfTest method performanceTestNuget.

@Disabled
@Test
public void performanceTestNuget() {
    Assertions.assertTimeout(Duration.ofSeconds(120), () -> {
        String dependencyGraphFile = FunctionalTestFiles.asString("/nuget/dwCheckApi_inspection.json");
        NugetInspectorParser packager = new NugetInspectorParser(gson, externalIdFactory);
        NugetParseResult result = packager.createCodeLocation(dependencyGraphFile);
        CodeLocation codeLocation = result.getCodeLocations().get(0);
        BdioPropertyHelper bdioPropertyHelper = new BdioPropertyHelper();
        BdioNodeFactory bdioNodeFactory = new BdioNodeFactory(bdioPropertyHelper);
        DependencyGraphTransformer dependencyGraphTransformer = new DependencyGraphTransformer(bdioPropertyHelper, bdioNodeFactory);
        BdioProject bdioNode = bdioNodeFactory.createProject("test", "1.0.0", BdioId.createFromPieces("bdioId"), externalIdFactory.createMavenExternalId("group", "name", "version"));
        List<BdioComponent> components = dependencyGraphTransformer.transformDependencyGraph(codeLocation.getDependencyGraph(), bdioNode, codeLocation.getDependencyGraph().getRootDependencies(), new HashMap<>());
        assertEquals(211, components.size());
    });
}
Also used : BdioProject(com.synopsys.integration.bdio.model.BdioProject) CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) BdioNodeFactory(com.synopsys.integration.bdio.BdioNodeFactory) BdioComponent(com.synopsys.integration.bdio.model.BdioComponent) DependencyGraphTransformer(com.synopsys.integration.bdio.graph.DependencyGraphTransformer) NugetParseResult(com.synopsys.integration.detectable.detectables.nuget.parse.NugetParseResult) NugetInspectorParser(com.synopsys.integration.detectable.detectables.nuget.parse.NugetInspectorParser) BdioPropertyHelper(com.synopsys.integration.bdio.BdioPropertyHelper) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 4 with NugetInspectorParser

use of com.synopsys.integration.detectable.detectables.nuget.parse.NugetInspectorParser in project synopsys-detect by blackducksoftware.

the class NugetParserTest method handlesNullContainer.

@Test
public void handlesNullContainer() {
    NugetInspection result = new NugetInspection();
    result.containers.add(null);
    String resultText = gson.toJson(result);
    NugetInspectorParser parser = new NugetInspectorParser(gson, new ExternalIdFactory());
    NugetParseResult parsed = parser.createCodeLocation(resultText);
    Assertions.assertEquals(0, parsed.getCodeLocations().size());
}
Also used : NugetInspection(com.synopsys.integration.detectable.detectables.nuget.model.NugetInspection) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) NugetParseResult(com.synopsys.integration.detectable.detectables.nuget.parse.NugetParseResult) NugetInspectorParser(com.synopsys.integration.detectable.detectables.nuget.parse.NugetInspectorParser) Test(org.junit.jupiter.api.Test)

Example 5 with NugetInspectorParser

use of com.synopsys.integration.detectable.detectables.nuget.parse.NugetInspectorParser in project synopsys-detect by blackducksoftware.

the class NugetParserTest method handlesNullChild.

@Test
public void handlesNullChild() {
    NugetInspection result = new NugetInspection();
    NugetContainer container = new NugetContainer();
    container.type = NugetContainerType.SOLUTION;
    container.children = new ArrayList<>();
    container.children.add(null);
    result.containers.add(container);
    String resultText = gson.toJson(result);
    NugetInspectorParser parser = new NugetInspectorParser(gson, new ExternalIdFactory());
    NugetParseResult parsed = parser.createCodeLocation(resultText);
    Assertions.assertEquals(0, parsed.getCodeLocations().size());
}
Also used : NugetInspection(com.synopsys.integration.detectable.detectables.nuget.model.NugetInspection) NugetContainer(com.synopsys.integration.detectable.detectables.nuget.model.NugetContainer) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) NugetParseResult(com.synopsys.integration.detectable.detectables.nuget.parse.NugetParseResult) NugetInspectorParser(com.synopsys.integration.detectable.detectables.nuget.parse.NugetInspectorParser) Test(org.junit.jupiter.api.Test)

Aggregations

NugetInspectorParser (com.synopsys.integration.detectable.detectables.nuget.parse.NugetInspectorParser)5 NugetParseResult (com.synopsys.integration.detectable.detectables.nuget.parse.NugetParseResult)5 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)4 Test (org.junit.jupiter.api.Test)4 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)3 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 BdioProject (com.synopsys.integration.bdio.model.BdioProject)2 NugetInspection (com.synopsys.integration.detectable.detectables.nuget.model.NugetInspection)2 BdioExternalIdentifier (com.synopsys.integration.bdio.model.BdioExternalIdentifier)1 BdioNode (com.synopsys.integration.bdio.model.BdioNode)1 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)1 NugetContainer (com.synopsys.integration.detectable.detectables.nuget.model.NugetContainer)1 HashMap (java.util.HashMap)1 Disabled (org.junit.jupiter.api.Disabled)1