use of com.synopsys.integration.detectable.detectables.yarn.parse.YarnLockParser in project synopsys-detect by blackducksoftware.
the class YarnLockParserFunctionalTest method testV1Lockfile.
@Test
void testV1Lockfile() throws IOException {
File lockfile = FunctionalTestFiles.asFile("/yarn/lockfilev1/yarn.lock");
List<String> yarnLockLines = FileUtils.readLines(lockfile, StandardCharsets.UTF_8);
Assertions.assertTrue(lockfile.exists());
YarnLockLineAnalyzer yarnLockLineAnalyzer = new YarnLockLineAnalyzer();
YarnLockDependencySpecParser yarnLockDependencySpecParser = new YarnLockDependencySpecParser(yarnLockLineAnalyzer);
YarnLockEntrySectionParserSet yarnLockEntryElementParser = new YarnLockEntrySectionParserSet(yarnLockLineAnalyzer, yarnLockDependencySpecParser);
YarnLockEntryParser yarnLockEntryParser = new YarnLockEntryParser(yarnLockLineAnalyzer, yarnLockEntryElementParser);
YarnLockParser yarnLockParser = new YarnLockParser(yarnLockEntryParser);
YarnLock yarnLock = yarnLockParser.parseYarnLock(yarnLockLines);
Assertions.assertEquals(4238, yarnLock.getEntries().size());
Assertions.assertEquals("zwitch", yarnLock.getEntries().get(4237).getIds().get(0).getName());
Assertions.assertEquals("^1.0.0", yarnLock.getEntries().get(4237).getIds().get(0).getVersion());
}
use of com.synopsys.integration.detectable.detectables.yarn.parse.YarnLockParser in project synopsys-detect by blackducksoftware.
the class YarnLockParserTest method testSkipIrrelevantStuff.
@Test
void testSkipIrrelevantStuff() {
List<String> yarnLockText = Arrays.asList("#", "", "any-root-dep@1:", " ignoredelement1", // must have a version to create an entry
" version: 1.0.0", " ignoredelement2", " dependencies:", " some-peer: ^10.0.0", " ignoredelement3", "#", "");
YarnLockParser yarnLockParser = createYarnLockParser();
YarnLock yarnLock = yarnLockParser.parseYarnLock(yarnLockText);
Assertions.assertEquals(1, yarnLock.getEntries().size());
YarnLockEntry first = yarnLock.getEntries().get(0);
Assertions.assertEquals("1.0.0", first.getVersion());
Assertions.assertEquals(1, first.getDependencies().size());
YarnLockDependency dep = first.getDependencies().get(0);
Assertions.assertEquals("some-peer", dep.getName());
Assertions.assertEquals("^10.0.0", dep.getVersion());
Assertions.assertFalse(dep.isOptional());
}
use of com.synopsys.integration.detectable.detectables.yarn.parse.YarnLockParser in project synopsys-detect by blackducksoftware.
the class YarnLockParserTest method testThatYarnLockIsParsedCorrectlyToMap.
@Test
void testThatYarnLockIsParsedCorrectlyToMap() {
List<String> yarnLockText = new ArrayList<>();
yarnLockText.add("# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.");
yarnLockText.add("# yarn lockfile v1");
yarnLockText.add("");
yarnLockText.add("");
yarnLockText.add("async@0.9.0:");
yarnLockText.add(" version \"0.9.0\"");
yarnLockText.add(" resolved \"http://nexus.fr.murex.com/nexus3/repository/npm-all/async/-/async-0.9.0.tgz#ac3613b1da9bed1b47510bb4651b8931e47146c7\"");
yarnLockText.add("colors@~1.0.3:");
yarnLockText.add(" version \"1.0.3\"");
yarnLockText.add(" resolved \"http://nexus.fr.murex.com/nexus3/repository/npm-all/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b\"");
YarnLockParser yarnLockParser = createYarnLockParser();
YarnLock yarnLock = yarnLockParser.parseYarnLock(yarnLockText);
assertEntry(yarnLock, "async", "0.9.0", "0.9.0");
assertEntry(yarnLock, "colors", "~1.0.3", "1.0.3");
}
use of com.synopsys.integration.detectable.detectables.yarn.parse.YarnLockParser in project synopsys-detect by blackducksoftware.
the class YarnLockParserTest method createYarnLockParser.
@NotNull
private YarnLockParser createYarnLockParser() {
YarnLockLineAnalyzer lineAnalyzer = new YarnLockLineAnalyzer();
YarnLockDependencySpecParser yarnLockDependencySpecParser = new YarnLockDependencySpecParser(lineAnalyzer);
YarnLockEntrySectionParserSet yarnLockEntryElementParser = new YarnLockEntrySectionParserSet(lineAnalyzer, yarnLockDependencySpecParser);
YarnLockEntryParser entryParser = new YarnLockEntryParser(lineAnalyzer, yarnLockEntryElementParser);
YarnLockParser yarnLockParser = new YarnLockParser(entryParser);
return yarnLockParser;
}
use of com.synopsys.integration.detectable.detectables.yarn.parse.YarnLockParser in project synopsys-detect by blackducksoftware.
the class YarnLockParserTest method testParsingNamesWithAtSymbolSlash.
@Test
void testParsingNamesWithAtSymbolSlash() {
List<String> yarnLockText = new ArrayList<>();
yarnLockText.add("# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.");
yarnLockText.add("# yarn lockfile v1");
yarnLockText.add("");
yarnLockText.add("");
yarnLockText.add("\"@apollo/client@^3.1.3\", \"@apollo/client@^3.1.4\", \"@apollo/client@^3.3.6\":\n");
yarnLockText.add(" version \"3.3.6\"\n");
yarnLockText.add(" resolved \"https://registry.yarnpkg.com/@apollo/client/-/client-3.3.6.tgz#f359646308167f38d5bc498dfc2344c888400093\"\n");
yarnLockText.add(" integrity sha512-XSm/STyNS8aHdDigLLACKNMHwI0qaQmEHWHtTP+jHe/E1wZRnn66VZMMgwKLy2V4uHISHfmiZ4KpUKDPeJAKqg==\n");
yarnLockText.add(" dependencies:\n");
yarnLockText.add(" \"@graphql-typed-document-node/core\" \"^3.0.0\"\n");
YarnLockParser yarnLockParser = createYarnLockParser();
YarnLock yarnLock = yarnLockParser.parseYarnLock(yarnLockText);
YarnLockDependency dep = new YarnLockDependency("@graphql-typed-document-node/core", "^3.0.0", false);
assertEntry(yarnLock, "@apollo/client", "^3.1.3", "3.3.6", dep);
}
Aggregations