Search in sources :

Example 6 with PnpmLockYaml

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

the class PnpmLockYamlParser method parseYamlFile.

private PnpmLockYaml parseYamlFile(File pnpmLockYamlFile) throws FileNotFoundException {
    Representer representer = new Representer();
    representer.getPropertyUtils().setSkipMissingProperties(true);
    Yaml yaml = new Yaml(new Constructor(PnpmLockYaml.class), representer);
    return yaml.load(new FileReader(pnpmLockYamlFile));
}
Also used : Representer(org.yaml.snakeyaml.representer.Representer) Constructor(org.yaml.snakeyaml.constructor.Constructor) PnpmLockYaml(com.synopsys.integration.detectable.detectables.pnpm.lockfile.model.PnpmLockYaml) FileReader(java.io.FileReader) Yaml(org.yaml.snakeyaml.Yaml) PnpmLockYaml(com.synopsys.integration.detectable.detectables.pnpm.lockfile.model.PnpmLockYaml)

Example 7 with PnpmLockYaml

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

the class PnpmYamlTransformerTest method createPnpmLockYaml.

private PnpmLockYaml createPnpmLockYaml() {
    PnpmLockYaml pnpmLockYaml = new PnpmLockYaml();
    Map<String, String> dependencies = new HashMap<>();
    dependencies.put("dep", "1.0.0");
    dependencies.put("fileDep", "file:fileDep-1.0.0.tgz");
    pnpmLockYaml.dependencies = dependencies;
    Map<String, String> devDependencies = new HashMap<>();
    devDependencies.put("devDep", "2.0.0");
    pnpmLockYaml.devDependencies = devDependencies;
    Map<String, String> optionalDependencies = new HashMap<>();
    optionalDependencies.put("optDep", "3.0.0");
    pnpmLockYaml.optionalDependencies = optionalDependencies;
    Map<String, PnpmPackageInfo> packages = new HashMap<>();
    PnpmPackageInfo dep = new PnpmPackageInfo();
    Map<String, String> depDependencies = new HashMap<>();
    depDependencies.put("transitive", "1.1.0");
    dep.dependencies = depDependencies;
    packages.put("/dep/1.0.0", dep);
    PnpmPackageInfo devDep = new PnpmPackageInfo();
    devDep.dev = true;
    packages.put("/devDep/2.0.0", devDep);
    PnpmPackageInfo optDep = new PnpmPackageInfo();
    optDep.optional = true;
    packages.put("/optDep/3.0.0", optDep);
    PnpmPackageInfo transitive = new PnpmPackageInfo();
    packages.put("/transitive/1.1.0", transitive);
    PnpmPackageInfo fileDep = new PnpmPackageInfo();
    fileDep.name = "fileDep";
    fileDep.version = "1.0.0";
    packages.put("file:fileDep-1.0.0.tgz", fileDep);
    pnpmLockYaml.packages = packages;
    return pnpmLockYaml;
}
Also used : HashMap(java.util.HashMap) PnpmLockYaml(com.synopsys.integration.detectable.detectables.pnpm.lockfile.model.PnpmLockYaml) PnpmPackageInfo(com.synopsys.integration.detectable.detectables.pnpm.lockfile.model.PnpmPackageInfo)

Example 8 with PnpmLockYaml

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

the class PnpmYamlTransformerTest method testExcludeDevDependencies.

@Test
public void testExcludeDevDependencies() throws IntegrationException {
    PnpmYamlTransformer transformer = createTransformer(PnpmDependencyType.DEV);
    PnpmLockYaml pnpmLockYaml = createPnpmLockYaml();
    DependencyGraph dependencyGraph = transformer.generateCodeLocation(pnpmLockYamlFile, pnpmLockYaml, projectNameVersion, linkedPackageResolver).getDependencyGraph();
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.NPMJS, dependencyGraph);
    graphAssert.hasRootSize(3);
    graphAssert.hasNoDependency("devDep", "2.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 9 with PnpmLockYaml

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

the class PnpmYamlTransformerTest method testExcludeDependencies.

@Test
public void testExcludeDependencies() throws IntegrationException {
    PnpmLockYaml pnpmLockYaml = createPnpmLockYaml();
    PnpmYamlTransformer transformer = createTransformer(PnpmDependencyType.APP);
    DependencyGraph dependencyGraph = transformer.generateCodeLocation(pnpmLockYamlFile, pnpmLockYaml, projectNameVersion, linkedPackageResolver).getDependencyGraph();
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.NPMJS, dependencyGraph);
    graphAssert.hasRootSize(2);
}
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 10 with PnpmLockYaml

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

the class PnpmYamlTransformerTest method testThrowExceptionOnNullPackagesSection.

@Test
public void testThrowExceptionOnNullPackagesSection() {
    PnpmLockYaml pnpmLockYaml = createPnpmLockYaml();
    PnpmYamlTransformer transformer = createTransformer();
    pnpmLockYaml.packages = null;
    assertThrows(IntegrationException.class, () -> transformer.generateCodeLocation(pnpmLockYamlFile, pnpmLockYaml, projectNameVersion, 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)

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