Search in sources :

Example 1 with YarnLockEntryBuilder

use of com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntryBuilder 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());
}
Also used : YarnLockEntryId(com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntryId) YarnLockEntry(com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntry) YarnLockEntryBuilder(com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntryBuilder) Test(org.junit.jupiter.api.Test)

Example 2 with YarnLockEntryBuilder

use of com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntryBuilder 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());
}
Also used : YarnLockEntryId(com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntryId) YarnLockEntry(com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntry) YarnLockEntryBuilder(com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntryBuilder) Test(org.junit.jupiter.api.Test)

Example 3 with YarnLockEntryBuilder

use of com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntryBuilder 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());
}
Also used : YarnLockEntryId(com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntryId) YarnLockEntry(com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntry) YarnLockEntryBuilder(com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntryBuilder)

Example 4 with YarnLockEntryBuilder

use of com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntryBuilder in project synopsys-detect by blackducksoftware.

the class YarnLockHeaderSectionParserTest method testList.

@Test
void testList() {
    String line = "\"@apollographql/apollo-tools@^0.4.2\", \"@apollographql/apollo-tools@^0.4.3\":";
    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("@apollographql/apollo-tools", ids.get(0).getName());
    Assertions.assertEquals("^0.4.2", ids.get(0).getVersion());
    Assertions.assertEquals("@apollographql/apollo-tools", ids.get(1).getName());
    Assertions.assertEquals("^0.4.3", ids.get(1).getVersion());
}
Also used : YarnLockEntryId(com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntryId) YarnLockEntry(com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntry) YarnLockEntryBuilder(com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntryBuilder) Test(org.junit.jupiter.api.Test)

Example 5 with YarnLockEntryBuilder

use of com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntryBuilder in project synopsys-detect by blackducksoftware.

the class YarnLockHeaderSectionParserTest method testQuotedId.

@Test
void testQuotedId() {
    String line = "\"xtend@>=4.0.0 <4.1.0-0\", xtend@^4.0.0, xtend@~4.0.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(3, ids.size());
    Assertions.assertEquals("xtend", ids.get(0).getName());
    Assertions.assertEquals(">=4.0.0 <4.1.0-0", ids.get(0).getVersion());
    Assertions.assertEquals("xtend", ids.get(1).getName());
    Assertions.assertEquals("^4.0.0", ids.get(1).getVersion());
    Assertions.assertEquals("xtend", ids.get(2).getName());
    Assertions.assertEquals("~4.0.1", ids.get(2).getVersion());
}
Also used : YarnLockEntryId(com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntryId) YarnLockEntry(com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntry) YarnLockEntryBuilder(com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntryBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

YarnLockEntry (com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntry)6 YarnLockEntryBuilder (com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntryBuilder)6 YarnLockEntryId (com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntryId)6 Test (org.junit.jupiter.api.Test)5