Search in sources :

Example 1 with PnpmLockYaml

use of com.synopsys.integration.detectable.detectables.pnpm.lockfile.model.PnpmLockYaml in project synopsys-detect by blackducksoftware.

the class PnpmYamlTransformerTest method testGenerateCodeLocation.

@Test
public void testGenerateCodeLocation() throws IntegrationException {
    PnpmLockYaml pnpmLockYaml = createPnpmLockYaml();
    PnpmYamlTransformer transformer = createTransformer();
    CodeLocation codeLocation = transformer.generateCodeLocation(pnpmLockYamlFile, pnpmLockYaml, projectNameVersion, linkedPackageResolver);
    assertTrue(codeLocation.getExternalId().isPresent(), "Expected the codelocation to produce an ExternalId.");
    assertEquals("name", codeLocation.getExternalId().get().getName());
    assertEquals("version", codeLocation.getExternalId().get().getVersion());
    DependencyGraph dependencyGraph = codeLocation.getDependencyGraph();
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.NPMJS, dependencyGraph);
    graphAssert.hasRootSize(4);
    graphAssert.hasRootDependency("dep", "1.0.0");
    graphAssert.hasRootDependency("devDep", "2.0.0");
    graphAssert.hasRootDependency("optDep", "3.0.0");
    graphAssert.hasParentChildRelationship("dep", "1.0.0", "transitive", "1.1.0");
}
Also used : CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) PnpmYamlTransformer(com.synopsys.integration.detectable.detectables.pnpm.lockfile.process.PnpmYamlTransformer) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) PnpmLockYaml(com.synopsys.integration.detectable.detectables.pnpm.lockfile.model.PnpmLockYaml) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.jupiter.api.Test)

Example 2 with PnpmLockYaml

use of com.synopsys.integration.detectable.detectables.pnpm.lockfile.model.PnpmLockYaml in project synopsys-detect by blackducksoftware.

the class PnpmYamlTransformerTest method testNoFailureOnNullNameVersion.

@Test
public void testNoFailureOnNullNameVersion() throws IntegrationException {
    PnpmLockYaml pnpmLockYaml = createPnpmLockYaml();
    PnpmYamlTransformer transformer = createTransformer();
    transformer.generateCodeLocation(pnpmLockYamlFile, pnpmLockYaml, null, linkedPackageResolver);
}
Also used : PnpmYamlTransformer(com.synopsys.integration.detectable.detectables.pnpm.lockfile.process.PnpmYamlTransformer) PnpmLockYaml(com.synopsys.integration.detectable.detectables.pnpm.lockfile.model.PnpmLockYaml) Test(org.junit.jupiter.api.Test)

Example 3 with PnpmLockYaml

use of com.synopsys.integration.detectable.detectables.pnpm.lockfile.model.PnpmLockYaml in project synopsys-detect by blackducksoftware.

the class PnpmYamlTransformerTest method testExcludeOptionalDependencies.

@Test
public void testExcludeOptionalDependencies() throws IntegrationException {
    PnpmLockYaml pnpmLockYaml = createPnpmLockYaml();
    PnpmYamlTransformer transformer = createTransformer(PnpmDependencyType.OPTIONAL);
    DependencyGraph dependencyGraph = transformer.generateCodeLocation(pnpmLockYamlFile, pnpmLockYaml, projectNameVersion, linkedPackageResolver).getDependencyGraph();
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.NPMJS, dependencyGraph);
    graphAssert.hasRootSize(3);
    graphAssert.hasNoDependency("optDep", "3.0.0");
}
Also used : PnpmYamlTransformer(com.synopsys.integration.detectable.detectables.pnpm.lockfile.process.PnpmYamlTransformer) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) PnpmLockYaml(com.synopsys.integration.detectable.detectables.pnpm.lockfile.model.PnpmLockYaml) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.jupiter.api.Test)

Example 4 with PnpmLockYaml

use of com.synopsys.integration.detectable.detectables.pnpm.lockfile.model.PnpmLockYaml in project synopsys-detect by blackducksoftware.

the class PnpmYamlTransformerTest method testParseFileDependencies.

@Test
public void testParseFileDependencies() throws IntegrationException {
    PnpmLockYaml pnpmLockYaml = createPnpmLockYaml();
    PnpmYamlTransformer transformer = createTransformer(PnpmDependencyType.DEV, PnpmDependencyType.OPTIONAL);
    DependencyGraph dependencyGraph = transformer.generateCodeLocation(pnpmLockYamlFile, pnpmLockYaml, projectNameVersion, linkedPackageResolver).getDependencyGraph();
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.NPMJS, dependencyGraph);
    graphAssert.hasRootSize(2);
    graphAssert.hasDependency("fileDep", "1.0.0");
}
Also used : PnpmYamlTransformer(com.synopsys.integration.detectable.detectables.pnpm.lockfile.process.PnpmYamlTransformer) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) PnpmLockYaml(com.synopsys.integration.detectable.detectables.pnpm.lockfile.model.PnpmLockYaml) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.jupiter.api.Test)

Example 5 with PnpmLockYaml

use of com.synopsys.integration.detectable.detectables.pnpm.lockfile.model.PnpmLockYaml in project synopsys-detect by blackducksoftware.

the class PnpmLockYamlParser method parse.

public List<CodeLocation> parse(File pnpmLockYamlFile, @Nullable NameVersion projectNameVersion, PnpmLinkedPackageResolver linkedPackageResolver) throws IOException, IntegrationException {
    PnpmLockYaml pnpmLockYaml = parseYamlFile(pnpmLockYamlFile);
    List<CodeLocation> codeLocationsFromImports = createCodeLocationsFromImports(pnpmLockYamlFile.getParentFile(), pnpmLockYaml, linkedPackageResolver, projectNameVersion);
    if (codeLocationsFromImports.isEmpty()) {
        return createCodeLocationsFromRoot(pnpmLockYamlFile.getParentFile(), pnpmLockYaml, projectNameVersion, linkedPackageResolver);
    }
    return codeLocationsFromImports;
}
Also used : CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) PnpmLockYaml(com.synopsys.integration.detectable.detectables.pnpm.lockfile.model.PnpmLockYaml)

Aggregations

PnpmLockYaml (com.synopsys.integration.detectable.detectables.pnpm.lockfile.model.PnpmLockYaml)10 PnpmYamlTransformer (com.synopsys.integration.detectable.detectables.pnpm.lockfile.process.PnpmYamlTransformer)7 Test (org.junit.jupiter.api.Test)7 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)5 NameVersionGraphAssert (com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert)5 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)2 PnpmPackageInfo (com.synopsys.integration.detectable.detectables.pnpm.lockfile.model.PnpmPackageInfo)1 FileReader (java.io.FileReader)1 HashMap (java.util.HashMap)1 Yaml (org.yaml.snakeyaml.Yaml)1 Constructor (org.yaml.snakeyaml.constructor.Constructor)1 Representer (org.yaml.snakeyaml.representer.Representer)1