Search in sources :

Example 21 with GraphAssert

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

the class NpmDevExclusionTest method testDevDependencyNotExists.

@Test
public void testDevDependencyNotExists() {
    NpmPackagerResult result = createPackager(NpmDependencyType.DEV, NpmDependencyType.PEER).parseAndTransform(packageJsonText, packageLockText);
    GraphAssert graphAssert = new GraphAssert(Forge.NPMJS, result.getCodeLocation().getDependencyGraph());
    graphAssert.hasNoDependency(childDev);
    graphAssert.hasNoDependency(parentDev);
    graphAssert.hasRootSize(0);
}
Also used : GraphAssert(com.synopsys.integration.detectable.util.graph.GraphAssert) NpmPackagerResult(com.synopsys.integration.detectable.detectables.npm.lockfile.result.NpmPackagerResult) Test(org.junit.jupiter.api.Test) FunctionalTest(com.synopsys.integration.detectable.annotations.FunctionalTest)

Example 22 with GraphAssert

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

the class NpmDevExclusionTest method testDevDependencyExists.

@Test
public void testDevDependencyExists() {
    NpmPackagerResult result = createPackager(NpmDependencyType.PEER).parseAndTransform(packageJsonText, packageLockText);
    GraphAssert graphAssert = new GraphAssert(Forge.NPMJS, result.getCodeLocation().getDependencyGraph());
    graphAssert.hasDependency(childDev);
    graphAssert.hasDependency(parentDev);
    graphAssert.hasRootSize(1);
}
Also used : GraphAssert(com.synopsys.integration.detectable.util.graph.GraphAssert) NpmPackagerResult(com.synopsys.integration.detectable.detectables.npm.lockfile.result.NpmPackagerResult) Test(org.junit.jupiter.api.Test) FunctionalTest(com.synopsys.integration.detectable.annotations.FunctionalTest)

Example 23 with GraphAssert

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

the class NpmWithoutRequiresExcludesTest method testDevDependencyExcluded.

@Test
public void testDevDependencyExcluded() {
    PackageLock packageLock = new PackageLock();
    packageLock.dependencies = new HashMap<>();
    List<NpmDependency> resolvedDependencies = new ArrayList<>();
    resolvedDependencies.add(new NpmDependency("example", "1.0.0", true, true));
    NpmProject npmProject = new NpmProject(Strings.EMPTY, Strings.EMPTY, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), resolvedDependencies);
    NpmLockfileGraphTransformer graphTransformer = new NpmLockfileGraphTransformer(EnumListFilter.fromExcluded(NpmDependencyType.DEV, NpmDependencyType.PEER));
    DependencyGraph graph = graphTransformer.transform(packageLock, npmProject, Collections.emptyList());
    GraphAssert graphAssert = new GraphAssert(Forge.NPMJS, graph);
    graphAssert.hasRootSize(0);
}
Also used : PackageLock(com.synopsys.integration.detectable.detectables.npm.lockfile.model.PackageLock) NpmLockfileGraphTransformer(com.synopsys.integration.detectable.detectables.npm.lockfile.parse.NpmLockfileGraphTransformer) NpmDependency(com.synopsys.integration.detectable.detectables.npm.lockfile.model.NpmDependency) NpmProject(com.synopsys.integration.detectable.detectables.npm.lockfile.model.NpmProject) GraphAssert(com.synopsys.integration.detectable.util.graph.GraphAssert) ArrayList(java.util.ArrayList) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.jupiter.api.Test)

Example 24 with GraphAssert

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

the class PackageJsonExtractorFunctionalTest method extractWithPeerDependencies.

@Test
void extractWithPeerDependencies() {
    Extraction extraction = createExtractor(NpmDependencyType.DEV).extract(packageJsonInputStream);
    assertEquals(1, extraction.getCodeLocations().size());
    CodeLocation codeLocation = extraction.getCodeLocations().get(0);
    DependencyGraph dependencyGraph = codeLocation.getDependencyGraph();
    GraphAssert graphAssert = new GraphAssert(Forge.RUBYGEMS, dependencyGraph);
    graphAssert.hasRootDependency(testDep1);
    graphAssert.hasRootDependency(testDep2);
    graphAssert.hasRootDependency(testPeerDep1);
    graphAssert.hasRootDependency(testPeerDep2);
    graphAssert.hasNoDependency(testDevDep1);
    graphAssert.hasNoDependency(testDevDep2);
    graphAssert.hasRootSize(4);
}
Also used : CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) GraphAssert(com.synopsys.integration.detectable.util.graph.GraphAssert) Extraction(com.synopsys.integration.detectable.extraction.Extraction) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.jupiter.api.Test) FunctionalTest(com.synopsys.integration.detectable.annotations.FunctionalTest)

Example 25 with GraphAssert

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

the class PearDependencyGraphTransformerTest method buildDependencyGraphRequiredOnly.

@Test
void buildDependencyGraphRequiredOnly() {
    DependencyGraph dependencyGraph = buildDependencyGraph(PearDependencyType.OPTIONAL);
    Set<Dependency> rootDependencies = dependencyGraph.getRootDependencies();
    Assertions.assertEquals(1, rootDependencies.size());
    ExternalIdFactory externalIdFactory = new ExternalIdFactory();
    GraphAssert graphAssert = new GraphAssert(Forge.PEAR, dependencyGraph);
    graphAssert.hasDependency(externalIdFactory.createNameVersionExternalId(Forge.PEAR, "Archive_Tar", "1.4.3"));
}
Also used : GraphAssert(com.synopsys.integration.detectable.util.graph.GraphAssert) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) PackageDependency(com.synopsys.integration.detectable.detectables.pear.model.PackageDependency) Test(org.junit.jupiter.api.Test) UnitTest(com.synopsys.integration.detectable.annotations.UnitTest)

Aggregations

GraphAssert (com.synopsys.integration.detectable.util.graph.GraphAssert)30 Test (org.junit.jupiter.api.Test)30 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)26 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)9 FunctionalTest (com.synopsys.integration.detectable.annotations.FunctionalTest)7 UnitTest (com.synopsys.integration.detectable.annotations.UnitTest)7 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)7 PackageResolved (com.synopsys.integration.detectable.detectables.swift.lock.data.PackageResolved)5 PackageState (com.synopsys.integration.detectable.detectables.swift.lock.data.PackageState)5 ResolvedPackage (com.synopsys.integration.detectable.detectables.swift.lock.data.ResolvedPackage)5 PackageResolved (com.synopsys.integration.detectable.detectables.xcode.model.PackageResolved)5 PackageState (com.synopsys.integration.detectable.detectables.xcode.model.PackageState)5 ResolvedPackage (com.synopsys.integration.detectable.detectables.xcode.model.ResolvedPackage)5 PackageResolvedTransformer (com.synopsys.integration.detectable.detectables.xcode.process.PackageResolvedTransformer)5 Extraction (com.synopsys.integration.detectable.extraction.Extraction)5 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)4 NpmPackagerResult (com.synopsys.integration.detectable.detectables.npm.lockfile.result.NpmPackagerResult)4 InputStream (java.io.InputStream)4 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)3 GsonBuilder (com.google.gson.GsonBuilder)2