Skip to content

Commit

Permalink
Fix Issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-zepol committed Sep 7, 2024
1 parent dde0024 commit e91811b
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 192 deletions.
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

0 comments on commit e91811b

Please sign in to comment.