Skip to content

Commit

Permalink
Merge pull request #4091 from gbonnefille/test-license-id-or-name
Browse files Browse the repository at this point in the history
Add test for license finding by Id or Name
  • Loading branch information
nscuro authored Aug 24, 2024
2 parents 3837f0c + 3a41ad8 commit 3555981
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,49 @@ public void informWithLicenseResolutionByNameTest() {
});
}

@Test
public void informWithLicenseResolutionByIdOrNameTest() {
final var license = new License();
license.setLicenseId("MIT");
license.setName("MIT License");
qm.persist(license);

final var project = new Project();
project.setName("acme-license-app");
qm.persist(project);

final byte[] bomBytes = """
{
"bomFormat": "CycloneDX",
"specVersion": "1.4",
"serialNumber": "urn:uuid:3e671687-395b-41f5-a30f-a58921a69b80",
"version": 1,
"components": [
{
"type": "library",
"name": "acme-lib-x",
"licenses": [
{
"license": {
"name": "MIT"
}
}
]
}
]
}
""".getBytes(StandardCharsets.UTF_8);

final var bomUploadEvent = new BomUploadEvent(qm.detach(Project.class, project.getId()), bomBytes);
new BomUploadProcessingTask().inform(bomUploadEvent);
awaitBomProcessedNotification(bomUploadEvent);

assertThat(qm.getAllComponents(project)).satisfiesExactly(component -> {
assertThat(component.getResolvedLicense()).isNotNull();
assertThat(component.getResolvedLicense().getLicenseId()).isEqualTo("MIT");
});
}

@Test // https://github.com/DependencyTrack/dependency-track/issues/1905
public void informIssue1905Test() throws Exception {
final var project = qm.createProject("Acme Example", null, "1.0", null, null, null, true, false);
Expand Down

0 comments on commit 3555981

Please sign in to comment.