use of com.synopsys.integration.detectable.detectables.pipenv.parse.data.PipfileLock in project synopsys-detect by blackducksoftware.
the class PipfileLockParserTest method testParse.
@Test
public void testParse() {
PipfileLock pipfileLock = pipfileLock();
PipfileLockDependencyVersionParser dependencyVersionParser = new PipfileLockDependencyVersionParser();
PipfileLockTransformer parser = new PipfileLockTransformer(dependencyVersionParser, EnumListFilter.excludeNone());
List<PipfileLockDependency> dependencies = parser.transform(pipfileLock);
Assertions.assertEquals(3, dependencies.size());
Assertions.assertTrue(containsDependency(dependencies, "comp1", "1.0"));
Assertions.assertTrue(containsDependency(dependencies, "comp2", null));
Assertions.assertTrue(containsDependency(dependencies, "comp3", "3.0"));
}
use of com.synopsys.integration.detectable.detectables.pipenv.parse.data.PipfileLock in project synopsys-detect by blackducksoftware.
the class PipfileLockParserTest method testExcludeDevelopDependencies.
@Test
public void testExcludeDevelopDependencies() {
PipfileLock pipfileLock = pipfileLock();
PipfileLockDependencyVersionParser dependencyVersionParser = new PipfileLockDependencyVersionParser();
PipfileLockTransformer parser = new PipfileLockTransformer(dependencyVersionParser, EnumListFilter.fromExcluded(PipenvDependencyType.DEV));
List<PipfileLockDependency> dependencies = parser.transform(pipfileLock);
Assertions.assertEquals(2, dependencies.size());
Assertions.assertTrue(containsDependency(dependencies, "comp1", "1.0"));
Assertions.assertTrue(containsDependency(dependencies, "comp2", null));
Assertions.assertFalse(containsDependency(dependencies, "comp3", "3.0"));
}
use of com.synopsys.integration.detectable.detectables.pipenv.parse.data.PipfileLock in project synopsys-detect by blackducksoftware.
the class PipfileLockParserTest method pipfileLock.
private PipfileLock pipfileLock() {
PipfileLock pipfileLock = new PipfileLock();
Map<String, PipfileLockDependencyEntry> dependencies = new HashMap<>();
dependencies.put("comp1", createEntry("==1.0"));
dependencies.put("comp2", createEntry(null));
pipfileLock.dependencies = dependencies;
Map<String, PipfileLockDependencyEntry> devDependencies = new HashMap<>();
devDependencies.put("comp3", createEntry("==3.0"));
pipfileLock.devDependencies = devDependencies;
return pipfileLock;
}
use of com.synopsys.integration.detectable.detectables.pipenv.parse.data.PipfileLock in project synopsys-detect by blackducksoftware.
the class PipfileLockExtractor method extract.
public Extraction extract(File pipfileLockFile) throws IOException {
String pipfileLockText = FileUtils.readFileToString(pipfileLockFile, StandardCharsets.UTF_8);
PipfileLock pipfileLock = gson.fromJson(pipfileLockText, PipfileLock.class);
List<PipfileLockDependency> dependencies = pipfileLockTransformer.transform(pipfileLock);
DependencyGraph dependencyGraph = pipfileLockDependencyTransformer.transform(dependencies);
CodeLocation codeLocation = new CodeLocation(dependencyGraph);
// No project info - hoping git can help with that.
return Extraction.success(codeLocation);
}
Aggregations