summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-impl/appc/src
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-06-13 10:39:55 -0400
committerJim Hahn <jrh3@att.com>2019-06-17 10:50:16 -0400
commitd37c71292d9cbdd892f328d63f49a8027b1f13c4 (patch)
tree615a8af45285d1032a02af1214c76b938c58044d /models-interactions/model-impl/appc/src
parentf59ec395bf1e41df894f884e70ff3185280668c0 (diff)
Fix simple sonar issues in models
Added @FunctionalInterface where needed. Replaced anonymous classes with lambda expressions. Replaced duplicate strings with a constant. Removed unused BeforeClass & AfterClass test methods. Removed some trailing spaces. Fixed: aai actor.appc actor.appclcm actor.sdnc actor.sdnr actor.so actor.vfc actorServiceProvider appc appclcm cds events Change-Id: I0e21cbb10db6d1217bbd0e00e6dd4fac3eb84e31 Issue-ID: POLICY-1791 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.java49
-rw-r--r--models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java19
-rw-r--r--models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseStatusTest.java19
3 files changed, 38 insertions, 49 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 5ff71e03a..ad8fc1f34 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
@@ -19,27 +19,6 @@
* ============LICENSE_END=========================================================
*/
-/*-
- * ============LICENSE_START=======================================================
- * appc
- * ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
package org.onap.policy.appc;
import static org.junit.Assert.assertEquals;
@@ -58,6 +37,10 @@ import org.junit.Test;
public class CommonHeaderTest {
+ private static final String KANSAS = "Kansas";
+ private static final String DOROTHY = "Dorothy";
+ private static final String CAN_I_GO_HOME = "Can I go home?";
+
@Test
public void testCommonHeader() {
CommonHeader commonHeader = new CommonHeader();
@@ -65,15 +48,15 @@ public class CommonHeaderTest {
assertNotNull(new CommonHeader(commonHeader));
assertNotEquals(0, commonHeader.hashCode());
- commonHeader.setApiVer("Kansas");
- assertEquals("Kansas", commonHeader.getApiVer());
+ commonHeader.setApiVer(KANSAS);
+ assertEquals(KANSAS, commonHeader.getApiVer());
List<Map<String, String>> flagSet = new ArrayList<>();
commonHeader.setFlags(flagSet);
assertEquals(flagSet, commonHeader.getFlags());
- commonHeader.setOriginatorId("Dorothy");
- assertEquals("Dorothy", commonHeader.getOriginatorId());
+ commonHeader.setOriginatorId(DOROTHY);
+ assertEquals(DOROTHY, commonHeader.getOriginatorId());
UUID requestId = UUID.randomUUID();
commonHeader.setRequestId(requestId);
@@ -83,8 +66,8 @@ public class CommonHeaderTest {
commonHeader.setRequestTrack(requestTrackSet);
assertEquals(requestTrackSet, commonHeader.getRequestTrack());
- commonHeader.setSubRequestId("Can I go home?");
- assertEquals("Can I go home?", commonHeader.getSubRequestId());
+ commonHeader.setSubRequestId(CAN_I_GO_HOME);
+ assertEquals(CAN_I_GO_HOME, commonHeader.getSubRequestId());
Instant timestamp = Instant.now();
commonHeader.setTimeStamp(timestamp);
@@ -118,9 +101,9 @@ public class CommonHeaderTest {
assertFalse(commonHeader.equals(copiedCommonHeader));
copiedCommonHeader.setApiVer(null);
assertTrue(commonHeader.equals(copiedCommonHeader));
- commonHeader.setApiVer("Kansas");
+ commonHeader.setApiVer(KANSAS);
assertFalse(commonHeader.equals(copiedCommonHeader));
- copiedCommonHeader.setApiVer("Kansas");
+ copiedCommonHeader.setApiVer(KANSAS);
assertTrue(commonHeader.equals(copiedCommonHeader));
commonHeader.setFlags(null);
@@ -136,9 +119,9 @@ public class CommonHeaderTest {
assertFalse(commonHeader.equals(copiedCommonHeader));
copiedCommonHeader.setOriginatorId(null);
assertTrue(commonHeader.equals(copiedCommonHeader));
- commonHeader.setOriginatorId("Dorothy");
+ commonHeader.setOriginatorId(DOROTHY);
assertFalse(commonHeader.equals(copiedCommonHeader));
- copiedCommonHeader.setOriginatorId("Dorothy");
+ copiedCommonHeader.setOriginatorId(DOROTHY);
assertTrue(commonHeader.equals(copiedCommonHeader));
commonHeader.setRequestId(null);
@@ -163,9 +146,9 @@ public class CommonHeaderTest {
assertFalse(commonHeader.equals(copiedCommonHeader));
copiedCommonHeader.setSubRequestId(null);
assertTrue(commonHeader.equals(copiedCommonHeader));
- commonHeader.setSubRequestId("Can I go home?");
+ commonHeader.setSubRequestId(CAN_I_GO_HOME);
assertFalse(commonHeader.equals(copiedCommonHeader));
- copiedCommonHeader.setSubRequestId("Can I go home?");
+ copiedCommonHeader.setSubRequestId(CAN_I_GO_HOME);
assertTrue(commonHeader.equals(copiedCommonHeader));
commonHeader.setTimeStamp(null);
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 0f461d221..560a7d8d5 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
@@ -34,6 +34,9 @@ import org.junit.Test;
public class RequestTest {
+ private static final String WIZARD = "Wizard";
+ private static final String GO_TO_OZ = "Go to Oz";
+
@Test
public void testRequest() {
Request request = new Request();
@@ -45,11 +48,11 @@ public class RequestTest {
request.setCommonHeader(commonHeader);
assertEquals(commonHeader, request.getCommonHeader());
- request.setAction("Go to Oz");
- assertEquals("Go to Oz", request.getAction());
+ request.setAction(GO_TO_OZ);
+ assertEquals(GO_TO_OZ, request.getAction());
- request.setObjectId("Wizard");
- assertEquals("Wizard", request.getObjectId());
+ request.setObjectId(WIZARD);
+ assertEquals(WIZARD, request.getObjectId());
request.setTargetId("Oz");
assertEquals("Oz", request.getTargetId());
@@ -90,18 +93,18 @@ public class RequestTest {
assertFalse(request.equals(copiedRequest));
copiedRequest.setAction(null);
assertTrue(request.equals(copiedRequest));
- request.setAction("Go to Oz");
+ request.setAction(GO_TO_OZ);
assertFalse(request.equals(copiedRequest));
- copiedRequest.setAction("Go to Oz");
+ copiedRequest.setAction(GO_TO_OZ);
assertTrue(request.equals(copiedRequest));
request.setObjectId(null);
assertFalse(request.equals(copiedRequest));
copiedRequest.setObjectId(null);
assertTrue(request.equals(copiedRequest));
- request.setObjectId("Wizard");
+ request.setObjectId(WIZARD);
assertFalse(request.equals(copiedRequest));
- copiedRequest.setObjectId("Wizard");
+ copiedRequest.setObjectId(WIZARD);
assertTrue(request.equals(copiedRequest));
request.setTargetId(null);
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 561c9494b..2541f9b0a 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
@@ -31,6 +31,9 @@ import org.junit.Test;
public class ResponseStatusTest {
+ private static final String THERE_S_NO_PLACE_LIKE_HOME = "There's no place like home";
+ private static final String THE_WONDERFUL_LAND_OF_OZ = "The wonderful land of Oz";
+
@Test
public void testResonseStatus() {
ResponseStatus status = new ResponseStatus();
@@ -40,11 +43,11 @@ public class ResponseStatusTest {
status.setCode(1234);
assertEquals(1234, status.getCode());
- status.setDescription("The wonderful land of Oz");
- assertEquals("The wonderful land of Oz", status.getDescription());
+ status.setDescription(THE_WONDERFUL_LAND_OF_OZ);
+ assertEquals(THE_WONDERFUL_LAND_OF_OZ, status.getDescription());
- status.setValue("There's no place like home");
- assertEquals("There's no place like home", status.getValue());
+ status.setValue(THERE_S_NO_PLACE_LIKE_HOME);
+ assertEquals(THERE_S_NO_PLACE_LIKE_HOME, status.getValue());
assertNotEquals(0, status.hashCode());
assertEquals("ResponseStatus [Code=1234, Value=There's no pla", status.toString().substring(0, 47));
@@ -72,18 +75,18 @@ public class ResponseStatusTest {
assertFalse(status.equals(copiedStatus));
copiedStatus.setDescription(null);
assertTrue(status.equals(copiedStatus));
- status.setDescription("The wonderful land of Oz");
+ status.setDescription(THE_WONDERFUL_LAND_OF_OZ);
assertFalse(status.equals(copiedStatus));
- copiedStatus.setDescription("The wonderful land of Oz");
+ copiedStatus.setDescription(THE_WONDERFUL_LAND_OF_OZ);
assertTrue(status.equals(copiedStatus));
status.setValue(null);
assertFalse(status.equals(copiedStatus));
copiedStatus.setValue(null);
assertTrue(status.equals(copiedStatus));
- status.setValue("There's no place like home");
+ status.setValue(THERE_S_NO_PLACE_LIKE_HOME);
assertFalse(status.equals(copiedStatus));
- copiedStatus.setValue("There's no place like home");
+ copiedStatus.setValue(THERE_S_NO_PLACE_LIKE_HOME);
assertTrue(status.equals(copiedStatus));
}
}