Search in sources :

Example 26 with NameVersionGraphAssert

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

the class PipfileLockDetectableTest 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.PYPI, extraction.getCodeLocations().get(0).getDependencyGraph());
    graphAssert.hasRootSize(3);
    graphAssert.hasRootDependency("asgiref", "3.5.0");
    graphAssert.hasRootDependency("crispy-bootstrap5", "0.6");
    graphAssert.hasRootDependency("flake8", "4.0.1");
}
Also used : NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert)

Example 27 with NameVersionGraphAssert

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

the class PipInspectorTreeParserTest method validTest.

@Test
public void validTest() {
    List<String> pipInspectorOutput = Arrays.asList("projectName==projectVersionName", "   with-dashes==1.0.0", "   Uppercase==2.0.0", "      child==3.0.0", "   test==4.0.0");
    Optional<NameVersionCodeLocation> validParse = parser.parse(pipInspectorOutput, "");
    Assertions.assertTrue(validParse.isPresent());
    Assertions.assertEquals("projectName", validParse.get().getProjectName());
    Assertions.assertEquals("projectVersionName", validParse.get().getProjectVersion());
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.PYPI, validParse.get().getCodeLocation().getDependencyGraph());
    graphAssert.hasRootDependency("with-dashes", "1.0.0");
    graphAssert.hasRootDependency("Uppercase", "2.0.0");
    graphAssert.hasRootDependency("test", "4.0.0");
    graphAssert.hasParentChildRelationship("Uppercase", "2.0.0", "child", "3.0.0");
    graphAssert.hasRootSize(3);
}
Also used : NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) NameVersionCodeLocation(com.synopsys.integration.detectable.detectables.pip.inspector.model.NameVersionCodeLocation) Test(org.junit.jupiter.api.Test) UnitTest(com.synopsys.integration.detectable.annotations.UnitTest)

Example 28 with NameVersionGraphAssert

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

the class CargoLockPackageTransformerTest method testParsesNamesAndVersionsSimple.

@Test
public void testParsesNamesAndVersionsSimple() throws DetectableException, MissingExternalIdException, CycleDetectedException {
    List<CargoLockPackage> input = new ArrayList<>();
    input.add(createPackage("test1", "1.0.0"));
    input.add(createPackage("test2", "2.0.0"));
    CargoLockPackageTransformer cargoLockPackageTransformer = new CargoLockPackageTransformer();
    DependencyGraph graph = cargoLockPackageTransformer.transformToGraph(input);
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.CRATES, graph);
    graphAssert.hasRootSize(2);
    graphAssert.hasRootDependency("test1", "1.0.0");
    graphAssert.hasRootDependency("test2", "2.0.0");
}
Also used : ArrayList(java.util.ArrayList) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) CargoLockPackage(com.synopsys.integration.detectable.detectables.cargo.model.CargoLockPackage) Test(org.junit.jupiter.api.Test)

Example 29 with NameVersionGraphAssert

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

the class CargoLockPackageTransformerTest method testCorrectNumberOfRootDependencies.

@Test
public void testCorrectNumberOfRootDependencies() throws DetectableException, MissingExternalIdException {
    List<CargoLockPackage> input = new ArrayList<>();
    input.add(createPackage("test1", "1.0.0", new NameOptionalVersion("dep1"), new NameOptionalVersion("dep2")));
    input.add(createPackage("dep1", "0.5.0"));
    input.add(createPackage("dep2", "0.6.0"));
    CargoLockPackageTransformer cargoLockPackageTransformer = new CargoLockPackageTransformer();
    DependencyGraph graph = cargoLockPackageTransformer.transformToGraph(input);
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.CRATES, graph);
    graphAssert.hasRootDependency("test1", "1.0.0");
    graphAssert.hasRootDependency("dep1", "0.5.0");
    graphAssert.hasRootDependency("dep2", "0.6.0");
    graphAssert.hasRootSize(3);
}
Also used : NameOptionalVersion(com.synopsys.integration.detectable.util.NameOptionalVersion) ArrayList(java.util.ArrayList) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) CargoLockPackage(com.synopsys.integration.detectable.detectables.cargo.model.CargoLockPackage) Test(org.junit.jupiter.api.Test)

Example 30 with NameVersionGraphAssert

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

the class CarthageDeclarationTransformerTest method happyCase.

@Test
void happyCase() {
    CarthageDeclarationTransformer transformer = new CarthageDeclarationTransformer();
    List<CarthageDeclaration> carthageDeclarations = Arrays.asList(new CarthageDeclaration("github", "some-name/resource", "some-version"), new CarthageDeclaration("github", "different-name/resource", "other-version"));
    DependencyGraph graph = transformer.transform(carthageDeclarations);
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.GITHUB, graph);
    graphAssert.hasRootDependency("some-name/resource", "some-version");
    graphAssert.hasRootDependency("different-name/resource", "other-version");
    graphAssert.hasRootSize(2);
}
Also used : CarthageDeclaration(com.synopsys.integration.detectable.detectables.carthage.model.CarthageDeclaration) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) CarthageDeclarationTransformer(com.synopsys.integration.detectable.detectables.carthage.transform.CarthageDeclarationTransformer) 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