Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ public OrganizationalChoice deserialize(JsonParser jp, DeserializationContext ct

private OrganizationalEntity deserializeOrganization(JsonParser jp, JsonNode organizationNode) throws JsonProcessingException {
OrganizationalEntity organization = new OrganizationalEntity();
organization.setName(organizationNode.get("name").asText());
if (organizationNode.has("name")) {
organization.setName(organizationNode.get("name").asText());
}

if (organizationNode.has("contact")) {
JsonNode contactsNode = organizationNode.get("contact");
Expand Down
13 changes: 13 additions & 0 deletions src/test/java/org/cyclonedx/parsers/JsonParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import java.util.Objects;
import java.util.stream.Collectors;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
Expand Down Expand Up @@ -256,6 +257,18 @@ public void testIssue343Regression() throws Exception {
assertEquals(0, bom.getComponents().get(0).getHashes().size());
}

@Test
public void testIssue507Regression() throws Exception {
final Bom bom = getJsonBom("regression/issue507.json");
assertThat(bom.getComponents()).hasSize(1);
assertThat(bom.getComponents().get(0).getLicenses()).isNotNull();
assertThat(bom.getComponents().get(0).getLicenses().getLicenses()).hasSize(1);
assertThat(bom.getComponents().get(0).getLicenses().getLicenses().get(0).getLicensing()).isNotNull();
assertThat(bom.getComponents().get(0).getLicenses().getLicenses().get(0).getLicensing().getPurchaser()).isNotNull();
assertThat(bom.getComponents().get(0).getLicenses().getLicenses().get(0).getLicensing().getPurchaser().getOrganization()).isNotNull();
assertThat(bom.getComponents().get(0).getLicenses().getLicenses().get(0).getLicensing().getPurchaser().getOrganization().getContacts()).hasSize(1);
}

@Test
public void schema16_license_id_acknowledgement() throws Exception {
final Bom bom = getJsonBom("1.6/valid-license-id-1.6.json");
Expand Down
28 changes: 28 additions & 0 deletions src/test/resources/regression/issue507.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"bomFormat": "CycloneDX",
"specVersion": "1.6",
"components": [
{
"type": "library",
"name": "acme-library",
"licenses": [
{
"license": {
"name": "foo",
"licensing": {
"purchaser": {
"organization": {
"contact": [
{
"name": ""
}
]
}
}
}
}
}
]
}
]
}