Search in sources :

Example 11 with YarnLockEntryId

use of com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntryId 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 12 with YarnLockEntryId

use of com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntryId 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)

Example 13 with YarnLockEntryId

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

the class YarnLockHeaderSectionParserTest method testQuotedList.

@Test
void testQuotedList() {
    String line = "\"color-convert@npm:^1.9.0, color-convert@npm:^1.9.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("color-convert", ids.get(0).getName());
    Assertions.assertEquals("^1.9.0", ids.get(0).getVersion());
    Assertions.assertEquals("color-convert", ids.get(1).getName());
    Assertions.assertEquals("^1.9.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)

Aggregations

YarnLockEntryId (com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntryId)13 YarnLockEntry (com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntry)12 YarnLockEntryBuilder (com.synopsys.integration.detectable.detectables.yarn.parse.entry.YarnLockEntryBuilder)6 Test (org.junit.jupiter.api.Test)6 YarnLockDependency (com.synopsys.integration.detectable.detectables.yarn.parse.YarnLockDependency)4 PackageJson (com.synopsys.integration.detectable.detectables.npm.packagejson.model.PackageJson)2 NullSafePackageJson (com.synopsys.integration.detectable.detectables.yarn.packagejson.NullSafePackageJson)2 WorkspacePackageJson (com.synopsys.integration.detectable.detectables.yarn.packagejson.WorkspacePackageJson)2 YarnLock (com.synopsys.integration.detectable.detectables.yarn.parse.YarnLock)2 YarnLockResult (com.synopsys.integration.detectable.detectables.yarn.parse.YarnLockResult)2 LinkedList (java.util.LinkedList)2 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)1 LazyExternalIdDependencyGraphBuilder (com.synopsys.integration.bdio.graph.builder.LazyExternalIdDependencyGraphBuilder)1 LazyId (com.synopsys.integration.bdio.graph.builder.LazyId)1 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)1 UnitTest (com.synopsys.integration.detectable.annotations.UnitTest)1 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)1 YarnWorkspace (com.synopsys.integration.detectable.detectables.yarn.workspace.YarnWorkspace)1 YarnWorkspaces (com.synopsys.integration.detectable.detectables.yarn.workspace.YarnWorkspaces)1 NameVersion (com.synopsys.integration.util.NameVersion)1