Search in sources :

Example 1 with ClearlyDefinedContentData

use of org.eclipse.dash.licenses.clearlydefined.ClearlyDefinedContentData in project dash-licenses by eclipse.

the class ClearlyDefinedContentDataTests method testMissingData.

@Test
void testMissingData() {
    ClearlyDefinedContentData info = new ClearlyDefinedContentData("test", JsonValue.EMPTY_JSON_OBJECT);
    assertEquals(0, info.getScore());
    assertEquals(0, info.getEffectiveScore());
    assertEquals("", info.getLicense());
    assertArrayEquals(new String[] {}, info.discoveredLicenses().toArray(String[]::new));
}
Also used : ClearlyDefinedContentData(org.eclipse.dash.licenses.clearlydefined.ClearlyDefinedContentData) Test(org.junit.jupiter.api.Test)

Example 2 with ClearlyDefinedContentData

use of org.eclipse.dash.licenses.clearlydefined.ClearlyDefinedContentData in project dash-licenses by eclipse.

the class ClearlyDefinedContentDataTests method testSingleLicense.

@Test
void testSingleLicense() throws Exception {
    InputStream input = this.getClass().getResourceAsStream("/write-1.0.3.json");
    JsonReader reader = Json.createReader(new InputStreamReader(input, StandardCharsets.UTF_8));
    JsonObject data = ((JsonValue) reader.read()).asJsonObject();
    ClearlyDefinedContentData info = new ClearlyDefinedContentData("npm/npmjs/-/write/1.0.3", data);
    assertEquals("npm/npmjs/-/write/1.0.3", info.getId().toString());
    assertEquals("MIT", info.getLicense());
    assertEquals("1.0.3", info.getRevision());
    assertArrayEquals(new String[] { "MIT" }, info.discoveredLicenses().toArray(String[]::new));
    assertEquals(94, info.getScore());
    assertEquals(97, info.getEffectiveScore());
    assertEquals("https://clearlydefined.io/definitions/npm/npmjs/-/write/1.0.3", info.getUrl());
    assertEquals("https://github.com/jonschlinkert/write/tree/f5397515060bf42f75151fcc3c4722517e4e322a", info.getSourceLocation().getUrl());
    assertEquals("https://github.com/jonschlinkert/write/archive/refs/tags/1.0.3.zip", info.getSourceLocation().getDownloadUrl());
    assertNull(info.getStatus());
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) JsonValue(jakarta.json.JsonValue) JsonReader(jakarta.json.JsonReader) JsonObject(jakarta.json.JsonObject) ClearlyDefinedContentData(org.eclipse.dash.licenses.clearlydefined.ClearlyDefinedContentData) Test(org.junit.jupiter.api.Test)

Example 3 with ClearlyDefinedContentData

use of org.eclipse.dash.licenses.clearlydefined.ClearlyDefinedContentData in project dash-licenses by eclipse.

the class ClearlyDefinedContentDataTests method testDiscoveredLicenses.

@Test
void testDiscoveredLicenses() throws Exception {
    InputStream input = this.getClass().getResourceAsStream("/lockfile-1.1.0.json");
    JsonReader reader = Json.createReader(new InputStreamReader(input, StandardCharsets.UTF_8));
    JsonObject data = ((JsonValue) reader.read()).asJsonObject();
    ClearlyDefinedContentData info = new ClearlyDefinedContentData("npm/npmjs/-/lockfile/1.1.1", data);
    assertArrayEquals(new String[] { "GPL-2.0", "MIT" }, info.discoveredLicenses().toArray(String[]::new));
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) JsonValue(jakarta.json.JsonValue) JsonReader(jakarta.json.JsonReader) JsonObject(jakarta.json.JsonObject) ClearlyDefinedContentData(org.eclipse.dash.licenses.clearlydefined.ClearlyDefinedContentData) Test(org.junit.jupiter.api.Test)

Aggregations

ClearlyDefinedContentData (org.eclipse.dash.licenses.clearlydefined.ClearlyDefinedContentData)3 Test (org.junit.jupiter.api.Test)3 JsonObject (jakarta.json.JsonObject)2 JsonReader (jakarta.json.JsonReader)2 JsonValue (jakarta.json.JsonValue)2 InputStream (java.io.InputStream)2 InputStreamReader (java.io.InputStreamReader)2