From 41ecf036b7f1b3bdd56311a0bc706407b242faca Mon Sep 17 00:00:00 2001 From: ramverma Date: Fri, 20 Jul 2018 16:52:38 +0100 Subject: Fix sonar bugs and vulnerabilities in apex-pdp Change-Id: I7ecabd3705de4a5352d5a98d1ab3a01677172651 Issue-ID: POLICY-954 Signed-off-by: ramverma --- .../test/entities/ArtifactKeyTestEntity.java | 40 +++++++++++++--------- .../test/entities/ReferenceKeyTestEntity.java | 38 +++++++++++--------- 2 files changed, 45 insertions(+), 33 deletions(-) (limited to 'context/context-test-utils/src') diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/entities/ArtifactKeyTestEntity.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/entities/ArtifactKeyTestEntity.java index e801ae786..49802c2da 100644 --- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/entities/ArtifactKeyTestEntity.java +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/entities/ArtifactKeyTestEntity.java @@ -28,9 +28,9 @@ import javax.persistence.Entity; import javax.persistence.Table; import javax.xml.bind.annotation.XmlElement; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; import org.onap.policy.apex.model.basicmodel.concepts.AxConcept; import org.onap.policy.apex.model.basicmodel.concepts.AxKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; @Entity @@ -59,10 +59,12 @@ public class ArtifactKeyTestEntity extends AxConcept { this.doubleValue = doubleValue; } + @Override public AxArtifactKey getKey() { return key; } + @Override public List getKeys() { return Arrays.asList((AxKey) getKey()); } @@ -125,38 +127,42 @@ public class ArtifactKeyTestEntity extends AxConcept { @Override public boolean equals(final Object obj) { - if (obj == null) + if (obj == null) { return false; - if (this == obj) + } + if (this == obj) { return true; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) obj; if (key == null) { - if (other.key != null) + if (other.key != null) { return false; - } else if (!key.equals(other.key)) - return false; - if (doubleValue != other.doubleValue) + } + } else if (!key.equals(other.key)) { return false; - return true; + } + return (Double.compare(doubleValue, other.doubleValue) == 0); } @Override public int compareTo(final AxConcept otherObj) { - if (otherObj == null) + if (otherObj == null) { return -1; - if (this == otherObj) + } + if (this == otherObj) { return 0; + } final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) otherObj; if (key == null) { - if (other.key != null) + if (other.key != null) { return 1; - } else if (!key.equals(other.key)) + } + } else if (!key.equals(other.key)) { return key.compareTo(other.key); - if (doubleValue != other.doubleValue) - return new Double(doubleValue).compareTo(other.doubleValue); - - return 0; + } + return Double.compare(doubleValue, other.doubleValue); } } diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/entities/ReferenceKeyTestEntity.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/entities/ReferenceKeyTestEntity.java index 14c3628e5..6f276335b 100644 --- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/entities/ReferenceKeyTestEntity.java +++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/entities/ReferenceKeyTestEntity.java @@ -62,10 +62,12 @@ public class ReferenceKeyTestEntity extends AxConcept { this.doubleValue = doubleValue; } + @Override public AxReferenceKey getKey() { return key; } + @Override public List getKeys() { return Arrays.asList((AxKey) getKey()); } @@ -128,38 +130,42 @@ public class ReferenceKeyTestEntity extends AxConcept { @Override public boolean equals(final Object obj) { - if (obj == null) + if (obj == null) { return false; - if (this == obj) + } + if (this == obj) { return true; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } final ReferenceKeyTestEntity other = (ReferenceKeyTestEntity) obj; if (key == null) { - if (other.key != null) + if (other.key != null) { return false; - } else if (!key.equals(other.key)) - return false; - if (doubleValue != other.doubleValue) + } + } else if (!key.equals(other.key)) { return false; - return true; + } + return (Double.compare(doubleValue, other.doubleValue) == 0); } @Override public int compareTo(final AxConcept otherObj) { - if (otherObj == null) + if (otherObj == null) { return -1; - if (this == otherObj) + } + if (this == otherObj) { return 0; + } final ReferenceKeyTestEntity other = (ReferenceKeyTestEntity) otherObj; if (key == null) { - if (other.key != null) + if (other.key != null) { return 1; - } else if (!key.equals(other.key)) + } + } else if (!key.equals(other.key)) { return key.compareTo(other.key); - if (doubleValue != other.doubleValue) - return new Double(doubleValue).compareTo(other.doubleValue); - - return 0; + } + return Double.compare(doubleValue, other.doubleValue); } } -- cgit 1.2.3-korg