Search in sources :

Example 16 with DetectCodeLocation

use of com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation in project hub-detect by blackducksoftware.

the class NugetInspectorPackagerTest method createCodeLocation.

private void createCodeLocation(final File dependencyNodeFile, final List<String> expectedOutputFiles) throws IOException {
    final ExternalIdFactory externalIdFactory = new ExternalIdFactory();
    final NugetInspectorPackager packager = new NugetInspectorPackager(gson, externalIdFactory);
    final NugetParseResult result = packager.createDetectCodeLocation(dependencyNodeFile);
    for (int i = 0; i < expectedOutputFiles.size(); i++) {
        final DetectCodeLocation codeLocation = result.codeLocations.get(i);
        final String expectedOutputFile = expectedOutputFiles.get(i);
        DependencyGraphResourceTestUtil.assertGraph(expectedOutputFile, codeLocation.getDependencyGraph());
    }
}
Also used : DetectCodeLocation(com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)

Example 17 with DetectCodeLocation

use of com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation in project hub-detect by blackducksoftware.

the class GradleReportParserTest method complexTest.

@Test
public void complexTest() throws IOException {
    final DetectCodeLocation codeLocation = build("src/test/resources/gradle/parse-tests/complex_dependencyGraph.txt");
    final DependencyGraph graph = codeLocation.getDependencyGraph();
    assertHasMavenGav(graph, "non-project:with-nested:1.0.0");
    assertHasMavenGav(graph, "solo:component:4.12");
    assertHasMavenGav(graph, "some.group:child:2.2.2");
    assertHasMavenGav(graph, "terminal:child:6.2.3");
    assertDoesNotHave(graph, "child-project");
    assertDoesNotHave(graph, "nested-parent");
    assertDoesNotHave(graph, "spring-webflux");
    assertDoesNotHave(graph, "spring-beans");
    assertDoesNotHave(graph, "spring-core");
    assertDoesNotHave(graph, "spring-web");
    assertDoesNotHave(graph, "should-suppress");
    assertHasRootMavenGavs(graph, "solo:component:4.12", "non-project:with-nested:1.0.0", "some.group:parent:5.0.0", "terminal:child:6.2.3");
    assertParentHasChildMavenGav("some.group:parent:5.0.0", graph, "some.group:child:2.2.2");
}
Also used : DetectCodeLocation(com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.Test)

Example 18 with DetectCodeLocation

use of com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation in project hub-detect by blackducksoftware.

the class MavenCodeLocationPackagerTest method createNewCodeLocationTest.

private void createNewCodeLocationTest(final String mavenOutputText, final String expectedResourcePath, final int numberOfCodeLocations, final String excludedModules, final String includedModules, int codeLocationIndex, final String scope) {
    final MavenCodeLocationPackager mavenCodeLocationPackager = new MavenCodeLocationPackager(new ExternalIdFactory());
    final List<MavenParseResult> result = mavenCodeLocationPackager.extractCodeLocations("/test/path", mavenOutputText, scope, excludedModules, includedModules);
    assertEquals(numberOfCodeLocations, result.size());
    final DetectCodeLocation codeLocation = result.get(codeLocationIndex).codeLocation;
    testUtil.testJsonResource(expectedResourcePath, codeLocation);
}
Also used : DetectCodeLocation(com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)

Example 19 with DetectCodeLocation

use of com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation 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)

Example 20 with DetectCodeLocation

use of com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation in project hub-detect by blackducksoftware.

the class GradleReportParserTest method testImplementationsGraph.

@Test
public void testImplementationsGraph() throws IOException {
    final File file = new File("src/test/resources/gradle/gradle_implementations_dependencyGraph.txt");
    final GradleReportParser gradleReportParser = new GradleReportParser(new ExternalIdFactory());
    final Optional<DetectCodeLocation> result = gradleReportParser.parseDependencies(file);
    assertTrue(result.isPresent());
    System.out.println(new GsonBuilder().setPrettyPrinting().create().toJson(result.get()));
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) DetectCodeLocation(com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) File(java.io.File) Test(org.junit.Test)

Aggregations

DetectCodeLocation (com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation)44 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)22 Extraction (com.blackducksoftware.integration.hub.detect.workflow.extraction.Extraction)18 File (java.io.File)17 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)15 ArrayList (java.util.ArrayList)10 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)9 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)9 MutableDependencyGraph (com.synopsys.integration.bdio.graph.MutableDependencyGraph)8 MutableMapDependencyGraph (com.synopsys.integration.bdio.graph.MutableMapDependencyGraph)8 ExecutableOutput (com.blackducksoftware.integration.hub.detect.util.executable.ExecutableOutput)7 Test (org.junit.Test)7 Executable (com.blackducksoftware.integration.hub.detect.util.executable.Executable)5 List (java.util.List)5 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 Optional (java.util.Optional)4 Collectors (java.util.stream.Collectors)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4