use of com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntry in project synopsys-detect by blackducksoftware.
the class YarnLockHeaderSectionParserTest method testParserHandlesMissingSymbol.
@Test
void testParserHandlesMissingSymbol() {
String line = "example, example@1";
List<String> lines = Arrays.asList(line);
Assertions.assertTrue(yarnLockParser.applies(line));
YarnLockEntryBuilder builder = new YarnLockEntryBuilder();
yarnLockParser.parseSection(builder, lines, 0);
// Complete the builder requirements and build the entry
builder.setVersion("testVersion");
YarnLockEntry entry = builder.build();
List<YarnLockEntryId> ids = entry.getIds();
Assertions.assertEquals(2, ids.size());
Assertions.assertEquals("example", ids.get(0).getName());
Assertions.assertEquals("", ids.get(0).getVersion());
Assertions.assertEquals("example", ids.get(1).getName());
Assertions.assertEquals("1", ids.get(1).getVersion());
}
use of com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntry in project synopsys-detect by blackducksoftware.
the class YarnLockHeaderSectionParserTest method handlesSymbolInName.
@Test
void handlesSymbolInName() {
String line = "@example";
List<String> lines = Arrays.asList(line);
Assertions.assertTrue(yarnLockParser.applies(line));
YarnLockEntryBuilder builder = new YarnLockEntryBuilder();
yarnLockParser.parseSection(builder, lines, 0);
// Complete the builder requirements and build the entry
builder.setVersion("testVersion");
YarnLockEntry entry = builder.build();
List<YarnLockEntryId> ids = entry.getIds();
Assertions.assertEquals(1, ids.size());
Assertions.assertEquals("@example", ids.get(0).getName());
Assertions.assertEquals("", ids.get(0).getVersion());
}
use of com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntry in project synopsys-detect by blackducksoftware.
the class YarnLockKeyValuePairSectionParserTest method doTest.
private void doTest(String line, String versionValue) {
Assertions.assertTrue(yarnLockKeyValuePairElementParser.applies(line));
YarnLockEntryBuilder builder = new YarnLockEntryBuilder();
builder.addId(new YarnLockEntryId("idname", "idversion"));
List<String> lines = Arrays.asList(line);
yarnLockKeyValuePairElementParser.parseSection(builder, lines, 0);
YarnLockEntry entry = builder.build();
Assertions.assertEquals(versionValue, entry.getVersion());
}
use of com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntry in project synopsys-detect by blackducksoftware.
the class YarnLockParserTest method testThatYarnLockPeerNotAdded.
@Test
void testThatYarnLockPeerNotAdded() {
List<String> yarnLockText = Arrays.asList("any-root-dep@1:", // must have a version to create an entry
" version: 1", " peerDependencies:", " some-peer: ^10.0.0", " peerDependenciesMeta:", " some-peer:", " optional: true");
YarnLockParser yarnLockParser = createYarnLockParser();
YarnLock yarnLock = yarnLockParser.parseYarnLock(yarnLockText);
Assertions.assertEquals(1, yarnLock.getEntries().size());
YarnLockEntry first = yarnLock.getEntries().get(0);
Assertions.assertEquals(0, first.getDependencies().size());
}
use of com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntry in project synopsys-detect by blackducksoftware.
the class YarnLockParserTest method testThatYarnParsesSemiColon.
@Test
void testThatYarnParsesSemiColon() {
List<String> yarnLockText = Arrays.asList("any-root-dep@1:", // must have a version to create an entry
" version: 1.0.0", " dependencies:", " some-peer: ^10.0.0");
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());
}
Aggregations