Search in sources :

Example 56 with CodeLocation

use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.

the class PackageJsonExtractorFunctionalTest method extractWithNoDevDependencies.

@Test
void extractWithNoDevDependencies() {
    Extraction extraction = createExtractor(NpmDependencyType.PEER, NpmDependencyType.DEV).extract(packageJsonInputStream);
    assertEquals(1, extraction.getCodeLocations().size());
    CodeLocation codeLocation = extraction.getCodeLocations().get(0);
    DependencyGraph dependencyGraph = codeLocation.getDependencyGraph();
    GraphAssert graphAssert = new GraphAssert(Forge.RUBYGEMS, dependencyGraph);
    graphAssert.hasRootDependency(testDep1);
    graphAssert.hasRootDependency(testDep2);
    graphAssert.hasNoDependency(testDevDep1);
    graphAssert.hasNoDependency(testDevDep2);
    graphAssert.hasNoDependency(testPeerDep1);
    graphAssert.hasNoDependency(testPeerDep2);
    graphAssert.hasRootSize(2);
}
Also used : CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) GraphAssert(com.synopsys.integration.detectable.util.graph.GraphAssert) Extraction(com.synopsys.integration.detectable.extraction.Extraction) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.jupiter.api.Test) FunctionalTest(com.synopsys.integration.detectable.annotations.FunctionalTest)

Example 57 with CodeLocation

use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.

the class PackageJsonExtractorTest method extractWithNoDevOrPeerDependencies.

@Test
void extractWithNoDevOrPeerDependencies() {
    PackageJson packageJson = createPackageJson();
    Extraction extraction = createExtractor(NpmDependencyType.DEV, NpmDependencyType.PEER).extract(packageJson);
    assertEquals(1, extraction.getCodeLocations().size());
    CodeLocation codeLocation = extraction.getCodeLocations().get(0);
    DependencyGraph dependencyGraph = codeLocation.getDependencyGraph();
    GraphAssert graphAssert = new GraphAssert(Forge.RUBYGEMS, dependencyGraph);
    graphAssert.hasRootDependency(testDep1);
    graphAssert.hasRootDependency(testDep2);
    graphAssert.hasNoDependency(testDevDep1);
    graphAssert.hasNoDependency(testDevDep2);
    graphAssert.hasRootSize(2);
}
Also used : CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) GraphAssert(com.synopsys.integration.detectable.util.graph.GraphAssert) Extraction(com.synopsys.integration.detectable.extraction.Extraction) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) PackageJson(com.synopsys.integration.detectable.detectables.npm.packagejson.model.PackageJson) Test(org.junit.jupiter.api.Test) UnitTest(com.synopsys.integration.detectable.annotations.UnitTest)

Example 58 with CodeLocation

use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.

the class PackageJsonExtractorTest method extractWithDevNoPeerDependencies.

@Test
void extractWithDevNoPeerDependencies() {
    PackageJson packageJson = createPackageJson();
    Extraction extraction = createExtractor(NpmDependencyType.PEER).extract(packageJson);
    assertEquals(1, extraction.getCodeLocations().size());
    CodeLocation codeLocation = extraction.getCodeLocations().get(0);
    DependencyGraph dependencyGraph = codeLocation.getDependencyGraph();
    GraphAssert graphAssert = new GraphAssert(Forge.RUBYGEMS, dependencyGraph);
    graphAssert.hasRootDependency(testDep1);
    graphAssert.hasRootDependency(testDep2);
    graphAssert.hasRootDependency(testDevDep1);
    graphAssert.hasRootDependency(testDevDep2);
    graphAssert.hasRootSize(4);
}
Also used : CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) GraphAssert(com.synopsys.integration.detectable.util.graph.GraphAssert) Extraction(com.synopsys.integration.detectable.extraction.Extraction) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) PackageJson(com.synopsys.integration.detectable.detectables.npm.packagejson.model.PackageJson) Test(org.junit.jupiter.api.Test) UnitTest(com.synopsys.integration.detectable.annotations.UnitTest)

Example 59 with CodeLocation

use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation 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 60 with CodeLocation

use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.

the class DependencyFileDetailGeneratorTest method testDependencyCreatedWithEachForge.

@Test
public void testDependencyCreatedWithEachForge() {
    File mockFile = Mockito.mock(File.class);
    Mockito.when(mockFile.toString()).thenReturn("Example");
    Set<PackageDetails> packages = new HashSet<>();
    packages.add(new PackageDetails("testPackageName1", "testPackageVersion1", "testPackageArch1"));
    packages.add(new PackageDetails("testPackageName2", "testPackageVersion2", "testPackageArch2"));
    ExternalIdFactory externalIdFactory = new ExternalIdFactory();
    ClangPackageDetailsTransformer clangPackageDetailsTransformer = new ClangPackageDetailsTransformer(externalIdFactory);
    CodeLocation codeLocation = clangPackageDetailsTransformer.toCodeLocation(Arrays.asList(Forge.CENTOS, Forge.FEDORA, Forge.REDHAT), packages);
    Set<Dependency> dependencies = codeLocation.getDependencyGraph().getRootDependencies();
    assertEquals(6, dependencies.size());
    for (Dependency dependency : dependencies) {
        System.out.printf("Checking dependency: %s:%s / %s\n", dependency.getName(), dependency.getVersion(), dependency.getExternalId().getForge().getName());
        char indexChar = dependency.getName().charAt(15);
        assertTrue(indexChar == '1' || indexChar == '2' || indexChar == '3');
        String forge = dependency.getExternalId().getForge().getName();
        assertTrue("centos".equals(forge) || "fedora".equals(forge) || "redhat".equals(forge));
        assertEquals(String.format("testPackageName%c", indexChar), dependency.getName());
        assertEquals(String.format("testPackageVersion%c", indexChar), dependency.getVersion());
        assertEquals(String.format("testPackageArch%c", indexChar), dependency.getExternalId().getArchitecture());
        assertEquals(forge, dependency.getExternalId().getForge().getName());
        assertEquals(String.format("testPackageName%c", indexChar), dependency.getExternalId().getName());
        assertEquals(String.format("testPackageVersion%c", indexChar), dependency.getExternalId().getVersion());
    }
}
Also used : CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) File(java.io.File) PackageDetails(com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetails) HashSet(java.util.HashSet) ClangPackageDetailsTransformer(com.synopsys.integration.detectable.detectables.clang.dependencyfile.ClangPackageDetailsTransformer) Test(org.junit.jupiter.api.Test)

Aggregations

CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)104 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)60 Extraction (com.synopsys.integration.detectable.extraction.Extraction)41 File (java.io.File)24 ArrayList (java.util.ArrayList)23 Test (org.junit.jupiter.api.Test)22 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)21 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)20 NameVersion (com.synopsys.integration.util.NameVersion)19 IOException (java.io.IOException)19 BasicDependencyGraph (com.synopsys.integration.bdio.graph.BasicDependencyGraph)16 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)16 List (java.util.List)14 UnitTest (com.synopsys.integration.detectable.annotations.UnitTest)13 ExecutableOutput (com.synopsys.integration.executable.ExecutableOutput)11 ExecutableRunnerException (com.synopsys.integration.executable.ExecutableRunnerException)10 Optional (java.util.Optional)10 Collectors (java.util.stream.Collectors)10 Logger (org.slf4j.Logger)10 LoggerFactory (org.slf4j.LoggerFactory)10