Skip to content

Commit ebafc9d

Browse files
committed
Fix Issue
1 parent 16276f9 commit ebafc9d

File tree

5 files changed

+58
-35
lines changed

5 files changed

+58
-35
lines changed

src/main/java/org/cyclonedx/model/component/evidence/Occurrence.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
66
import com.fasterxml.jackson.annotation.JsonInclude;
77
import com.fasterxml.jackson.annotation.JsonProperty;
8+
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
89
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
910
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
1011
import org.cyclonedx.Version;
@@ -14,6 +15,7 @@
1415
@JsonIgnoreProperties(ignoreUnknown = true)
1516
@JsonInclude(JsonInclude.Include.NON_EMPTY)
1617
@JacksonXmlRootElement(localName = "occurrence")
18+
@JsonPropertyOrder({"bom-ref", "location", "line", "offset", "symbol", "additionalContext"})
1719
public class Occurrence extends ExtensibleElement
1820
{
1921
@JacksonXmlProperty(isAttribute = true, localName = "bom-ref")
@@ -30,7 +32,7 @@ public class Occurrence extends ExtensibleElement
3032
private Integer offset;
3133

3234
@VersionFilter(Version.VERSION_16)
33-
private Integer symbol;
35+
private String symbol;
3436

3537
@VersionFilter(Version.VERSION_16)
3638
private String additionalContext;
@@ -67,11 +69,11 @@ public void setOffset(final Integer offset) {
6769
this.offset = offset;
6870
}
6971

70-
public Integer getSymbol() {
72+
public String getSymbol() {
7173
return symbol;
7274
}
7375

74-
public void setSymbol(final Integer symbol) {
76+
public void setSymbol(final String symbol) {
7577
this.symbol = symbol;
7678
}
7779

src/test/java/org/cyclonedx/parsers/AbstractParserTest.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -680,9 +680,9 @@ private void assertEvidence(final Evidence evidence, final Version version) {
680680
assertEquals("http://www.apache.org/licenses/LICENSE-2.0",
681681
evidence.getLicenseChoice().getLicenses().get(0).getUrl());
682682

683-
if (version == Version.VERSION_15) {
683+
if (version.getVersion() >= Version.VERSION_15.getVersion()) {
684684
assertCallStack(evidence.getCallstack());
685-
assertOccurrences(evidence.getOccurrences());
685+
assertOccurrences(evidence.getOccurrences(), version);
686686
assertEquals(1, evidence.getIdentities().size());
687687
assertIdentifiers(evidence.getIdentities().get(0), version);
688688
}
@@ -693,12 +693,16 @@ private void assertEvidence(final Evidence evidence, final Version version) {
693693
}
694694
}
695695

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

700700
assertNotNull(occurrence.getBomRef());
701701
assertNotNull(occurrence.getLocation());
702+
703+
if (version.getVersion() >= Version.VERSION_16.getVersion()) {
704+
assertNotNull(occurrence.getSymbol());
705+
}
702706
}
703707

704708
private void assertCallStack(final Callstack callstack){

0 commit comments

Comments
 (0)