Search in sources :

Example 31 with NameVersionGraphAssert

use of com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert in project synopsys-detect by blackducksoftware.

the class NpmOutputParserTest method npmCliDependencyFinder.

@Test
public void npmCliDependencyFinder() {
    NpmCliParser parser = new NpmCliParser(new ExternalIdFactory(), EnumListFilter.excludeNone());
    String testIn = String.join(System.lineSeparator(), Arrays.asList("{", "   \"name\": \"node-js\",", "   \"version\": \"0.2.0\",", "   \"dependencies\": {", "       \"upper-case\": {", "       \"version\": \"1.1.3\",", "       \"from\": \"upper-case@latest\",", "       \"resolved\": \"https://registry.npmjs.org/upper-case/-/upper-case-1.1.3.tgz\"", "       },", "       \"xml2js\": {", "           \"version\": \"0.4.17\",", "           \"from\": \"xml2js@latest\",", "           \"resolved\": \"https://registry.npmjs.org/xml2js/-/xml2js-0.4.17.tgz\",", "            \"dependencies\": {", "               \"sax\": {", "                   \"version\": \"1.2.2\",", "                   \"from\": \"sax@>=0.6.0\",", "                   \"resolved\": \"https://registry.npmjs.org/sax/-/sax-1.2.2.tgz\"", "               },", "               \"xmlbuilder\": {", "                   \"version\": \"4.2.1\",", "                   \"from\": \"xmlbuilder@>=4.1.0 <5.0.0\",", "                   \"resolved\": \"https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-4.2.1.tgz\",", "                   \"dependencies\": {", "                       \"lodash\": {", "                           \"version\": \"4.17.4\",", "                           \"from\": \"lodash@>=4.0.0 <5.0.0\",", "                           \"resolved\": \"https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz\"", "                       }", "                   }", "               }", "           }", "       }", "   }", "}"));
    NpmDependencyTypeFilter npmDependencyTypeFilter = new NpmDependencyTypeFilter(Collections.emptySet(), Collections.emptySet(), true, true);
    PackageJson packageJson = new PackageJson();
    NpmPackagerResult result = parser.convertNpmJsonFileToCodeLocation(testIn, packageJson);
    Assertions.assertEquals("node-js", result.getProjectName());
    Assertions.assertEquals("0.2.0", result.getProjectVersion());
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.NPMJS, result.getCodeLocation().getDependencyGraph());
    graphAssert.hasRootSize(2);
    graphAssert.hasRootDependency("xml2js", "0.4.17");
    graphAssert.hasRootDependency("upper-case", "1.1.3");
    graphAssert.hasParentChildRelationship("xml2js", "0.4.17", "xmlbuilder", "4.2.1");
    graphAssert.hasParentChildRelationship("xml2js", "0.4.17", "sax", "1.2.2");
    graphAssert.hasParentChildRelationship("xmlbuilder", "4.2.1", "lodash", "4.17.4");
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) NpmDependencyTypeFilter(com.synopsys.integration.detectable.detectables.npm.cli.parse.NpmDependencyTypeFilter) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) PackageJson(com.synopsys.integration.detectable.detectables.npm.packagejson.model.PackageJson) NpmPackagerResult(com.synopsys.integration.detectable.detectables.npm.lockfile.result.NpmPackagerResult) NpmCliParser(com.synopsys.integration.detectable.detectables.npm.cli.parse.NpmCliParser) Test(org.junit.jupiter.api.Test)

Example 32 with NameVersionGraphAssert

use of com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert in project synopsys-detect by blackducksoftware.

the class GoVndrDetectableTest method assertExtraction.

@Override
public void assertExtraction(@NotNull Extraction extraction) {
    Assertions.assertEquals(1, extraction.getCodeLocations().size());
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.GOLANG, extraction.getCodeLocations().get(0).getDependencyGraph());
    graphAssert.hasRootSize(5);
    graphAssert.hasRootDependency("github.com/klauspost/compress", "v1.4.1");
    graphAssert.hasRootDependency("github.com/klauspost/cpuid", "v1.2.0");
    graphAssert.hasRootDependency("github.com/klauspost/pgzip", "v1.2.1");
    graphAssert.hasRootDependency("github.com/Azure/go-ansiterm", "d6e3b3328b783f23731bc4d058875b0371ff8109");
    graphAssert.hasRootDependency("github.com/Microsoft/go-winio", "5b44b70ab3ab4d291a7c1d28afe7b4afeced0ed4");
    graphAssert.hasNoDependency("github.com/Azure/go-ansiterm", "dont_include_me");
}
Also used : NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert)

Example 33 with NameVersionGraphAssert

use of com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert in project synopsys-detect by blackducksoftware.

the class VndrParserTest method invalidLine.

@Test
void invalidLine() {
    DependencyGraph dependencyGraph = vndrParser.parseVendorConf(Arrays.asList("github.com/klauspost/compress v1.4.1", "invlaid_line"));
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.GOLANG, dependencyGraph);
    graphAssert.hasRootSize(1);
    graphAssert.hasRootDependency("github.com/klauspost/compress", "v1.4.1");
}
Also used : NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.jupiter.api.Test)

Example 34 with NameVersionGraphAssert

use of com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert in project synopsys-detect by blackducksoftware.

the class VndrParserTest method happyPathTest.

@Test
void happyPathTest() {
    DependencyGraph dependencyGraph = vndrParser.parseVendorConf(Arrays.asList("github.com/klauspost/compress v1.4.1", "github.com/klauspost/cpuid v1.2.0"));
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.GOLANG, dependencyGraph);
    graphAssert.hasRootSize(2);
    graphAssert.hasRootDependency("github.com/klauspost/compress", "v1.4.1");
    graphAssert.hasRootDependency("github.com/klauspost/cpuid", "v1.2.0");
}
Also used : NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.jupiter.api.Test)

Example 35 with NameVersionGraphAssert

use of com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert in project synopsys-detect by blackducksoftware.

the class VndrParserTest method whitespaceSeparationTest.

@Test
void whitespaceSeparationTest() {
    DependencyGraph dependencyGraph = vndrParser.parseVendorConf(Arrays.asList("github.com/Microsoft/go-winio v1", "github.com/Microsoft/go-winio   v2", "github.com/Microsoft/go-winio\tv3"));
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.GOLANG, dependencyGraph);
    graphAssert.hasRootSize(3);
    graphAssert.hasRootDependency("github.com/Microsoft/go-winio", "v1");
    graphAssert.hasRootDependency("github.com/Microsoft/go-winio", "v2");
    graphAssert.hasRootDependency("github.com/Microsoft/go-winio", "v3");
}
Also used : NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.jupiter.api.Test)

Aggregations

NameVersionGraphAssert (com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert)76 Test (org.junit.jupiter.api.Test)35 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)32 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)18 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)10 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)10 UnitTest (com.synopsys.integration.detectable.annotations.UnitTest)7 ArrayList (java.util.ArrayList)6 PnpmLockYaml (com.synopsys.integration.detectable.detectables.pnpm.lockfile.model.PnpmLockYaml)5 PnpmYamlTransformer (com.synopsys.integration.detectable.detectables.pnpm.lockfile.process.PnpmYamlTransformer)5 PipFreeze (com.synopsys.integration.detectable.detectables.pipenv.build.model.PipFreeze)4 PipenvGraph (com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraph)4 PipenvGraphEntry (com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraphEntry)4 PipenvTransformer (com.synopsys.integration.detectable.detectables.pipenv.build.parser.PipenvTransformer)4 PoetryLockParser (com.synopsys.integration.detectable.detectables.poetry.parser.PoetryLockParser)4 FunctionalTest (com.synopsys.integration.detectable.annotations.FunctionalTest)3 GemlockParser (com.synopsys.integration.detectable.detectables.rubygems.gemlock.parse.GemlockParser)3 BitbakeGraph (com.synopsys.integration.detectable.detectables.bitbake.model.BitbakeGraph)2 BitbakeDependencyGraphTransformer (com.synopsys.integration.detectable.detectables.bitbake.transform.BitbakeDependencyGraphTransformer)2 CargoLockPackage (com.synopsys.integration.detectable.detectables.cargo.model.CargoLockPackage)2