use of com.synopsys.integration.detectable.detectables.npm.cli.parse.NpmDependencyTypeFilter 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.detectables.npm.cli.parse.NpmDependencyTypeFilter in project synopsys-detect by blackducksoftware.
the class NpmDependencyTypeFilterTest method includeDevTest.
@Test
void includeDevTest() {
NpmDependencyTypeFilter filter = createFilter(true, false);
assertTrue(filter.shouldInclude(NEITHER, true));
assertTrue(filter.shouldInclude(NEITHER, false));
assertTrue(filter.shouldInclude(DEV, true));
assertTrue(filter.shouldInclude(DEV, false));
assertFalse(filter.shouldInclude(PEER, true));
assertTrue(filter.shouldInclude(PEER, false));
}
use of com.synopsys.integration.detectable.detectables.npm.cli.parse.NpmDependencyTypeFilter in project synopsys-detect by blackducksoftware.
the class NpmDependencyTypeFilterTest method includeNeitherTest.
@Test
void includeNeitherTest() {
NpmDependencyTypeFilter filter = createFilter(false, false);
assertTrue(filter.shouldInclude(NEITHER, true));
assertTrue(filter.shouldInclude(NEITHER, false));
assertTrue(filter.shouldInclude(DEV, false));
assertFalse(filter.shouldInclude(DEV, true));
assertTrue(filter.shouldInclude(PEER, false));
assertFalse(filter.shouldInclude(PEER, true));
}
use of com.synopsys.integration.detectable.detectables.npm.cli.parse.NpmDependencyTypeFilter in project synopsys-detect by blackducksoftware.
the class NpmDependencyTypeFilterTest method includeBothTest.
@Test
void includeBothTest() {
NpmDependencyTypeFilter filter = createFilter(true, true);
assertTrue(filter.shouldInclude(NEITHER, true));
assertTrue(filter.shouldInclude(NEITHER, false));
assertTrue(filter.shouldInclude(DEV, true));
assertTrue(filter.shouldInclude(DEV, false));
assertTrue(filter.shouldInclude(PEER, true));
assertTrue(filter.shouldInclude(PEER, false));
}
use of com.synopsys.integration.detectable.detectables.npm.cli.parse.NpmDependencyTypeFilter in project synopsys-detect by blackducksoftware.
the class NpmDependencyTypeFilterTest method includePeerTest.
@Test
void includePeerTest() {
NpmDependencyTypeFilter filter = createFilter(false, true);
assertTrue(filter.shouldInclude(NEITHER, true));
assertTrue(filter.shouldInclude(NEITHER, false));
assertFalse(filter.shouldInclude(DEV, true));
assertTrue(filter.shouldInclude(DEV, false));
assertTrue(filter.shouldInclude(PEER, true));
assertTrue(filter.shouldInclude(PEER, false));
}
Aggregations