aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-impl/appclcm
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/appclcm
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/appclcm')
-rw-r--r--models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java48
-rw-r--r--models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmCommonHeaderTest.java28
-rw-r--r--models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestTest.java19
-rw-r--r--models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseStatusTest.java10
-rw-r--r--models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmWrapperTest.java46
5 files changed, 86 insertions, 65 deletions
diff --git a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java
index 0ca6239cd..0ee79cf17 100644
--- a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java
+++ b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java
@@ -35,6 +35,12 @@ import org.slf4j.LoggerFactory;
public class AppcLcmTest {
+ private static final String VNF_ID_KEY = "vnf-id";
+
+ private static final String RESTART = "restart";
+
+ private static final String CORRELATION_ID = "664be3d2-6c12-4f4b-a3e7-c349acced200";
+
private static final Logger logger = LoggerFactory.getLogger(AppcLcmTest.class);
private static LcmRequestWrapper dmaapRequest;
@@ -45,29 +51,29 @@ public class AppcLcmTest {
* Construct an APPCLCM Request to be Serialized
*/
dmaapRequest = new LcmRequestWrapper();
- dmaapRequest.setCorrelationId("664be3d2-6c12-4f4b-a3e7-c349acced200" + "-" + "1");
- dmaapRequest.setRpcName("restart");
+ dmaapRequest.setCorrelationId(CORRELATION_ID + "-" + "1");
+ dmaapRequest.setRpcName(RESTART);
dmaapRequest.setType("request");
dmaapResponse = new LcmResponseWrapper();
- dmaapResponse.setCorrelationId("664be3d2-6c12-4f4b-a3e7-c349acced200" + "-" + "1");
- dmaapResponse.setRpcName("restart");
+ dmaapResponse.setCorrelationId(CORRELATION_ID + "-" + "1");
+ dmaapResponse.setRpcName(RESTART);
dmaapResponse.setType("response");
LcmRequest appcRequest = new LcmRequest();
- appcRequest.setAction("restart");
+ appcRequest.setAction(RESTART);
HashMap<String, String> actionIdentifiers = new HashMap<>();
- actionIdentifiers.put("vnf-id", "trial-vnf-003");
+ actionIdentifiers.put(VNF_ID_KEY, "trial-vnf-003");
actionIdentifiers.put("vserver-id", "08f6c1f9-99e7-49f3-a662-c62b9f200d79");
appcRequest.setActionIdentifiers(actionIdentifiers);
LcmCommonHeader commonHeader = new LcmCommonHeader();
- commonHeader.setRequestId(UUID.fromString("664be3d2-6c12-4f4b-a3e7-c349acced200"));
+ commonHeader.setRequestId(UUID.fromString(CORRELATION_ID));
commonHeader.setSubRequestId("1");
- commonHeader.setOriginatorId("664be3d2-6c12-4f4b-a3e7-c349acced200");
+ commonHeader.setOriginatorId(CORRELATION_ID);
appcRequest.setCommonHeader(commonHeader);
@@ -111,7 +117,7 @@ public class AppcLcmTest {
* action-identifiers should exist and contain a vnf-id
*/
assertTrue(jsonRequest.contains("action-identifiers"));
- assertTrue(jsonRequest.contains("vnf-id"));
+ assertTrue(jsonRequest.contains(VNF_ID_KEY));
/*
* The action sub-tag should exist
@@ -132,19 +138,19 @@ public class AppcLcmTest {
/*
* Use the serializer to convert the json string into a java object
*/
- LcmRequestWrapper dmaapRequest = Serialization.gson.fromJson(jsonRequest, LcmRequestWrapper.class);
- assertNotNull(dmaapRequest);
+ LcmRequestWrapper req = Serialization.gson.fromJson(jsonRequest, LcmRequestWrapper.class);
+ assertNotNull(req);
/*
* The type of the DMAAP wrapper should be request
*/
- assertEquals("request", dmaapRequest.getType());
+ assertEquals("request", req.getType());
/*
* The DMAAP wrapper must have a body as that is the true APPC request
*/
- assertNotNull(dmaapRequest.getBody());
- LcmRequest appcRequest = dmaapRequest.getBody();
+ assertNotNull(req.getBody());
+ LcmRequest appcRequest = req.getBody();
assertNotNull(appcRequest);
/*
@@ -156,13 +162,13 @@ public class AppcLcmTest {
* The action should not be null and should be set to restart
*/
assertNotNull(appcRequest.getAction());
- assertEquals("restart", appcRequest.getAction());
+ assertEquals(RESTART, appcRequest.getAction());
/*
* The action-identifiers should not be null and should contain a vnf-id
*/
assertNotNull(appcRequest.getActionIdentifiers());
- assertNotNull(appcRequest.getActionIdentifiers().get("vnf-id"));
+ assertNotNull(appcRequest.getActionIdentifiers().get(VNF_ID_KEY));
logger.debug("Request as a Java Object: \n" + appcRequest.toString() + "\n\n");
}
@@ -202,19 +208,19 @@ public class AppcLcmTest {
/*
* Use the serializer to convert the json string into a java object
*/
- LcmResponseWrapper dmaapResponse = Serialization.gson.fromJson(jsonResponse, LcmResponseWrapper.class);
- assertNotNull(dmaapResponse);
+ LcmResponseWrapper resp = Serialization.gson.fromJson(jsonResponse, LcmResponseWrapper.class);
+ assertNotNull(resp);
/*
* The type of the DMAAP wrapper should be response
*/
- assertEquals("response", dmaapResponse.getType());
+ assertEquals("response", resp.getType());
/*
* The DMAAP wrapper must have a body as that is the true APPC response
*/
- assertNotNull(dmaapResponse.getBody());
- LcmResponse appcResponse = dmaapResponse.getBody();
+ assertNotNull(resp.getBody());
+ LcmResponse appcResponse = resp.getBody();
assertNotNull(appcResponse);
/*
diff --git a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmCommonHeaderTest.java b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmCommonHeaderTest.java
index 7825e7fc1..32a4954c1 100644
--- a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmCommonHeaderTest.java
+++ b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmCommonHeaderTest.java
@@ -36,6 +36,10 @@ import org.junit.Test;
public class LcmCommonHeaderTest {
+ 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 testLcmCommonHeader() {
LcmCommonHeader commonHeader = new LcmCommonHeader();
@@ -43,22 +47,22 @@ public class LcmCommonHeaderTest {
assertNotNull(new LcmCommonHeader(commonHeader));
assertNotEquals(0, commonHeader.hashCode());
- commonHeader.setApiVer("Kansas");
- assertEquals("Kansas", commonHeader.getApiVer());
+ commonHeader.setApiVer(KANSAS);
+ assertEquals(KANSAS, commonHeader.getApiVer());
Map<String, String> flagMap = new HashMap<>();
commonHeader.setFlags(flagMap);
assertEquals(flagMap, commonHeader.getFlags());
- commonHeader.setOriginatorId("Dorothy");
- assertEquals("Dorothy", commonHeader.getOriginatorId());
+ commonHeader.setOriginatorId(DOROTHY);
+ assertEquals(DOROTHY, commonHeader.getOriginatorId());
UUID requestId = UUID.randomUUID();
commonHeader.setRequestId(requestId);
assertEquals(requestId, commonHeader.getRequestId());
- 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);
@@ -91,9 +95,9 @@ public class LcmCommonHeaderTest {
assertFalse(commonHeader.equals(copiedLcmCommonHeader));
copiedLcmCommonHeader.setApiVer(null);
assertTrue(commonHeader.equals(copiedLcmCommonHeader));
- commonHeader.setApiVer("Kansas");
+ commonHeader.setApiVer(KANSAS);
assertFalse(commonHeader.equals(copiedLcmCommonHeader));
- copiedLcmCommonHeader.setApiVer("Kansas");
+ copiedLcmCommonHeader.setApiVer(KANSAS);
assertTrue(commonHeader.equals(copiedLcmCommonHeader));
commonHeader.setFlags(null);
@@ -109,9 +113,9 @@ public class LcmCommonHeaderTest {
assertFalse(commonHeader.equals(copiedLcmCommonHeader));
copiedLcmCommonHeader.setOriginatorId(null);
assertTrue(commonHeader.equals(copiedLcmCommonHeader));
- commonHeader.setOriginatorId("Dorothy");
+ commonHeader.setOriginatorId(DOROTHY);
assertFalse(commonHeader.equals(copiedLcmCommonHeader));
- copiedLcmCommonHeader.setOriginatorId("Dorothy");
+ copiedLcmCommonHeader.setOriginatorId(DOROTHY);
assertTrue(commonHeader.equals(copiedLcmCommonHeader));
commonHeader.setRequestId(null);
@@ -127,9 +131,9 @@ public class LcmCommonHeaderTest {
assertFalse(commonHeader.equals(copiedLcmCommonHeader));
copiedLcmCommonHeader.setSubRequestId(null);
assertTrue(commonHeader.equals(copiedLcmCommonHeader));
- commonHeader.setSubRequestId("Can I go home?");
+ commonHeader.setSubRequestId(CAN_I_GO_HOME);
assertFalse(commonHeader.equals(copiedLcmCommonHeader));
- copiedLcmCommonHeader.setSubRequestId("Can I go home?");
+ copiedLcmCommonHeader.setSubRequestId(CAN_I_GO_HOME);
assertTrue(commonHeader.equals(copiedLcmCommonHeader));
commonHeader.setTimeStamp(null);
diff --git a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestTest.java b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestTest.java
index 4b392f816..40662935d 100644
--- a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestTest.java
+++ b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestTest.java
@@ -34,6 +34,9 @@ import org.junit.Test;
public class LcmRequestTest {
+ private static final String THE_EMERALD_CITY = "The Emerald City";
+ private static final String GO_TO_OZ = "Go to Oz";
+
@Test
public void testLcmRequest() {
LcmRequest request = new LcmRequest();
@@ -45,8 +48,8 @@ public class LcmRequestTest {
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());
Map<String, String> actionIdentifiers = new HashMap<>();
actionIdentifiers.put("North", "Good Witch");
@@ -55,8 +58,8 @@ public class LcmRequestTest {
request.setActionIdentifiers(actionIdentifiers);
assertEquals(actionIdentifiers, request.getActionIdentifiers());
- request.setPayload("The Emerald City");
- assertEquals("The Emerald City", request.getPayload());
+ request.setPayload(THE_EMERALD_CITY);
+ assertEquals(THE_EMERALD_CITY, request.getPayload());
assertNotEquals(0, request.hashCode());
@@ -86,9 +89,9 @@ public class LcmRequestTest {
assertFalse(request.equals(copiedLcmRequest));
copiedLcmRequest.setAction(null);
assertTrue(request.equals(copiedLcmRequest));
- request.setAction("Go to Oz");
+ request.setAction(GO_TO_OZ);
assertFalse(request.equals(copiedLcmRequest));
- copiedLcmRequest.setAction("Go to Oz");
+ copiedLcmRequest.setAction(GO_TO_OZ);
assertTrue(request.equals(copiedLcmRequest));
request.setActionIdentifiers(null);
@@ -104,9 +107,9 @@ public class LcmRequestTest {
assertFalse(request.equals(copiedLcmRequest));
copiedLcmRequest.setPayload(null);
assertTrue(request.equals(copiedLcmRequest));
- request.setPayload("The Emerald City");
+ request.setPayload(THE_EMERALD_CITY);
assertFalse(request.equals(copiedLcmRequest));
- copiedLcmRequest.setPayload("The Emerald City");
+ copiedLcmRequest.setPayload(THE_EMERALD_CITY);
assertTrue(request.equals(copiedLcmRequest));
}
}
diff --git a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseStatusTest.java b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseStatusTest.java
index b022aa1cb..a4d1bc6d1 100644
--- a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseStatusTest.java
+++ b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseStatusTest.java
@@ -31,6 +31,8 @@ import org.junit.Test;
public class LcmResponseStatusTest {
+ private static final String THE_WONDERFUL_LAND_OF_OZ = "The wonderful land of Oz";
+
@Test
public void testResonseStatus() {
LcmResponseStatus status = new LcmResponseStatus();
@@ -40,8 +42,8 @@ public class LcmResponseStatusTest {
status.setCode(1234);
assertEquals(1234, status.getCode());
- status.setMessage("The wonderful land of Oz");
- assertEquals("The wonderful land of Oz", status.getMessage());
+ status.setMessage(THE_WONDERFUL_LAND_OF_OZ);
+ assertEquals(THE_WONDERFUL_LAND_OF_OZ, status.getMessage());
assertEquals("ResponseStatus [code=1234, message=The wonderfu", status.toString().substring(0, 47));
@@ -67,9 +69,9 @@ public class LcmResponseStatusTest {
assertFalse(status.equals(copiedStatus));
copiedStatus.setMessage(null);
assertTrue(status.equals(copiedStatus));
- status.setMessage("The wonderful land of Oz");
+ status.setMessage(THE_WONDERFUL_LAND_OF_OZ);
assertFalse(status.equals(copiedStatus));
- copiedStatus.setMessage("The wonderful land of Oz");
+ copiedStatus.setMessage(THE_WONDERFUL_LAND_OF_OZ);
assertTrue(status.equals(copiedStatus));
}
}
diff --git a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmWrapperTest.java b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmWrapperTest.java
index 18fdc8ca2..7d005cdd4 100644
--- a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmWrapperTest.java
+++ b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmWrapperTest.java
@@ -31,26 +31,32 @@ import org.junit.Test;
public class LcmWrapperTest {
+ private static final String YELLOW_BRICK_ROAD = "YellowBrickRoad";
+ private static final String TORNADO = "Tornado";
+ private static final String THE_EMERALD_CITY = "The Emerald City";
+ private static final String MUNCHKIN = "Munchkin";
+ private static final String VERSION19 = "19.3.9";
+
@Test
public void testLcmWrapper() {
LcmWrapper wrapper = new LcmWrapper();
assertNotNull(wrapper);
assertNotEquals(0, wrapper.hashCode());
- wrapper.setVersion("19.3.9");
- assertEquals("19.3.9", wrapper.getVersion());
+ wrapper.setVersion(VERSION19);
+ assertEquals(VERSION19, wrapper.getVersion());
- wrapper.setCambriaPartition("The Emerald City");
- assertEquals("The Emerald City", wrapper.getCambriaPartition());
+ wrapper.setCambriaPartition(THE_EMERALD_CITY);
+ assertEquals(THE_EMERALD_CITY, wrapper.getCambriaPartition());
- wrapper.setRpcName("Tornado");
- assertEquals("Tornado", wrapper.getRpcName());
+ wrapper.setRpcName(TORNADO);
+ assertEquals(TORNADO, wrapper.getRpcName());
- wrapper.setCorrelationId("YellowBrickRoad");
- assertEquals("YellowBrickRoad", wrapper.getCorrelationId());
+ wrapper.setCorrelationId(YELLOW_BRICK_ROAD);
+ assertEquals(YELLOW_BRICK_ROAD, wrapper.getCorrelationId());
- wrapper.setType("Munchkin");
- assertEquals("Munchkin", wrapper.getType());
+ wrapper.setType(MUNCHKIN);
+ assertEquals(MUNCHKIN, wrapper.getType());
assertNotEquals(0, wrapper.hashCode());
@@ -72,45 +78,45 @@ public class LcmWrapperTest {
assertFalse(wrapper.equals(copiedLcmWrapper));
copiedLcmWrapper.setVersion(null);
assertTrue(wrapper.equals(copiedLcmWrapper));
- wrapper.setVersion("19.3.9");
+ wrapper.setVersion(VERSION19);
assertFalse(wrapper.equals(copiedLcmWrapper));
- copiedLcmWrapper.setVersion("19.3.9");
+ copiedLcmWrapper.setVersion(VERSION19);
assertTrue(wrapper.equals(copiedLcmWrapper));
wrapper.setCambriaPartition(null);
assertFalse(wrapper.equals(copiedLcmWrapper));
copiedLcmWrapper.setCambriaPartition(null);
assertTrue(wrapper.equals(copiedLcmWrapper));
- wrapper.setCambriaPartition("The Emerald City");
+ wrapper.setCambriaPartition(THE_EMERALD_CITY);
assertFalse(wrapper.equals(copiedLcmWrapper));
- copiedLcmWrapper.setCambriaPartition("The Emerald City");
+ copiedLcmWrapper.setCambriaPartition(THE_EMERALD_CITY);
assertTrue(wrapper.equals(copiedLcmWrapper));
wrapper.setRpcName(null);
assertFalse(wrapper.equals(copiedLcmWrapper));
copiedLcmWrapper.setRpcName(null);
assertTrue(wrapper.equals(copiedLcmWrapper));
- wrapper.setRpcName("Tornado");
+ wrapper.setRpcName(TORNADO);
assertFalse(wrapper.equals(copiedLcmWrapper));
- copiedLcmWrapper.setRpcName("Tornado");
+ copiedLcmWrapper.setRpcName(TORNADO);
assertTrue(wrapper.equals(copiedLcmWrapper));
wrapper.setCorrelationId(null);
assertFalse(wrapper.equals(copiedLcmWrapper));
copiedLcmWrapper.setCorrelationId(null);
assertTrue(wrapper.equals(copiedLcmWrapper));
- wrapper.setCorrelationId("YellowBrickRoad");
+ wrapper.setCorrelationId(YELLOW_BRICK_ROAD);
assertFalse(wrapper.equals(copiedLcmWrapper));
- copiedLcmWrapper.setCorrelationId("YellowBrickRoad");
+ copiedLcmWrapper.setCorrelationId(YELLOW_BRICK_ROAD);
assertTrue(wrapper.equals(copiedLcmWrapper));
wrapper.setType(null);
assertFalse(wrapper.equals(copiedLcmWrapper));
copiedLcmWrapper.setType(null);
assertTrue(wrapper.equals(copiedLcmWrapper));
- wrapper.setType("Munchkin");
+ wrapper.setType(MUNCHKIN);
assertFalse(wrapper.equals(copiedLcmWrapper));
- copiedLcmWrapper.setType("Munchkin");
+ copiedLcmWrapper.setType(MUNCHKIN);
assertTrue(wrapper.equals(copiedLcmWrapper));
}
}