use of com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert in project synopsys-detect by blackducksoftware.
the class PipenvTransformerTest method resolvesFuzzyVersion.
@Test
void resolvesFuzzyVersion() {
List<PipFreezeEntry> pipFreezeEntries = new ArrayList<>();
pipFreezeEntries.add(new PipFreezeEntry("example", "2.0.0"));
PipFreeze pipFreeze = new PipFreeze(pipFreezeEntries);
List<PipenvGraphEntry> pipenvGraphEntries = new ArrayList<>();
pipenvGraphEntries.add(new PipenvGraphEntry("example", "fuzzy", new ArrayList<>()));
PipenvGraph pipenvGraph = new PipenvGraph(pipenvGraphEntries);
PipenvTransformer pipenvTransformer = new PipenvTransformer(new ExternalIdFactory());
CodeLocation codeLocation = pipenvTransformer.transform("", "", pipFreeze, pipenvGraph, false);
DependencyGraph graph = codeLocation.getDependencyGraph();
NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.PYPI, graph);
graphAssert.hasDependency("example", "2.0.0");
}
use of com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert in project synopsys-detect by blackducksoftware.
the class PipfileLockDependencyTransformerTest method testTransform.
@Test
public void testTransform() {
List<PipfileLockDependency> dependencies = Arrays.asList(new PipfileLockDependency("comp1", "1.0"), new PipfileLockDependency("comp2", "2.0"));
PipfileLockDependencyTransformer transformer = new PipfileLockDependencyTransformer();
DependencyGraph dependencyGraph = transformer.transform(dependencies);
NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.PYPI, dependencyGraph);
graphAssert.hasRootSize(2);
graphAssert.hasRootDependency("comp1", "1.0");
graphAssert.hasRootDependency("comp2", "2.0");
}
use of com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert in project synopsys-detect by blackducksoftware.
the class PoetryLockParserTest method testParseComplexDependencyHierarchy.
@Test
public void testParseComplexDependencyHierarchy() throws IOException {
String input = String.join(System.lineSeparator(), Arrays.asList("[[package]]", "name = \"test1\"", "version = \"1.0.0\"", "", "[package.dependencies]", "test2 = \">=1.0\"", "", "[[package]]", "name = \"test2\"", "version = \"2.0\"", "", "[package.dependencies]", "test4 = \"<4.4\"", "", "[[package]]", "name = \"test3\"", "version = \"3.0\"", "", "[[package]]", "name = \"test4\"", "version = \"4.0\"", "", "[package.dependencies]", "test1 = \"~1.0.0\""));
PoetryLockParser poetryLockParser = new PoetryLockParser();
DependencyGraph graph = poetryLockParser.parseLockFile(input);
NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.PYPI, graph);
graphAssert.hasRootSize(1);
graphAssert.hasRootDependency("test3", "3.0");
graphAssert.hasParentChildRelationship("test1", "1.0.0", "test2", "2.0");
graphAssert.hasParentChildRelationship("test2", "2.0", "test4", "4.0");
graphAssert.hasParentChildRelationship("test4", "4.0", "test1", "1.0.0");
}
use of com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert in project synopsys-detect by blackducksoftware.
the class PoetryLockParserTest method testParseNameAndVersionSimple.
@Test
public void testParseNameAndVersionSimple() {
String input = String.join(System.lineSeparator(), Arrays.asList("[[package]]", "name = \"pytest-cov\"", "version = \"2.8.1\"", "", "[[package]]", "name = \"pytest-mock\"", "version = \"2.0.0\""));
PoetryLockParser poetryLockParser = new PoetryLockParser();
DependencyGraph graph = poetryLockParser.parseLockFile(input);
NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.PYPI, graph);
graphAssert.hasRootSize(2);
graphAssert.hasRootDependency("pytest-cov", "2.8.1");
graphAssert.hasRootDependency("pytest-mock", "2.0.0");
}
use of com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert in project synopsys-detect by blackducksoftware.
the class PoetryLockParserTest method testEmptyGraphWhenNoPackageObjects.
@Test
public void testEmptyGraphWhenNoPackageObjects() throws IOException {
String input = String.join(System.lineSeparator(), Arrays.asList("package", "name = \"pytest\"", "version = \"1.0.0\"", "", "package", "name = \"python\"", "version = \"3.0\""));
PoetryLockParser poetryLockParser = new PoetryLockParser();
DependencyGraph graph = poetryLockParser.parseLockFile(input);
NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.PYPI, graph);
graphAssert.hasRootSize(0);
}
Aggregations