Search in sources :

Example 1 with YarnLockFileReader

use of org.eclipse.dash.licenses.cli.YarnLockFileReader in project dash-licenses by eclipse.

the class YarnLockFileReaderTests method testAllValidIds.

@Test
void testAllValidIds() throws IOException {
    try (InputStream input = this.getClass().getResourceAsStream(YARN_LOCK)) {
        var ids = new YarnLockFileReader(new InputStreamReader(input)).getContentIds();
        assertTrue(ids.stream().allMatch(each -> each.isValid()));
    }
}
Also used : Test(org.junit.jupiter.api.Test) YarnLockFileReader(org.eclipse.dash.licenses.cli.YarnLockFileReader) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) StringReader(java.io.StringReader) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) IContentId(org.eclipse.dash.licenses.IContentId) IOException(java.io.IOException) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) YarnLockFileReader(org.eclipse.dash.licenses.cli.YarnLockFileReader) Test(org.junit.jupiter.api.Test)

Example 2 with YarnLockFileReader

use of org.eclipse.dash.licenses.cli.YarnLockFileReader in project dash-licenses by eclipse.

the class YarnLockFileReaderTests method testSingleEntryWithNamespace.

@Test
void testSingleEntryWithNamespace() throws IOException {
    // @formatter:off
    String contents = "\"@babel/code-frame@^7.0.0\", \"@babel/code-frame@^7.12.13\":\n" + "  version \"7.12.13\"\n" + "  resolved \"https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.12.13.tgz#dcfc826beef65e75c50e21d3837d7d95798dd658\"\n" + "  integrity sha512-HV1Cm0Q3ZrpCR93tkWOYiuYIgLxZXZFVG2VgK+MBWjUqZTundupbfx2aXarXuw5Ko5aMcjtJgbSs4vUGBS5v6g==\n" + "  dependencies:\n" + "    \"@babel/highlight\" \"^7.12.13\"";
    // @formatter:on
    var ids = new YarnLockFileReader(new StringReader(contents)).getContentIds();
    IContentId id = ids.get(0);
    assertEquals("@babel", id.getNamespace());
    assertEquals("code-frame", id.getName());
    assertEquals("7.12.13", id.getVersion());
}
Also used : IContentId(org.eclipse.dash.licenses.IContentId) StringReader(java.io.StringReader) YarnLockFileReader(org.eclipse.dash.licenses.cli.YarnLockFileReader) Test(org.junit.jupiter.api.Test)

Example 3 with YarnLockFileReader

use of org.eclipse.dash.licenses.cli.YarnLockFileReader in project dash-licenses by eclipse.

the class YarnLockFileReaderTests method testInvalidEntry.

@Test
void testInvalidEntry() throws IOException {
    // @formatter:off
    String contents = "spawn-command@^0.0.2-1:\n" + "  resolved \"https://registry.yarnpkg.com/spawn-command/-/spawn-command-0.0.2-1.tgz#62f5e9466981c1b796dc5929937e11c9c6921bd0\"\n" + "  integrity sha1-YvXpRmmBwbeW3Fkpk34RycaSG9A=\n" + "";
    // @formatter:on
    var ids = new YarnLockFileReader(new StringReader(contents)).getContentIds();
    IContentId id = ids.get(0);
    assertFalse(id.isValid());
}
Also used : IContentId(org.eclipse.dash.licenses.IContentId) StringReader(java.io.StringReader) YarnLockFileReader(org.eclipse.dash.licenses.cli.YarnLockFileReader) Test(org.junit.jupiter.api.Test)

Example 4 with YarnLockFileReader

use of org.eclipse.dash.licenses.cli.YarnLockFileReader in project dash-licenses by eclipse.

the class YarnLockFileReaderTests method test.

@Test
void test() throws IOException {
    try (InputStream input = this.getClass().getResourceAsStream(YARN_LOCK)) {
        var ids = new YarnLockFileReader(new InputStreamReader(input)).getContentIds();
        assertEquals("npm/npmjs/@babel/code-frame/7.12.11", ids.get(0).toString());
        assertEquals("npm/npmjs/@babel/code-frame/7.12.13", ids.get(1).toString());
        assertEquals("npm/npmjs/-/node-environment-flags/1.0.6", ids.get(2).toString());
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) YarnLockFileReader(org.eclipse.dash.licenses.cli.YarnLockFileReader) Test(org.junit.jupiter.api.Test)

Example 5 with YarnLockFileReader

use of org.eclipse.dash.licenses.cli.YarnLockFileReader in project dash-licenses by eclipse.

the class YarnLockFileReaderTests method testSingleEntry.

@Test
void testSingleEntry() throws IOException {
    // @formatter:off
    String contents = "spawn-command@^0.0.2-1:\n" + "  version \"0.0.2-1\"\n" + "  resolved \"https://registry.yarnpkg.com/spawn-command/-/spawn-command-0.0.2-1.tgz#62f5e9466981c1b796dc5929937e11c9c6921bd0\"\n" + "  integrity sha1-YvXpRmmBwbeW3Fkpk34RycaSG9A=\n" + "";
    // @formatter:on
    var ids = new YarnLockFileReader(new StringReader(contents)).getContentIds();
    IContentId id = ids.get(0);
    assertEquals("-", id.getNamespace());
    assertEquals("spawn-command", id.getName());
    assertEquals("0.0.2-1", id.getVersion());
}
Also used : IContentId(org.eclipse.dash.licenses.IContentId) StringReader(java.io.StringReader) YarnLockFileReader(org.eclipse.dash.licenses.cli.YarnLockFileReader) Test(org.junit.jupiter.api.Test)

Aggregations

YarnLockFileReader (org.eclipse.dash.licenses.cli.YarnLockFileReader)5 Test (org.junit.jupiter.api.Test)5 StringReader (java.io.StringReader)4 IContentId (org.eclipse.dash.licenses.IContentId)4 InputStream (java.io.InputStream)2 InputStreamReader (java.io.InputStreamReader)2 IOException (java.io.IOException)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)1 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)1