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));
}
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;
}
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");
}
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);
}
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));
}
Aggregations