Search in sources :

Example 41 with NameVersionGraphAssert

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

the class GoModDetectableTest 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(2);
    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.hasDependency("golang.org/x/tools", "90fa682c2a6e");
    graphAssert.hasParentChildRelationship("golang.org/x/text", "v0.3.6", "golang.org/x/tools", "90fa682c2a6e");
    graphAssert.hasRootDependency("sigs.k8s.io/yaml", "v1.2.0");
    graphAssert.hasDependency("github.com/davecgh/go-spew", "v1.1.1");
    graphAssert.hasParentChildRelationship("sigs.k8s.io/yaml", "v1.2.0", "github.com/davecgh/go-spew", "v1.1.1");
    graphAssert.hasDependency("gopkg.in/yaml.v2", "v2.2.8");
    graphAssert.hasParentChildRelationship("sigs.k8s.io/yaml", "v1.2.0", "gopkg.in/yaml.v2", "v2.2.8");
    graphAssert.hasDependency("gopkg.in/check.v1", "20d25e280405");
    graphAssert.hasParentChildRelationship("gopkg.in/yaml.v2", "v2.2.8", "gopkg.in/check.v1", "20d25e280405");
}
Also used : NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert)

Example 42 with NameVersionGraphAssert

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

the class GoModDetectableUnusedTest 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)

Example 43 with NameVersionGraphAssert

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

the class GoVendorDetectableTest 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(2);
    graphAssert.hasRootDependency("github.com/pkg/errors", "059132a15dd08d6704c67711dae0cf35ab991756");
    graphAssert.hasRootDependency("github.com/pkg/math", "f2ed9e40e245cdeec72c4b642d27ed4553f90667");
}
Also used : NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert)

Example 44 with NameVersionGraphAssert

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

the class MavenPomDetectableTest method assertExtraction.

@Override
public void assertExtraction(@NotNull Extraction extraction) {
    Assertions.assertEquals(1, extraction.getCodeLocations().size(), "A code location should have been generated.");
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.MAVEN, extraction.getCodeLocations().get(0).getDependencyGraph());
    graphAssert.hasRootSize(3);
    // ExternalIdFactory sets group for Maven external Ids
    ExternalIdFactory externalIdFactory = new ExternalIdFactory();
    ExternalId junit = externalIdFactory.createMavenExternalId("junit", "junit", "4.12");
    ExternalId powermockApiMockito = externalIdFactory.createMavenExternalId("org.powermock", "powermock-api-mockito", "1.6.6");
    ExternalId hubCommon = externalIdFactory.createMavenExternalId("com.blackducksoftware.integration", "hub-common", "13.1.2");
    ExternalId powermockApiMockitoCommon = externalIdFactory.createMavenExternalId("org.powermock", "powermock-api-mockito-common", "1.6.6");
    ExternalId powermockApiSupport = externalIdFactory.createMavenExternalId("org.powermock", "powermock-api-support", "1.6.6");
    ExternalId hamcrestCore = externalIdFactory.createMavenExternalId("org.hamcrest", "hamcrest-core", "1.3");
    ExternalId hubCommonRest = externalIdFactory.createMavenExternalId("com.blackducksoftware.integration", "hub-common-rest", "2.1.3");
    ExternalId mockitoCore = externalIdFactory.createMavenExternalId("org.mockito", "mockito-core", "1.10.19");
    ExternalId integrationCommon = externalIdFactory.createMavenExternalId("com.blackducksoftware.integration", "integration-common", "6.0.2");
    graphAssert.hasRootDependency(junit);
    graphAssert.hasRootDependency(powermockApiMockito);
    graphAssert.hasRootDependency(hubCommon);
    graphAssert.hasParentChildRelationship(powermockApiMockitoCommon, powermockApiSupport);
    graphAssert.hasParentChildRelationship(junit, hamcrestCore);
    graphAssert.hasParentChildRelationship(powermockApiMockito, powermockApiMockitoCommon);
    graphAssert.hasParentChildRelationship(powermockApiMockito, mockitoCore);
    graphAssert.hasParentChildRelationship(hubCommonRest, integrationCommon);
    graphAssert.hasParentChildRelationship(hubCommon, hubCommonRest);
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert)

Example 45 with NameVersionGraphAssert

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

the class MavenComplexOutputTest method test.

@Test
public void test() {
    ExternalIdFactory externalIdFactory = new ExternalIdFactory();
    MavenCodeLocationPackager packager = new MavenCodeLocationPackager(externalIdFactory);
    List<MavenParseResult> results = packager.extractCodeLocations("", getInput(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.MAVEN, results.get(0).getCodeLocation().getDependencyGraph());
    graphAssert.hasRootSize(1);
    ExternalId hubCommon = externalIdFactory.createMavenExternalId("com.blackducksoftware.integration", "hub-common", "13.1.2");
    ExternalId integrationCommon = externalIdFactory.createMavenExternalId("com.blackducksoftware.integration", "integration-common", "6.0.2");
    ExternalId hubCommonRest = externalIdFactory.createMavenExternalId("com.blackducksoftware.integration", "hub-common-rest", "2.1.3");
    graphAssert.hasRootDependency(hubCommon);
    graphAssert.hasParentChildRelationship(hubCommonRest, integrationCommon);
    graphAssert.hasParentChildRelationship(hubCommon, hubCommonRest);
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) MavenParseResult(com.synopsys.integration.detectable.detectables.maven.cli.MavenParseResult) MavenCodeLocationPackager(com.synopsys.integration.detectable.detectables.maven.cli.MavenCodeLocationPackager) 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