summaryrefslogtreecommitdiffstats
path: root/controlloop/common/model-impl/appclcm/src/test
diff options
context:
space:
mode:
authorLiam Fallon <liam.fallon@ericsson.com>2018-01-17 12:03:50 +0000
committerJorge Hernandez <jh1730@att.com>2018-01-18 19:46:46 +0000
commitbb462937523947c6f0ca622bc0ea3eb505442ad2 (patch)
treefceb4a45cb312f491f812bfd122e57a1b348b443 /controlloop/common/model-impl/appclcm/src/test
parentcebad66213ff84469971b253320f72fa3a41b3cd (diff)
Fix Technical Debt, Unit Test for APPCLCM POJOs
Mainly making fields private, fixing field and methods to follow Java guidelines, and adding getter and setter methods. Unit test added for all classes in org.onap.policy.appclcm Issue-ID: POLICY-455 Change-Id: Iae873f94a236cc9faeac5542a9633ca840b696ed Signed-off-by: Liam Fallon <liam.fallon@ericsson.com>
Diffstat (limited to 'controlloop/common/model-impl/appclcm/src/test')
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java8
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMCommonHeader.java159
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequest.java107
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequestWrapper.java62
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResonseCode.java54
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseStatus.java70
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseWrapper.java61
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMWrapper.java111
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/applcm/util/TestSerialization.java58
9 files changed, 686 insertions, 4 deletions
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java
index 41bafe498..2d58bfd99 100644
--- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java
@@ -140,7 +140,7 @@ public class AppcLcmTest {
/*
* The type of the DMAAP wrapper should be request
*/
- assertEquals(dmaapRequest.getType(), "request");
+ assertEquals("request", dmaapRequest.getType());
/*
* The DMAAP wrapper must have a body as that is
@@ -160,7 +160,7 @@ public class AppcLcmTest {
* set to restart
*/
assertNotNull(appcRequest.getAction());
- assertEquals(appcRequest.getAction(), "restart");
+ assertEquals("restart", appcRequest.getAction());
/*
* The action-identifiers should not be null
@@ -217,7 +217,7 @@ public class AppcLcmTest {
/*
* The type of the DMAAP wrapper should be response
*/
- assertEquals(dmaapResponse.getType(), "response");
+ assertEquals("response", dmaapResponse.getType());
/*
* The DMAAP wrapper must have a body as that is
@@ -237,7 +237,7 @@ public class AppcLcmTest {
* status code should be 400
*/
assertNotNull(appcResponse.getStatus());
- assertEquals(appcResponse.getStatus().getCode(), 400);
+ assertEquals(400, appcResponse.getStatus().getCode());
logger.debug("Response as a Java Object: \n" + appcResponse.toString() + "\n\n");
}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMCommonHeader.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMCommonHeader.java
new file mode 100644
index 000000000..6921068e5
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMCommonHeader.java
@@ -0,0 +1,159 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.appclcm;
+
+import static org.junit.Assert.*;
+
+import java.time.Instant;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import org.junit.Test;
+
+public class TestLCMCommonHeader {
+
+ @Test
+ public void testLCMLCMCommonHeader() {
+ LCMCommonHeader commonHeader = new LCMCommonHeader();
+ assertNotNull(commonHeader);
+ assertNotNull(new LCMCommonHeader(commonHeader));
+ assertNotEquals(0, commonHeader.hashCode());
+
+ 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());
+
+ UUID requestId = UUID.randomUUID();
+ commonHeader.setRequestId(requestId);
+ assertEquals(requestId, commonHeader.getRequestId());
+
+ commonHeader.setSubRequestId("Can I go home?");
+ assertEquals("Can I go home?", commonHeader.getSubRequestId());
+
+ Instant timestamp = Instant.now();
+ commonHeader.setTimeStamp(timestamp);
+ assertEquals(timestamp, commonHeader.getTimeStamp());
+
+ assertNotEquals(0, commonHeader.hashCode());
+
+ assertEquals("CommonHeader [timeStamp=", commonHeader.toString().substring(0, 24));
+
+ LCMCommonHeader copiedLCMCommonHeader = new LCMCommonHeader();
+ copiedLCMCommonHeader.setApiVer(commonHeader.getApiVer());
+ copiedLCMCommonHeader.setFlags(commonHeader.getFlags());
+ copiedLCMCommonHeader.setOriginatorId(commonHeader.getOriginatorId());
+ copiedLCMCommonHeader.setRequestId(commonHeader.getRequestId());
+ copiedLCMCommonHeader.setSubRequestId(commonHeader.getSubRequestId());
+ copiedLCMCommonHeader.setTimeStamp(commonHeader.getTimeStamp());
+
+ assertTrue(commonHeader.equals(commonHeader));
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+ assertFalse(commonHeader.equals(null));
+ assertFalse(commonHeader.equals("Hello"));
+
+ LCMCommonHeader clonedLCMCommonHeader = new LCMCommonHeader(commonHeader);
+ clonedLCMCommonHeader.setApiVer(commonHeader.getApiVer());
+ clonedLCMCommonHeader.setTimeStamp(commonHeader.getTimeStamp());
+
+ assertTrue(commonHeader.equals(clonedLCMCommonHeader));
+
+ commonHeader.setApiVer(null);
+ assertFalse(commonHeader.equals(copiedLCMCommonHeader));
+ copiedLCMCommonHeader.setApiVer(null);
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+ commonHeader.setApiVer("Kansas");
+ assertFalse(commonHeader.equals(copiedLCMCommonHeader));
+ copiedLCMCommonHeader.setApiVer("Kansas");
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+
+ commonHeader.setFlags(null);
+ assertFalse(commonHeader.equals(copiedLCMCommonHeader));
+ copiedLCMCommonHeader.setFlags(null);
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+ commonHeader.setFlags(flagMap);
+ assertFalse(commonHeader.equals(copiedLCMCommonHeader));
+ copiedLCMCommonHeader.setFlags(flagMap);
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+
+ commonHeader.setOriginatorId(null);
+ assertFalse(commonHeader.equals(copiedLCMCommonHeader));
+ copiedLCMCommonHeader.setOriginatorId(null);
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+ commonHeader.setOriginatorId("Dorothy");
+ assertFalse(commonHeader.equals(copiedLCMCommonHeader));
+ copiedLCMCommonHeader.setOriginatorId("Dorothy");
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+
+ commonHeader.setRequestId(null);
+ assertFalse(commonHeader.equals(copiedLCMCommonHeader));
+ copiedLCMCommonHeader.setRequestId(null);
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+ commonHeader.setRequestId(requestId);
+ assertFalse(commonHeader.equals(copiedLCMCommonHeader));
+ copiedLCMCommonHeader.setRequestId(requestId);
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+
+ commonHeader.setSubRequestId(null);
+ assertFalse(commonHeader.equals(copiedLCMCommonHeader));
+ copiedLCMCommonHeader.setSubRequestId(null);
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+ commonHeader.setSubRequestId("Can I go home?");
+ assertFalse(commonHeader.equals(copiedLCMCommonHeader));
+ copiedLCMCommonHeader.setSubRequestId("Can I go home?");
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+
+ commonHeader.setTimeStamp(null);
+ assertFalse(commonHeader.equals(copiedLCMCommonHeader));
+ copiedLCMCommonHeader.setTimeStamp(null);
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+ commonHeader.setTimeStamp(timestamp);
+ assertFalse(commonHeader.equals(copiedLCMCommonHeader));
+ copiedLCMCommonHeader.setTimeStamp(timestamp);
+ assertTrue(commonHeader.equals(copiedLCMCommonHeader));
+ }
+}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequest.java
new file mode 100644
index 000000000..223e50147
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequest.java
@@ -0,0 +1,107 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.appclcm;
+
+import static org.junit.Assert.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+
+public class TestLCMRequest {
+
+ @Test
+ public void testLCMRequest() {
+ LCMRequest request = new LCMRequest();
+ assertNotNull(request);
+ assertNotEquals(0, request.hashCode());
+
+ LCMCommonHeader commonHeader = new LCMCommonHeader();
+
+ request.setCommonHeader(commonHeader);
+ assertEquals(commonHeader, request.getCommonHeader());
+
+ request.setAction("Go to Oz");
+ assertEquals("Go to Oz", request.getAction());
+
+ Map<String, String> actionIdentifiers = new HashMap<>();
+ actionIdentifiers.put("North", "Good Witch");
+ actionIdentifiers.put("West", "Bad Witch");
+
+ request.setActionIdentifiers(actionIdentifiers);
+ assertEquals(actionIdentifiers, request.getActionIdentifiers());
+
+ request.setPayload("The Emerald City");
+ assertEquals("The Emerald City", request.getPayload());
+
+ assertNotEquals(0, request.hashCode());
+
+ assertEquals("Request [commonHeader=CommonHeader [timeStamp=", request.toString().substring(0, 46));
+
+ LCMRequest copiedLCMRequest = new LCMRequest();
+ copiedLCMRequest.setCommonHeader(request.getCommonHeader());
+ copiedLCMRequest.setAction(request.getAction());
+ copiedLCMRequest.setActionIdentifiers(request.getActionIdentifiers());
+ copiedLCMRequest.setPayload(request.getPayload());
+
+ assertTrue(request.equals(request));
+ assertTrue(request.equals(copiedLCMRequest));
+ assertFalse(request.equals(null));
+ assertFalse(request.equals("Hello"));
+
+ request.setCommonHeader(null);
+ assertFalse(request.equals(copiedLCMRequest));
+ copiedLCMRequest.setCommonHeader(null);
+ assertTrue(request.equals(copiedLCMRequest));
+ request.setCommonHeader(commonHeader);
+ assertFalse(request.equals(copiedLCMRequest));
+ copiedLCMRequest.setCommonHeader(commonHeader);
+ assertTrue(request.equals(copiedLCMRequest));
+
+ request.setAction(null);
+ assertFalse(request.equals(copiedLCMRequest));
+ copiedLCMRequest.setAction(null);
+ assertTrue(request.equals(copiedLCMRequest));
+ request.setAction("Go to Oz");
+ assertFalse(request.equals(copiedLCMRequest));
+ copiedLCMRequest.setAction("Go to Oz");
+ assertTrue(request.equals(copiedLCMRequest));
+
+ request.setActionIdentifiers(null);
+ assertFalse(request.equals(copiedLCMRequest));
+ copiedLCMRequest.setActionIdentifiers(null);
+ assertTrue(request.equals(copiedLCMRequest));
+ request.setActionIdentifiers(actionIdentifiers);
+ assertFalse(request.equals(copiedLCMRequest));
+ copiedLCMRequest.setActionIdentifiers(actionIdentifiers);
+ assertTrue(request.equals(copiedLCMRequest));
+
+ request.setPayload(null);
+ assertFalse(request.equals(copiedLCMRequest));
+ copiedLCMRequest.setPayload(null);
+ assertTrue(request.equals(copiedLCMRequest));
+ request.setPayload("The Emerald City");
+ assertFalse(request.equals(copiedLCMRequest));
+ copiedLCMRequest.setPayload("The Emerald City");
+ assertTrue(request.equals(copiedLCMRequest));
+ }
+}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequestWrapper.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequestWrapper.java
new file mode 100644
index 000000000..0a5205509
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequestWrapper.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.appclcm;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class TestLCMRequestWrapper {
+
+ @Test
+ public void testLCMRequestWrapperWrapper() {
+ assertNotNull(new LCMRequestWrapper(new LCMRequest()));
+ LCMRequestWrapper requestWrapper = new LCMRequestWrapper();
+ assertNotNull(requestWrapper);
+ assertNotEquals(0, requestWrapper.hashCode());
+
+ LCMRequest request = new LCMRequest();
+
+ requestWrapper.setBody(request);
+ assertEquals(request, requestWrapper.getBody());
+
+ assertNotEquals(0, requestWrapper.hashCode());
+
+ assertEquals("RequestWrapper [body=Request [commonHeader=nul", requestWrapper.toString().substring(0, 46));
+
+ LCMRequestWrapper copiedLCMRequestWrapper = new LCMRequestWrapper();
+ copiedLCMRequestWrapper.setBody(requestWrapper.getBody());
+
+ assertTrue(requestWrapper.equals(requestWrapper));
+ assertTrue(requestWrapper.equals(copiedLCMRequestWrapper));
+ assertFalse(requestWrapper.equals(null));
+ assertFalse(requestWrapper.equals("Hello"));
+
+ requestWrapper.setBody(null);
+ assertFalse(requestWrapper.equals(copiedLCMRequestWrapper));
+ copiedLCMRequestWrapper.setBody(null);
+ assertTrue(requestWrapper.equals(copiedLCMRequestWrapper));
+ requestWrapper.setBody(request);
+ assertFalse(requestWrapper.equals(copiedLCMRequestWrapper));
+ copiedLCMRequestWrapper.setBody(request);
+ assertTrue(requestWrapper.equals(copiedLCMRequestWrapper));
+ }
+}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResonseCode.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResonseCode.java
new file mode 100644
index 000000000..59606f8b4
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResonseCode.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.appclcm;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class TestLCMResonseCode {
+
+ @Test
+ public void testLCMResponseCode() {
+ assertNull(LCMResponseCode.toResponseValue(0));
+
+ assertEquals(LCMResponseCode.ACCEPTED, LCMResponseCode.toResponseValue(100));
+ assertEquals(LCMResponseCode.ERROR, LCMResponseCode.toResponseValue(200));
+ assertEquals(LCMResponseCode.REJECT, LCMResponseCode.toResponseValue(300));
+ assertEquals(LCMResponseCode.SUCCESS, LCMResponseCode.toResponseValue(400));
+ assertEquals(LCMResponseCode.FAILURE, LCMResponseCode.toResponseValue(450));
+ assertEquals(LCMResponseCode.FAILURE, LCMResponseCode.toResponseValue(401));
+ assertEquals(LCMResponseCode.FAILURE, LCMResponseCode.toResponseValue(406));
+ assertEquals(LCMResponseCode.PARTIAL_SUCCESS, LCMResponseCode.toResponseValue(500));
+ assertEquals(LCMResponseCode.PARTIAL_FAILURE, LCMResponseCode.toResponseValue(501));
+ assertEquals(LCMResponseCode.PARTIAL_FAILURE, LCMResponseCode.toResponseValue(599));
+
+ assertEquals("100", new LCMResponseCode(100).toString());
+ assertEquals("200", new LCMResponseCode(200).toString());
+ assertEquals("300", new LCMResponseCode(300).toString());
+ assertEquals("400", new LCMResponseCode(400).toString());
+ assertEquals("450", new LCMResponseCode(450).toString());
+ assertEquals("500", new LCMResponseCode(500).toString());
+ assertEquals("510", new LCMResponseCode(510).toString());
+
+ assertEquals(300, new LCMResponseCode(300).getCode());
+ }
+}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseStatus.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseStatus.java
new file mode 100644
index 000000000..0b6cbcf22
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseStatus.java
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.appclcm;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class TestLCMResponseStatus {
+
+ @Test
+ public void testResonseStatus() {
+ LCMResponseStatus status = new LCMResponseStatus();
+ assertNotNull(status);
+ assertNotEquals(0, status.hashCode());
+
+ status.setCode(1234);
+ assertEquals(1234, status.getCode());
+
+ 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));
+
+ LCMResponseStatus copiedStatus = new LCMResponseStatus();
+ copiedStatus.setCode(status.getCode());
+ copiedStatus.setMessage(status.getMessage());
+
+ assertTrue(status.equals(status));
+ assertTrue(status.equals(copiedStatus));
+ assertFalse(status.equals(null));
+ assertFalse(status.equals("Hello"));
+
+ status.setCode(-1);
+ assertFalse(status.equals(copiedStatus));
+ copiedStatus.setCode(-1);
+ assertTrue(status.equals(copiedStatus));
+ status.setCode(1234);
+ assertFalse(status.equals(copiedStatus));
+ copiedStatus.setCode(1234);
+ assertTrue(status.equals(copiedStatus));
+
+ status.setMessage(null);
+ assertFalse(status.equals(copiedStatus));
+ copiedStatus.setMessage(null);
+ assertTrue(status.equals(copiedStatus));
+ status.setMessage("The wonderful land of Oz");
+ assertFalse(status.equals(copiedStatus));
+ copiedStatus.setMessage("The wonderful land of Oz");
+ assertTrue(status.equals(copiedStatus));
+ }
+}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseWrapper.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseWrapper.java
new file mode 100644
index 000000000..d27fbaff3
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseWrapper.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.appclcm;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class TestLCMResponseWrapper {
+
+ @Test
+ public void testLCMResponseWrapperWrapper() {
+ LCMResponseWrapper responseWrapper = new LCMResponseWrapper();
+ assertNotNull(responseWrapper);
+ assertNotEquals(0, responseWrapper.hashCode());
+
+ LCMResponse response = new LCMResponse();
+
+ responseWrapper.setBody(response);
+ assertEquals(response, responseWrapper.getBody());
+
+ assertNotEquals(0, responseWrapper.hashCode());
+
+ assertEquals("ResponseWrapper [body=Response [commonHeader=n", responseWrapper.toString().substring(0, 46));
+
+ LCMResponseWrapper copiedLCMResponseWrapper = new LCMResponseWrapper();
+ copiedLCMResponseWrapper.setBody(responseWrapper.getBody());
+
+ assertTrue(responseWrapper.equals(responseWrapper));
+ assertTrue(responseWrapper.equals(copiedLCMResponseWrapper));
+ assertFalse(responseWrapper.equals(null));
+ assertFalse(responseWrapper.equals("Hello"));
+
+ responseWrapper.setBody(null);
+ assertFalse(responseWrapper.equals(copiedLCMResponseWrapper));
+ copiedLCMResponseWrapper.setBody(null);
+ assertTrue(responseWrapper.equals(copiedLCMResponseWrapper));
+ responseWrapper.setBody(response);
+ assertFalse(responseWrapper.equals(copiedLCMResponseWrapper));
+ copiedLCMResponseWrapper.setBody(response);
+ assertTrue(responseWrapper.equals(copiedLCMResponseWrapper));
+ }
+}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMWrapper.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMWrapper.java
new file mode 100644
index 000000000..20baf154d
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMWrapper.java
@@ -0,0 +1,111 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.appclcm;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class TestLCMWrapper {
+
+ @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.setCambriaPartition("The Emerald City");
+ assertEquals("The Emerald City", wrapper.getCambriaPartition());
+
+ wrapper.setRpcName("Tornado");
+ assertEquals("Tornado", wrapper.getRpcName());
+
+ wrapper.setCorrelationId("YellowBrickRoad");
+ assertEquals("YellowBrickRoad", wrapper.getCorrelationId());
+
+ wrapper.setType("Munchkin");
+ assertEquals("Munchkin", wrapper.getType());
+
+ assertNotEquals(0, wrapper.hashCode());
+
+ assertEquals("Wrapper [version=19.3.9, cambriaPartition=The ", wrapper.toString().substring(0, 46));
+
+ LCMWrapper copiedLCMWrapper = new LCMWrapper();
+ copiedLCMWrapper.setVersion(wrapper.getVersion());
+ copiedLCMWrapper.setCambriaPartition(wrapper.getCambriaPartition());
+ copiedLCMWrapper.setRpcName(wrapper.getRpcName());
+ copiedLCMWrapper.setCorrelationId(wrapper.getCorrelationId());
+ copiedLCMWrapper.setType(wrapper.getType());
+
+ assertTrue(wrapper.equals(wrapper));
+ assertTrue(wrapper.equals(copiedLCMWrapper));
+ assertFalse(wrapper.equals(null));
+ assertFalse(wrapper.equals("Hello"));
+
+ wrapper.setVersion(null);
+ assertFalse(wrapper.equals(copiedLCMWrapper));
+ copiedLCMWrapper.setVersion(null);
+ assertTrue(wrapper.equals(copiedLCMWrapper));
+ wrapper.setVersion("19.3.9");
+ assertFalse(wrapper.equals(copiedLCMWrapper));
+ copiedLCMWrapper.setVersion("19.3.9");
+ assertTrue(wrapper.equals(copiedLCMWrapper));
+
+ wrapper.setCambriaPartition(null);
+ assertFalse(wrapper.equals(copiedLCMWrapper));
+ copiedLCMWrapper.setCambriaPartition(null);
+ assertTrue(wrapper.equals(copiedLCMWrapper));
+ wrapper.setCambriaPartition("The Emerald City");
+ assertFalse(wrapper.equals(copiedLCMWrapper));
+ 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");
+ assertFalse(wrapper.equals(copiedLCMWrapper));
+ copiedLCMWrapper.setRpcName("Tornado");
+ assertTrue(wrapper.equals(copiedLCMWrapper));
+
+ wrapper.setCorrelationId(null);
+ assertFalse(wrapper.equals(copiedLCMWrapper));
+ copiedLCMWrapper.setCorrelationId(null);
+ assertTrue(wrapper.equals(copiedLCMWrapper));
+ wrapper.setCorrelationId("YellowBrickRoad");
+ assertFalse(wrapper.equals(copiedLCMWrapper));
+ copiedLCMWrapper.setCorrelationId("YellowBrickRoad");
+ assertTrue(wrapper.equals(copiedLCMWrapper));
+
+ wrapper.setType(null);
+ assertFalse(wrapper.equals(copiedLCMWrapper));
+ copiedLCMWrapper.setType(null);
+ assertTrue(wrapper.equals(copiedLCMWrapper));
+ wrapper.setType("Munchkin");
+ assertFalse(wrapper.equals(copiedLCMWrapper));
+ copiedLCMWrapper.setType("Munchkin");
+ assertTrue(wrapper.equals(copiedLCMWrapper));
+ }
+}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/applcm/util/TestSerialization.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/applcm/util/TestSerialization.java
new file mode 100644
index 000000000..c7167f509
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/applcm/util/TestSerialization.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.applcm.util;
+
+import static org.junit.Assert.*;
+
+import java.time.Instant;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+
+import org.junit.Test;
+import org.onap.policy.appclcm.util.Serialization;
+
+public class TestSerialization {
+
+ @Test
+ public void test() {
+ String nameString = "Dorothy";
+ String jsonName = Serialization.gsonPretty.toJson(nameString, String.class);
+ assertEquals("\"Dorothy\"", jsonName);
+ String jsonInOutName = Serialization.gsonPretty.fromJson(jsonName, String.class);
+ assertEquals("Dorothy", jsonInOutName);
+
+ Instant instant0 = Instant.ofEpochMilli(1516127215000L);
+ String instantString0 = Serialization.gsonPretty.toJson(instant0, Instant.class);
+ assertEquals("\"2018-01-16T18:26:55Z\"", instantString0);
+ Instant outInstant0 = Serialization.gsonPretty.fromJson(instantString0, Instant.class);
+ assertEquals(instant0, outInstant0);
+
+ Instant instant1 = Instant.ofEpochMilli(1516127215000L);
+ String instantString1 = Serialization.gsonJunit.toJson(instant1, Instant.class);
+ assertEquals("1516127215000", instantString1);
+ Instant outInstant1 = Serialization.gsonJunit.fromJson(instantString1, Instant.class);
+ assertEquals(instant1, outInstant1);
+
+ ZonedDateTime zdt = ZonedDateTime.ofInstant(instant0, ZoneId.of("UTC"));
+ String zdtString = Serialization.gsonPretty.toJson(zdt, ZonedDateTime.class);
+ assertEquals("{\n \"dateTime\": {\n \"date\":", zdtString.substring(0, 29));
+ }
+}