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));
}
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());
}
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));
}
Aggregations