use of com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert in project synopsys-detect by blackducksoftware.
the class NpmOutputParserTest method npmCliDependencyFinder.
@Test
public void npmCliDependencyFinder() {
NpmCliParser parser = new NpmCliParser(new ExternalIdFactory(), EnumListFilter.excludeNone());
String testIn = String.join(System.lineSeparator(), Arrays.asList("{", " \"name\": \"node-js\",", " \"version\": \"0.2.0\",", " \"dependencies\": {", " \"upper-case\": {", " \"version\": \"1.1.3\",", " \"from\": \"upper-case@latest\",", " \"resolved\": \"https://registry.npmjs.org/upper-case/-/upper-case-1.1.3.tgz\"", " },", " \"xml2js\": {", " \"version\": \"0.4.17\",", " \"from\": \"xml2js@latest\",", " \"resolved\": \"https://registry.npmjs.org/xml2js/-/xml2js-0.4.17.tgz\",", " \"dependencies\": {", " \"sax\": {", " \"version\": \"1.2.2\",", " \"from\": \"sax@>=0.6.0\",", " \"resolved\": \"https://registry.npmjs.org/sax/-/sax-1.2.2.tgz\"", " },", " \"xmlbuilder\": {", " \"version\": \"4.2.1\",", " \"from\": \"xmlbuilder@>=4.1.0 <5.0.0\",", " \"resolved\": \"https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-4.2.1.tgz\",", " \"dependencies\": {", " \"lodash\": {", " \"version\": \"4.17.4\",", " \"from\": \"lodash@>=4.0.0 <5.0.0\",", " \"resolved\": \"https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz\"", " }", " }", " }", " }", " }", " }", "}"));
NpmDependencyTypeFilter npmDependencyTypeFilter = new NpmDependencyTypeFilter(Collections.emptySet(), Collections.emptySet(), true, true);
PackageJson packageJson = new PackageJson();
NpmPackagerResult result = parser.convertNpmJsonFileToCodeLocation(testIn, packageJson);
Assertions.assertEquals("node-js", result.getProjectName());
Assertions.assertEquals("0.2.0", result.getProjectVersion());
NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.NPMJS, result.getCodeLocation().getDependencyGraph());
graphAssert.hasRootSize(2);
graphAssert.hasRootDependency("xml2js", "0.4.17");
graphAssert.hasRootDependency("upper-case", "1.1.3");
graphAssert.hasParentChildRelationship("xml2js", "0.4.17", "xmlbuilder", "4.2.1");
graphAssert.hasParentChildRelationship("xml2js", "0.4.17", "sax", "1.2.2");
graphAssert.hasParentChildRelationship("xmlbuilder", "4.2.1", "lodash", "4.17.4");
}
use of com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert in project synopsys-detect by blackducksoftware.
the class GoVndrDetectableTest method assertExtraction.
@Override
public void assertExtraction(@NotNull Extraction extraction) {
Assertions.assertEquals(1, extraction.getCodeLocations().size());
NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.GOLANG, extraction.getCodeLocations().get(0).getDependencyGraph());
graphAssert.hasRootSize(5);
graphAssert.hasRootDependency("github.com/klauspost/compress", "v1.4.1");
graphAssert.hasRootDependency("github.com/klauspost/cpuid", "v1.2.0");
graphAssert.hasRootDependency("github.com/klauspost/pgzip", "v1.2.1");
graphAssert.hasRootDependency("github.com/Azure/go-ansiterm", "d6e3b3328b783f23731bc4d058875b0371ff8109");
graphAssert.hasRootDependency("github.com/Microsoft/go-winio", "5b44b70ab3ab4d291a7c1d28afe7b4afeced0ed4");
graphAssert.hasNoDependency("github.com/Azure/go-ansiterm", "dont_include_me");
}
use of com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert in project synopsys-detect by blackducksoftware.
the class VndrParserTest method invalidLine.
@Test
void invalidLine() {
DependencyGraph dependencyGraph = vndrParser.parseVendorConf(Arrays.asList("github.com/klauspost/compress v1.4.1", "invlaid_line"));
NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.GOLANG, dependencyGraph);
graphAssert.hasRootSize(1);
graphAssert.hasRootDependency("github.com/klauspost/compress", "v1.4.1");
}
use of com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert in project synopsys-detect by blackducksoftware.
the class VndrParserTest method happyPathTest.
@Test
void happyPathTest() {
DependencyGraph dependencyGraph = vndrParser.parseVendorConf(Arrays.asList("github.com/klauspost/compress v1.4.1", "github.com/klauspost/cpuid v1.2.0"));
NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.GOLANG, dependencyGraph);
graphAssert.hasRootSize(2);
graphAssert.hasRootDependency("github.com/klauspost/compress", "v1.4.1");
graphAssert.hasRootDependency("github.com/klauspost/cpuid", "v1.2.0");
}
use of com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert in project synopsys-detect by blackducksoftware.
the class VndrParserTest method whitespaceSeparationTest.
@Test
void whitespaceSeparationTest() {
DependencyGraph dependencyGraph = vndrParser.parseVendorConf(Arrays.asList("github.com/Microsoft/go-winio v1", "github.com/Microsoft/go-winio v2", "github.com/Microsoft/go-winio\tv3"));
NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.GOLANG, dependencyGraph);
graphAssert.hasRootSize(3);
graphAssert.hasRootDependency("github.com/Microsoft/go-winio", "v1");
graphAssert.hasRootDependency("github.com/Microsoft/go-winio", "v2");
graphAssert.hasRootDependency("github.com/Microsoft/go-winio", "v3");
}
Aggregations