Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue 498 #500

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -5,6 +5,7 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import org.cyclonedx.Version;
Expand All @@ -14,6 +15,7 @@
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JacksonXmlRootElement(localName = "occurrence")
@JsonPropertyOrder({"bom-ref", "location", "line", "offset", "symbol", "additionalContext"})
public class Occurrence extends ExtensibleElement
{
@JacksonXmlProperty(isAttribute = true, localName = "bom-ref")
Expand All @@ -30,7 +32,7 @@ public class Occurrence extends ExtensibleElement
private Integer offset;

@VersionFilter(Version.VERSION_16)
private Integer symbol;
private String symbol;

@VersionFilter(Version.VERSION_16)
private String additionalContext;
Expand Down Expand Up @@ -67,11 +69,11 @@ public void setOffset(final Integer offset) {
this.offset = offset;
}

public Integer getSymbol() {
public String getSymbol() {
return symbol;
}

public void setSymbol(final Integer symbol) {
public void setSymbol(final String symbol) {
this.symbol = symbol;
}

Expand Down
10 changes: 7 additions & 3 deletions src/test/java/org/cyclonedx/parsers/AbstractParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -680,9 +680,9 @@ private void assertEvidence(final Evidence evidence, final Version version) {
assertEquals("http://www.apache.org/licenses/LICENSE-2.0",
evidence.getLicenseChoice().getLicenses().get(0).getUrl());

if (version == Version.VERSION_15) {
if (version.getVersion() >= Version.VERSION_15.getVersion()) {
assertCallStack(evidence.getCallstack());
assertOccurrences(evidence.getOccurrences());
assertOccurrences(evidence.getOccurrences(), version);
assertEquals(1, evidence.getIdentities().size());
assertIdentifiers(evidence.getIdentities().get(0), version);
}
Expand All @@ -693,12 +693,16 @@ private void assertEvidence(final Evidence evidence, final Version version) {
}
}

private void assertOccurrences(final List<Occurrence> occurrences){
private void assertOccurrences(final List<Occurrence> occurrences, Version version){
assertEquals(occurrences.size(), 1);
Occurrence occurrence = occurrences.get(0);

assertNotNull(occurrence.getBomRef());
assertNotNull(occurrence.getLocation());

if (version.getVersion() >= Version.VERSION_16.getVersion()) {
assertNotNull(occurrence.getSymbol());
}
}

private void assertCallStack(final Callstack callstack){
Expand Down
Loading