From dc101c2ad5e27d5a0afd4e2feeb8885f24728806 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Tue, 24 Aug 2021 13:20:26 -0400 Subject: Use CompareToBuilder Also added lombok to test classes. Issue-ID: POLICY-3391 Change-Id: I9ecf479f3861a2e5211b037e885029d1719b6a56 Signed-off-by: Jim Hahn --- .../integration/context/entities/ArtifactKeyTestEntity.java | 13 +++++-------- .../context/entities/ReferenceKeyTestEntity.java | 13 +++++-------- 2 files changed, 10 insertions(+), 16 deletions(-) (limited to 'testsuites/integration/integration-context-test/src/test/java') diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ArtifactKeyTestEntity.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ArtifactKeyTestEntity.java index 3b8394dbb..500405422 100644 --- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ArtifactKeyTestEntity.java +++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ArtifactKeyTestEntity.java @@ -33,6 +33,7 @@ import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.ToString; +import org.apache.commons.lang3.builder.CompareToBuilder; 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; @@ -143,13 +144,9 @@ public class ArtifactKeyTestEntity extends AxConcept { return -1; } final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) otherObj; - if (key == null) { - if (other.key != null) { - return 1; - } - } else if (!key.equals(other.key)) { - return key.compareTo(other.key); - } - return Double.compare(doubleValue, other.doubleValue); + return new CompareToBuilder() + .append(key, other.key) + .append(doubleValue, other.doubleValue) + .toComparison(); } } diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ReferenceKeyTestEntity.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ReferenceKeyTestEntity.java index da478f0dd..a8b90d17a 100644 --- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ReferenceKeyTestEntity.java +++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ReferenceKeyTestEntity.java @@ -34,6 +34,7 @@ import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.ToString; +import org.apache.commons.lang3.builder.CompareToBuilder; 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.AxReferenceKey; @@ -146,13 +147,9 @@ public class ReferenceKeyTestEntity extends AxConcept { return -1; } final ReferenceKeyTestEntity other = (ReferenceKeyTestEntity) otherObj; - if (key == null) { - if (other.key != null) { - return 1; - } - } else if (!key.equals(other.key)) { - return key.compareTo(other.key); - } - return Double.compare(doubleValue, other.doubleValue); + return new CompareToBuilder() + .append(key, other.key) + .append(doubleValue, other.doubleValue) + .toComparison(); } } -- cgit 1.2.3-korg