Search in sources :

Example 71 with NameVersionGraphAssert

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

the class PubDepsParserTest method test.

@Test
public void test() {
    List<String> pubDepsLines = FunctionalTestFiles.asListOfStrings("/dart/pubDeps.txt");
    PubDepsParser pubDepsParser = new PubDepsParser();
    DependencyGraph dependencyGraph = pubDepsParser.parse(pubDepsLines);
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.DART, dependencyGraph);
    graphAssert.hasRootSize(4);
    graphAssert.hasRootDependency("charcode", "1.1.3");
    graphAssert.hasRootDependency("pedantic", "1.9.2");
    graphAssert.hasRootDependency("test", "1.15.3");
    graphAssert.hasRootDependency("typed_data", "1.2.0");
    graphAssert.hasParentChildRelationship("analyzer", "0.39.17", "_fe_analyzer_shared", "7.0.0");
    graphAssert.hasParentChildRelationship("glob", "1.2.0", "node_io", "1.1.1");
    graphAssert.hasParentChildRelationship("node_interop", "1.1.1", "js", "1.1.0");
    graphAssert.hasParentChildRelationship("js", "1.1.0", "async", "2.2.1");
    graphAssert.hasParentChildRelationship("async", "2.2.1", "charcode", "1.1.3");
    graphAssert.hasParentChildRelationship("typed_data", "1.2.0", "webkit_inspection_protocol", "0.7.3");
}
Also used : PubDepsParser(com.synopsys.integration.detectable.detectables.dart.pubdep.PubDepsParser) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.jupiter.api.Test)

Example 72 with NameVersionGraphAssert

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

the class VndrParserTest method commentsTest.

@Test
void commentsTest() {
    DependencyGraph dependencyGraph = vndrParser.parseVendorConf(Arrays.asList("github.com/Azure/go-ansiterm d6e3b3328b783f23731bc4d058875b0371ff8109 # v0.4.15", "github.com/klauspost/compress v1.4.1", "# github.com/Azure/go-ansiterm dont_include_me"));
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.GOLANG, dependencyGraph);
    graphAssert.hasRootSize(2);
    graphAssert.hasRootDependency("github.com/Azure/go-ansiterm", "d6e3b3328b783f23731bc4d058875b0371ff8109");
    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 73 with NameVersionGraphAssert

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

the class BitbakeDependencyGraphTransformerTest method ignoredNoVersionRelationship.

@Test
public void ignoredNoVersionRelationship() {
    ExternalIdFactory externalIdFactory = new ExternalIdFactory();
    BitbakeGraph bitbakeGraph = new BitbakeGraph();
    bitbakeGraph.addNode("example", "75", "meta");
    bitbakeGraph.addNode("foobar", null, "meta");
    bitbakeGraph.addChild("example", "foobar");
    Map<String, List<String>> recipeToLayerMap = new HashMap<>();
    recipeToLayerMap.put("example", Collections.singletonList("meta"));
    recipeToLayerMap.put("foobar", Collections.singletonList("meta"));
    BitbakeDependencyGraphTransformer bitbakeDependencyGraphTransformer = new BitbakeDependencyGraphTransformer(EnumListFilter.excludeNone());
    DependencyGraph dependencyGraph = bitbakeDependencyGraphTransformer.transform(bitbakeGraph, recipeToLayerMap, null);
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.YOCTO, dependencyGraph);
    graphAssert.hasRootSize(1);
    ExternalId externalId = graphAssert.hasDependency(externalIdFactory.createYoctoExternalId("meta", "example", "75"));
    graphAssert.hasRelationshipCount(externalId, 0);
}
Also used : HashMap(java.util.HashMap) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) BitbakeDependencyGraphTransformer(com.synopsys.integration.detectable.detectables.bitbake.transform.BitbakeDependencyGraphTransformer) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) List(java.util.List) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) BitbakeGraph(com.synopsys.integration.detectable.detectables.bitbake.model.BitbakeGraph) Test(org.junit.jupiter.api.Test) UnitTest(com.synopsys.integration.detectable.annotations.UnitTest)

Example 74 with NameVersionGraphAssert

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

the class CargoDetectableTest method assertExtraction.

@Override
public void assertExtraction(@NotNull Extraction extraction) {
    Assertions.assertEquals(1, extraction.getCodeLocations().size());
    Assertions.assertEquals("cargo-audit", extraction.getProjectName());
    Assertions.assertEquals("0.12.0", extraction.getProjectVersion());
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.CRATES, extraction.getCodeLocations().get(0).getDependencyGraph());
    graphAssert.hasRootDependency("abscissa_core", "0.5.2");
    graphAssert.hasParentChildRelationship("abscissa_core", "0.5.2", "abscissa_derive", "0.5.0");
    graphAssert.hasParentChildRelationship("abscissa_core", "0.5.2", "backtrace", "0.3.46");
    graphAssert.hasParentChildRelationship("abscissa_derive", "0.5.0", "darling", "0.10.2");
    graphAssert.hasRootDependency("abscissa_derive", "0.5.0");
    graphAssert.hasRootDependency("backtrace", "0.3.46");
    graphAssert.hasRootDependency("darling", "0.10.2");
    graphAssert.hasRootSize(4);
}
Also used : NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert)

Example 75 with NameVersionGraphAssert

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

the class GoModDetectableVendoredTest method assertExtraction.

@Override
public void assertExtraction(@NotNull Extraction extraction) {
    assertSuccessfulExtraction(extraction);
    assertEquals(1, extraction.getCodeLocations().size());
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.GOLANG, extraction.getCodeLocations().get(0).getDependencyGraph());
    graphAssert.hasRootSize(1);
    graphAssert.hasRootDependency("golang.org/x/text", "v0.3.6");
    // This version should be replaced with a v0.3.6
    graphAssert.hasNoDependency("golang.org/x/text", "v0.3.0");
    graphAssert.hasNoDependency("golang.org/x/tools", "90fa682c2a6e");
    // sigs.k8s.io/yaml and it's transitives are unused as per `go mod why`
    graphAssert.hasNoDependency("sigs.k8s.io/yaml", "v1.2.0");
    graphAssert.hasNoDependency("github.com/davecgh/go-spew", "v1.1.1");
    graphAssert.hasNoDependency("gopkg.in/yaml.v2", "v2.2.8");
}
Also used : NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert)

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