Search in sources :

Example 1 with IContentId

use of org.eclipse.dash.licenses.IContentId 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 2 with IContentId

use of org.eclipse.dash.licenses.IContentId 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 IContentId

use of org.eclipse.dash.licenses.IContentId in project dash-licenses by eclipse.

the class LicenseCheckerTests method testWithUnsupported.

@Test
void testWithUnsupported() {
    IContentId contentId = ContentId.getContentId("p2/eclipseplugin/-/write/0.2.0");
    Map<IContentId, LicenseData> licenseData = licenseChecker.getLicenseData(Collections.singleton(contentId));
    LicenseData data = licenseData.get(contentId);
    assertNull(data.getLicense());
    assertEquals(LicenseSupport.Status.Restricted, data.getStatus());
}
Also used : IContentId(org.eclipse.dash.licenses.IContentId) LicenseData(org.eclipse.dash.licenses.LicenseData) Test(org.junit.jupiter.api.Test)

Example 4 with IContentId

use of org.eclipse.dash.licenses.IContentId in project dash-licenses by eclipse.

the class LicenseCheckerTests method testSingleApprovedLicense.

@Test
void testSingleApprovedLicense() {
    IContentId contentId = ContentId.getContentId("npm/npmjs/-/write/1.0.3");
    Map<IContentId, LicenseData> licenseData = licenseChecker.getLicenseData(Collections.singleton(contentId));
    LicenseData data = licenseData.get(contentId);
    assertEquals("MIT", data.getLicense());
    assertEquals(LicenseSupport.Status.Approved, data.getStatus());
}
Also used : IContentId(org.eclipse.dash.licenses.IContentId) LicenseData(org.eclipse.dash.licenses.LicenseData) Test(org.junit.jupiter.api.Test)

Example 5 with IContentId

use of org.eclipse.dash.licenses.IContentId in project dash-licenses by eclipse.

the class MavenIdParserTests method testOrbitBundle.

@Test
public void testOrbitBundle() {
    IContentId value = parser.parseId("p2.eclipse-plugin:org.eclipse.core.jobs:jar:3.8.0.v20160509-0411");
    assertEquals("p2", value.getType());
    assertEquals("orbit", value.getSource());
    assertEquals("p2.eclipse-plugin", value.getNamespace());
    assertEquals("org.eclipse.core.jobs", value.getName());
    assertEquals("3.8.0.v20160509-0411", value.getVersion());
}
Also used : IContentId(org.eclipse.dash.licenses.IContentId) Test(org.junit.jupiter.api.Test)

Aggregations

IContentId (org.eclipse.dash.licenses.IContentId)26 Test (org.junit.jupiter.api.Test)23 StringReader (java.io.StringReader)4 LicenseData (org.eclipse.dash.licenses.LicenseData)3 YarnLockFileReader (org.eclipse.dash.licenses.cli.YarnLockFileReader)3 Injector (com.google.inject.Injector)2 FileNotFoundException (java.io.FileNotFoundException)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 ISettings (org.eclipse.dash.licenses.ISettings)2 LicenseChecker (org.eclipse.dash.licenses.LicenseChecker)2 PackageLockFileReader (org.eclipse.dash.licenses.cli.PackageLockFileReader)2 LicenseToolModule (org.eclipse.dash.licenses.context.LicenseToolModule)2 CreateReviewRequestCollector (org.eclipse.dash.licenses.review.CreateReviewRequestCollector)2 Disabled (org.junit.jupiter.api.Disabled)2 Json (jakarta.json.Json)1 JsonArray (jakarta.json.JsonArray)1 JsonArrayBuilder (jakarta.json.JsonArrayBuilder)1 JsonObject (jakarta.json.JsonObject)1 JsonObjectBuilder (jakarta.json.JsonObjectBuilder)1