summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-impl/appc/src
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-07-21 09:55:38 -0400
committerJim Hahn <jrh3@att.com>2020-07-21 16:25:53 -0400
commit248a660d61fa03caa4710cf8cfe144eb245b807b (patch)
tree9f7c9aa7fda6d9ab9977bf2398a0136a787dc62a /models-interactions/model-impl/appc/src
parentf203526d0f86d385976da394bd1f0f918e4445d9 (diff)
Fix some sonars in policy-models
Fixed the following sonar issues in some of the project directories: - use assertNull, assertEquals, etc. - swap assertEquals arguments - extract a constant - don't invoke toString() in logger calls - TODOs - generic types Issue-ID: POLICY-2714 Change-Id: Id8803f9bf617ea9fc173a67b8606600709b55bdc Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-interactions/model-impl/appc/src')
-rw-r--r--models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java73
-rw-r--r--models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java11
-rw-r--r--models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseStatusTest.java39
-rw-r--r--models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseTest.java39
4 files changed, 84 insertions, 78 deletions
diff --git a/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java b/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java
index 4854e2759..3e84a3df2 100644
--- a/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java
+++ b/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,10 +22,8 @@
package org.onap.policy.appc;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import java.time.Instant;
import java.util.ArrayList;
@@ -85,78 +83,81 @@ public class CommonHeaderTest {
copiedCommonHeader.setSubRequestId(commonHeader.getSubRequestId());
copiedCommonHeader.setTimeStamp(commonHeader.getTimeStamp());
- assertTrue(commonHeader.equals(commonHeader));
- assertTrue(commonHeader.equals(copiedCommonHeader));
- assertFalse(commonHeader.equals(null));
- assertFalse(commonHeader.equals("Hello"));
+ /*
+ * Disabling sonar to test equals().
+ */
+ assertEquals(commonHeader, commonHeader); // NOSONAR
+ assertEquals(commonHeader, copiedCommonHeader);
+ assertNotEquals(commonHeader, null);
+ assertNotEquals(commonHeader, "Hello"); // NOSONAR
CommonHeader clonedCommonHeader = new CommonHeader(commonHeader);
clonedCommonHeader.setApiVer(commonHeader.getApiVer());
clonedCommonHeader.setTimeStamp(commonHeader.getTimeStamp());
- assertTrue(commonHeader.equals(clonedCommonHeader));
+ assertEquals(commonHeader, clonedCommonHeader);
commonHeader.setApiVer(null);
- assertFalse(commonHeader.equals(copiedCommonHeader));
+ assertNotEquals(commonHeader, copiedCommonHeader);
copiedCommonHeader.setApiVer(null);
- assertTrue(commonHeader.equals(copiedCommonHeader));
+ assertEquals(commonHeader, copiedCommonHeader);
commonHeader.setApiVer(KANSAS);
- assertFalse(commonHeader.equals(copiedCommonHeader));
+ assertNotEquals(commonHeader, copiedCommonHeader);
copiedCommonHeader.setApiVer(KANSAS);
- assertTrue(commonHeader.equals(copiedCommonHeader));
+ assertEquals(commonHeader, copiedCommonHeader);
commonHeader.setFlags(null);
- assertFalse(commonHeader.equals(copiedCommonHeader));
+ assertNotEquals(commonHeader, copiedCommonHeader);
copiedCommonHeader.setFlags(null);
- assertTrue(commonHeader.equals(copiedCommonHeader));
+ assertEquals(commonHeader, copiedCommonHeader);
commonHeader.setFlags(flagSet);
- assertFalse(commonHeader.equals(copiedCommonHeader));
+ assertNotEquals(commonHeader, copiedCommonHeader);
copiedCommonHeader.setFlags(flagSet);
- assertTrue(commonHeader.equals(copiedCommonHeader));
+ assertEquals(commonHeader, copiedCommonHeader);
commonHeader.setOriginatorId(null);
- assertFalse(commonHeader.equals(copiedCommonHeader));
+ assertNotEquals(commonHeader, copiedCommonHeader);
copiedCommonHeader.setOriginatorId(null);
- assertTrue(commonHeader.equals(copiedCommonHeader));
+ assertEquals(commonHeader, copiedCommonHeader);
commonHeader.setOriginatorId(DOROTHY);
- assertFalse(commonHeader.equals(copiedCommonHeader));
+ assertNotEquals(commonHeader, copiedCommonHeader);
copiedCommonHeader.setOriginatorId(DOROTHY);
- assertTrue(commonHeader.equals(copiedCommonHeader));
+ assertEquals(commonHeader, copiedCommonHeader);
commonHeader.setRequestId(null);
- assertFalse(commonHeader.equals(copiedCommonHeader));
+ assertNotEquals(commonHeader, copiedCommonHeader);
copiedCommonHeader.setRequestId(null);
- assertTrue(commonHeader.equals(copiedCommonHeader));
+ assertEquals(commonHeader, copiedCommonHeader);
commonHeader.setRequestId(requestId);
- assertFalse(commonHeader.equals(copiedCommonHeader));
+ assertNotEquals(commonHeader, copiedCommonHeader);
copiedCommonHeader.setRequestId(requestId);
- assertTrue(commonHeader.equals(copiedCommonHeader));
+ assertEquals(commonHeader, copiedCommonHeader);
commonHeader.setRequestTrack(null);
- assertFalse(commonHeader.equals(copiedCommonHeader));
+ assertNotEquals(commonHeader, copiedCommonHeader);
copiedCommonHeader.setRequestTrack(null);
- assertTrue(commonHeader.equals(copiedCommonHeader));
+ assertEquals(commonHeader, copiedCommonHeader);
commonHeader.setRequestTrack(requestTrackSet);
- assertFalse(commonHeader.equals(copiedCommonHeader));
+ assertNotEquals(commonHeader, copiedCommonHeader);
copiedCommonHeader.setRequestTrack(requestTrackSet);
- assertTrue(commonHeader.equals(copiedCommonHeader));
+ assertEquals(commonHeader, copiedCommonHeader);
commonHeader.setSubRequestId(null);
- assertFalse(commonHeader.equals(copiedCommonHeader));
+ assertNotEquals(commonHeader, copiedCommonHeader);
copiedCommonHeader.setSubRequestId(null);
- assertTrue(commonHeader.equals(copiedCommonHeader));
+ assertEquals(commonHeader, copiedCommonHeader);
commonHeader.setSubRequestId(CAN_I_GO_HOME);
- assertFalse(commonHeader.equals(copiedCommonHeader));
+ assertNotEquals(commonHeader, copiedCommonHeader);
copiedCommonHeader.setSubRequestId(CAN_I_GO_HOME);
- assertTrue(commonHeader.equals(copiedCommonHeader));
+ assertEquals(commonHeader, copiedCommonHeader);
commonHeader.setTimeStamp(null);
- assertFalse(commonHeader.equals(copiedCommonHeader));
+ assertNotEquals(commonHeader, copiedCommonHeader);
copiedCommonHeader.setTimeStamp(null);
- assertTrue(commonHeader.equals(copiedCommonHeader));
+ assertEquals(commonHeader, copiedCommonHeader);
commonHeader.setTimeStamp(timestamp);
- assertFalse(commonHeader.equals(copiedCommonHeader));
+ assertNotEquals(commonHeader, copiedCommonHeader);
copiedCommonHeader.setTimeStamp(timestamp);
- assertTrue(commonHeader.equals(copiedCommonHeader));
+ assertEquals(commonHeader, copiedCommonHeader);
}
}
diff --git a/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java b/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java
index e6fb868b3..7d804c869 100644
--- a/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java
+++ b/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -72,10 +72,13 @@ public class RequestTest {
copiedRequest.setPayload(request.getPayload());
copiedRequest.setTargetId(request.getTargetId());
- assertEquals(request, request);
+ /*
+ * Disabling sonar to test equals().
+ */
+ assertEquals(request, request); // NOSONAR
assertEquals(request, copiedRequest);
- assertNotEquals(null, request);
- assertNotEquals("Hello", request);
+ assertNotEquals(request, null);
+ assertNotEquals(request, "Hello"); // NOSONAR
request.setCommonHeader(null);
assertNotEquals(request, copiedRequest);
diff --git a/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseStatusTest.java b/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseStatusTest.java
index 2541f9b0a..ce8b2148d 100644
--- a/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseStatusTest.java
+++ b/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseStatusTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,10 +22,8 @@
package org.onap.policy.appc;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import org.junit.Test;
@@ -57,36 +55,39 @@ public class ResponseStatusTest {
copiedStatus.setDescription(status.getDescription());
copiedStatus.setValue(status.getValue());
- assertTrue(status.equals(status));
- assertTrue(status.equals(copiedStatus));
- assertFalse(status.equals(null));
- assertFalse(status.equals("Hello"));
+ /*
+ * Disabling sonar to test equals().
+ */
+ assertEquals(status, status); // NOSONAR
+ assertEquals(status, copiedStatus);
+ assertNotEquals(status, null);
+ assertNotEquals(status, "Hello"); // NOSONAR
status.setCode(-1);
- assertFalse(status.equals(copiedStatus));
+ assertNotEquals(status, copiedStatus);
copiedStatus.setCode(-1);
- assertTrue(status.equals(copiedStatus));
+ assertEquals(status, copiedStatus);
status.setCode(1234);
- assertFalse(status.equals(copiedStatus));
+ assertNotEquals(status, copiedStatus);
copiedStatus.setCode(1234);
- assertTrue(status.equals(copiedStatus));
+ assertEquals(status, copiedStatus);
status.setDescription(null);
- assertFalse(status.equals(copiedStatus));
+ assertNotEquals(status, copiedStatus);
copiedStatus.setDescription(null);
- assertTrue(status.equals(copiedStatus));
+ assertEquals(status, copiedStatus);
status.setDescription(THE_WONDERFUL_LAND_OF_OZ);
- assertFalse(status.equals(copiedStatus));
+ assertNotEquals(status, copiedStatus);
copiedStatus.setDescription(THE_WONDERFUL_LAND_OF_OZ);
- assertTrue(status.equals(copiedStatus));
+ assertEquals(status, copiedStatus);
status.setValue(null);
- assertFalse(status.equals(copiedStatus));
+ assertNotEquals(status, copiedStatus);
copiedStatus.setValue(null);
- assertTrue(status.equals(copiedStatus));
+ assertEquals(status, copiedStatus);
status.setValue(THERE_S_NO_PLACE_LIKE_HOME);
- assertFalse(status.equals(copiedStatus));
+ assertNotEquals(status, copiedStatus);
copiedStatus.setValue(THERE_S_NO_PLACE_LIKE_HOME);
- assertTrue(status.equals(copiedStatus));
+ assertEquals(status, copiedStatus);
}
}
diff --git a/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseTest.java b/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseTest.java
index 72c203f98..14e14f0f9 100644
--- a/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseTest.java
+++ b/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,10 +22,8 @@
package org.onap.policy.appc;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import java.util.HashMap;
import java.util.Map;
@@ -69,36 +67,39 @@ public class ResponseTest {
copiedResponse.setStatus(response.getStatus());
copiedResponse.setPayload(response.getPayload());
- assertTrue(response.equals(response));
- assertTrue(response.equals(copiedResponse));
- assertFalse(response.equals(null));
- assertFalse(response.equals("Hello"));
+ /*
+ * Disabling sonar to test equals().
+ */
+ assertEquals(response, response); // NOSONAR
+ assertEquals(response, copiedResponse);
+ assertNotEquals(response, null);
+ assertNotEquals(response, "Hello"); // NOSONAR
response.setCommonHeader(null);
- assertFalse(response.equals(copiedResponse));
+ assertNotEquals(response, copiedResponse);
copiedResponse.setCommonHeader(null);
- assertTrue(response.equals(copiedResponse));
+ assertEquals(response, copiedResponse);
response.setCommonHeader(commonHeader);
- assertFalse(response.equals(copiedResponse));
+ assertNotEquals(response, copiedResponse);
copiedResponse.setCommonHeader(commonHeader);
- assertTrue(response.equals(copiedResponse));
+ assertEquals(response, copiedResponse);
response.setStatus(null);
- assertFalse(response.equals(copiedResponse));
+ assertNotEquals(response, copiedResponse);
copiedResponse.setStatus(null);
- assertTrue(response.equals(copiedResponse));
+ assertEquals(response, copiedResponse);
response.setStatus(status);
- assertFalse(response.equals(copiedResponse));
+ assertNotEquals(response, copiedResponse);
copiedResponse.setStatus(status);
- assertTrue(response.equals(copiedResponse));
+ assertEquals(response, copiedResponse);
response.setPayload(new HashMap<String, Object>());
- assertFalse(response.equals(copiedResponse));
+ assertNotEquals(response, copiedResponse);
copiedResponse.setPayload(new HashMap<String, Object>());
- assertTrue(response.equals(copiedResponse));
+ assertEquals(response, copiedResponse);
response.setPayload(payload);
- assertFalse(response.equals(copiedResponse));
+ assertNotEquals(response, copiedResponse);
copiedResponse.setPayload(payload);
- assertTrue(response.equals(copiedResponse));
+ assertEquals(response, copiedResponse);
}
}