Search in sources :

Example 16 with NameVersionGraphAssert

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

the class NugetProjectInspectorTest method assertExtraction.

@Override
public void assertExtraction(@NotNull Extraction extraction) {
    List<CodeLocation> codeLocations = extraction.getCodeLocations();
    Assertions.assertEquals(2, codeLocations.size());
    Assertions.assertEquals(new File("C:\\Users\\jordanp\\source\\repos\\ConsoleApp3\\ConsoleApp1\\ConsoleApp1.csproj"), codeLocations.get(0).getSourcePath().orElse(null));
    Assertions.assertEquals(new File("C:\\Users\\jordanp\\source\\repos\\ConsoleApp3\\ConsoleApp3\\ConsoleApp3.csproj"), codeLocations.get(1).getSourcePath().orElse(null));
    NameVersionGraphAssert consoleApp1 = new NameVersionGraphAssert(Forge.NUGET, codeLocations.get(0).getDependencyGraph());
    consoleApp1.hasDependency("DocumentFormat.OpenXml", "2.13.0");
    NameVersionGraphAssert consoleApp3 = new NameVersionGraphAssert(Forge.NUGET, codeLocations.get(1).getDependencyGraph());
    consoleApp3.hasDependency("Newtonsoft.Json.Bson", "1.0.2");
    consoleApp3.hasDependency("Serilog", "2.10.0");
    consoleApp3.hasParentChildRelationship("Newtonsoft.Json.Bson", "1.0.2", "Newtonsoft.Json", "12.0.1");
}
Also used : CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) File(java.io.File)

Example 17 with NameVersionGraphAssert

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

the class PackagistDetectableTest method assertExtraction.

@Override
public void assertExtraction(@NotNull Extraction extraction) {
    Assertions.assertNotEquals(0, extraction.getCodeLocations().size(), "A code location should have been generated.");
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.PACKAGIST, extraction.getCodeLocations().get(0).getDependencyGraph());
    graphAssert.hasRootSize(2);
    graphAssert.hasRootDependency("clue/graph", "v0.9.0");
    graphAssert.hasRootDependency("graphp/graphviz", "v0.2.1");
    graphAssert.hasParentChildRelationship("graphp/algorithms", "v0.8.1", "clue/graph", "v0.9.0");
    graphAssert.hasParentChildRelationship("graphp/graphviz", "v0.2.1", "graphp/algorithms", "v0.8.1");
    graphAssert.hasParentChildRelationship("graphp/graphviz", "v0.2.1", "clue/graph", "v0.9.0");
}
Also used : NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert)

Example 18 with NameVersionGraphAssert

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

the class RebarDetectableTest method assertExtraction.

@Override
public void assertExtraction(@NotNull Extraction extraction) {
    Assertions.assertNotEquals(0, extraction.getCodeLocations().size(), "A code location should have been generated.");
    Assertions.assertEquals("project", extraction.getProjectName(), "A rebar tree includes project info. Project name expected.");
    Assertions.assertEquals("1.0.0", extraction.getProjectVersion(), "A rebar tree includes project info. Project version name expected.");
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.HEX, extraction.getCodeLocations().get(0).getDependencyGraph());
    graphAssert.hasRootSize(2);
    graphAssert.hasRootDependency("git_inner_parent_dependency", "0.0.2");
    graphAssert.hasRootDependency("git_outer_parent_dependency", "0.0.7");
    graphAssert.hasParentChildRelationship("git_inner_parent_dependency", "0.0.2", "hex_inner_child_dependency", "0.3.0");
    graphAssert.hasParentChildRelationship("git_outer_parent_dependency", "0.0.7", "git_outer_child_dependency", "0.8.0");
}
Also used : NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert)

Example 19 with NameVersionGraphAssert

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

the class GemlockNodeParserTest method testParsingEqualsGemfileLock.

@Test
public void testParsingEqualsGemfileLock() throws MissingExternalIdException {
    List<String> gemfileLockContents = Arrays.asList("GEM", "  remote: https://artifactory.ilabs.io/artifactory/api/gems/gem-public/", "  specs:", "    SyslogLogger (2.0)", "    activesupport (4.1.15)", "      json (~> 1.7, >= 1.7.7)", "    json (1.8.6)", "", "PLATFORMS", "  ruby", "", "DEPENDENCIES", "  SyslogLogger (~> 2.0)", "  activesupport (~> 4.1.15)");
    GemlockParser gemlockNodeParser = new GemlockParser(new ExternalIdFactory());
    DependencyGraph dependencyGraph = gemlockNodeParser.parseProjectDependencies(gemfileLockContents);
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.RUBYGEMS, dependencyGraph);
    graphAssert.hasRootSize(2);
    graphAssert.hasRootDependency("activesupport", "4.1.15");
    graphAssert.hasRootDependency("SyslogLogger", "2.0");
    graphAssert.hasParentChildRelationship("activesupport", "4.1.15", "json", "1.8.6");
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) GemlockParser(com.synopsys.integration.detectable.detectables.rubygems.gemlock.parse.GemlockParser) Test(org.junit.jupiter.api.Test) FunctionalTest(com.synopsys.integration.detectable.annotations.FunctionalTest)

Example 20 with NameVersionGraphAssert

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

the class RubygemsNodePackagerTest method findsAllVersions.

@Test
void findsAllVersions() throws MissingExternalIdException {
    // Finds all versions of the package not just the first matching architecture.
    List<String> actualText = Arrays.asList("GEM", "  remote: https://rubygems.org/", "  specs:", "    nokogiri (1.8.2)", "      mini_portile2 (~> 2.3.0)", "    nokogiri (1.8.2-java)", "    nokogiri (1.8.2-x86-mingw32)", "    nokoparent (3.1.0)", "      nokogiri (~> 1.8)", "", "PLATFORMS", "  java", "  ruby", "  x86-mingw32", "", "DEPENDENCIES", "  nokoparent (>= 1)", "  nokogiri (>= 1.8.1)");
    GemlockParser rubygemsNodePackager = new GemlockParser(new ExternalIdFactory());
    DependencyGraph graph = rubygemsNodePackager.parseProjectDependencies(actualText);
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.RUBYGEMS, graph);
    graphAssert.hasRootSize(2);
    graphAssert.hasRootDependency("nokoparent", "3.1.0");
    graphAssert.hasRootDependency("nokogiri", "1.8.2");
    graphAssert.hasNoDependency("nokogiri", "");
    graphAssert.hasDependency("nokogiri", "1.8.2");
    graphAssert.hasDependency("nokogiri", "1.8.2-java");
    graphAssert.hasDependency("nokogiri", "1.8.2-x86-mingw32");
    graphAssert.hasParentChildRelationship("nokoparent", "3.1.0", "nokogiri", "1.8.2");
    graphAssert.hasParentChildRelationship("nokogiri", "1.8.2", "mini_portile2", "");
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) GemlockParser(com.synopsys.integration.detectable.detectables.rubygems.gemlock.parse.GemlockParser) Test(org.junit.jupiter.api.Test) FunctionalTest(com.synopsys.integration.detectable.annotations.FunctionalTest)

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