diff options
author | Jim Hahn <jrh3@att.com> | 2019-05-08 14:33:57 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2019-05-08 16:24:35 -0400 |
commit | 10b21aae2bde224ab7f91f4b5ab1b89369c8fd1c (patch) | |
tree | 0417099e379e8be69f90221e8fd066fc40def62b /controlloop/common/model-impl/appclcm/src/test/java | |
parent | 01841878936986bc80a974977ccdeaceaf7f9a78 (diff) |
Add payload to vFW policy yaml
Added new "streams" payload to vFW policy yaml files.
Removed references to pg-streams.
Also deleted directories that were moved to policy/models.
Also removed references to trafficgenerator.
Updated licenses.
Removed some trailing whitespace.
Change-Id: I6becaa573628eee677f0959fadf86f9a9f032f88
Issue-ID: POLICY-1752
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'controlloop/common/model-impl/appclcm/src/test/java')
10 files changed, 0 insertions, 1031 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 deleted file mode 100644 index cee87077a..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java +++ /dev/null @@ -1,232 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appclcm - * ================================================================================ - * Copyright (C) 2017-2018 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.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.HashMap; -import java.util.UUID; - -import org.junit.Test; -import org.onap.policy.appclcm.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AppcLcmTest { - - private static final Logger logger = LoggerFactory.getLogger(AppcLcmTest.class); - - private static LcmRequestWrapper dmaapRequest; - private static LcmResponseWrapper dmaapResponse; - - static { - /* - * Construct an APPCLCM Request to be Serialized - */ - dmaapRequest = new LcmRequestWrapper(); - dmaapRequest.setCorrelationId("664be3d2-6c12-4f4b-a3e7-c349acced200" + "-" + "1"); - dmaapRequest.setRpcName("restart"); - dmaapRequest.setType("request"); - - dmaapResponse = new LcmResponseWrapper(); - dmaapResponse.setCorrelationId("664be3d2-6c12-4f4b-a3e7-c349acced200" + "-" + "1"); - dmaapResponse.setRpcName("restart"); - dmaapResponse.setType("response"); - - LcmRequest appcRequest = new LcmRequest(); - - appcRequest.setAction("restart"); - - HashMap<String, String> actionIdentifiers = new HashMap<>(); - actionIdentifiers.put("vnf-id", "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.setSubRequestId("1"); - commonHeader.setOriginatorId("664be3d2-6c12-4f4b-a3e7-c349acced200"); - - appcRequest.setCommonHeader(commonHeader); - - appcRequest.setPayload(null); - - dmaapRequest.setBody(appcRequest); - - /* - * Construct an APPCLCM Response to be Serialized - */ - LcmResponse appcResponse = new LcmResponse(appcRequest); - appcResponse.getStatus().setCode(400); - appcResponse.getStatus().setMessage("Restart Successful"); - appcResponse.setPayload(null); - - dmaapResponse.setBody(appcResponse); - } - - @Test - public void testRequestSerialization() { - - /* - * Use the gson serializer to obtain json - */ - String jsonRequest = Serialization.gson.toJson(dmaapRequest, LcmRequestWrapper.class); - assertNotNull(jsonRequest); - - /* - * The serializer should have added an extra sub-tag called "input" that wraps the request - */ - assertTrue(jsonRequest.contains("input")); - - /* - * The common-header, request-id, and sub-request-id should exist - */ - assertTrue(jsonRequest.contains("common-header")); - assertTrue(jsonRequest.contains("request-id")); - assertTrue(jsonRequest.contains("sub-request-id")); - - /* - * action-identifiers should exist and contain a vnf-id - */ - assertTrue(jsonRequest.contains("action-identifiers")); - assertTrue(jsonRequest.contains("vnf-id")); - - /* - * The action sub-tag should exist - */ - assertTrue(jsonRequest.contains("action")); - - logger.debug("Request as JSON: " + jsonRequest + "\n\n"); - } - - @Test - public void testRequestDeserialization() { - - /* - * Convert the LCM request object into json so we have a string of json to use for testing - */ - String jsonRequest = Serialization.gson.toJson(dmaapRequest, LcmRequestWrapper.class); - - /* - * Use the serializer to convert the json string into a java object - */ - LcmRequestWrapper dmaapRequest = Serialization.gson.fromJson(jsonRequest, LcmRequestWrapper.class); - assertNotNull(dmaapRequest); - - /* - * The type of the DMAAP wrapper should be request - */ - assertEquals("request", dmaapRequest.getType()); - - /* - * The DMAAP wrapper must have a body as that is the true APPC request - */ - assertNotNull(dmaapRequest.getBody()); - LcmRequest appcRequest = dmaapRequest.getBody(); - assertNotNull(appcRequest); - - /* - * The common header should not be null - */ - assertNotNull(appcRequest.getCommonHeader()); - - /* - * The action should not be null and should be set to restart - */ - assertNotNull(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")); - - logger.debug("Request as a Java Object: \n" + appcRequest.toString() + "\n\n"); - } - - @Test - public void testResponseSerialization() { - - /* - * Use the serializer to convert the object into json - */ - String jsonResponse = Serialization.gson.toJson(dmaapResponse, LcmResponseWrapper.class); - assertNotNull(jsonResponse); - - /* - * The serializer should have added an extra sub-tag called "input" that wraps the request - */ - assertTrue(jsonResponse.contains("output")); - - /* - * The response should contain a common-header, request-id, sub-request-id, and status - */ - assertTrue(jsonResponse.contains("common-header")); - assertTrue(jsonResponse.contains("request-id")); - assertTrue(jsonResponse.contains("sub-request-id")); - assertTrue(jsonResponse.contains("status")); - - logger.debug("Response as JSON: " + jsonResponse + "\n\n"); - } - - @Test - public void testResponseDeserialization() { - /* - * Convert the LCM response object into json so we have a string of json to use for testing - */ - String jsonResponse = Serialization.gson.toJson(dmaapResponse, LcmResponseWrapper.class); - - /* - * Use the serializer to convert the json string into a java object - */ - LcmResponseWrapper dmaapResponse = Serialization.gson.fromJson(jsonResponse, LcmResponseWrapper.class); - assertNotNull(dmaapResponse); - - /* - * The type of the DMAAP wrapper should be response - */ - assertEquals("response", dmaapResponse.getType()); - - /* - * The DMAAP wrapper must have a body as that is the true APPC response - */ - assertNotNull(dmaapResponse.getBody()); - LcmResponse appcResponse = dmaapResponse.getBody(); - assertNotNull(appcResponse); - - /* - * The common header should not be null - */ - assertNotNull(appcResponse.getCommonHeader()); - - /* - * The status should not be null and the status code should be 400 - */ - assertNotNull(appcResponse.getStatus()); - 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/LcmCommonHeaderTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmCommonHeaderTest.java deleted file mode 100644 index d48771a5c..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmCommonHeaderTest.java +++ /dev/null @@ -1,143 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 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.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.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.junit.Test; - -public class LcmCommonHeaderTest { - - @Test - public void testLcmCommonHeader() { - 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/LcmRequestTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestTest.java deleted file mode 100644 index 5cc817d5e..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 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.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; - -import org.junit.Test; - -public class LcmRequestTest { - - @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/LcmRequestWrapperTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestWrapperTest.java deleted file mode 100644 index 42bb91876..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestWrapperTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 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.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; - -public class LcmRequestWrapperTest { - - @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/LcmResonseCodeTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResonseCodeTest.java deleted file mode 100644 index b83fc8d79..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResonseCodeTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 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.assertEquals; -import static org.junit.Assert.assertNull; - -import org.junit.Test; - -public class LcmResonseCodeTest { - - @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/LcmResponseStatusTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseStatusTest.java deleted file mode 100644 index c1a78e10a..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseStatusTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 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.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; - -public class LcmResponseStatusTest { - - @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/LcmResponseTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseTest.java deleted file mode 100644 index 7583ee0c4..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseTest.java +++ /dev/null @@ -1,113 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appclcm - * ================================================================================ - * Copyright (C) 2017-2018 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.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class LcmResponseTest { - - private static final String PAYLOAD = "payload"; - - @Test - public void testHashCode() { - LcmResponse response = new LcmResponse(); - assertTrue(response.hashCode() != 0); - response.setCommonHeader(new LcmCommonHeader()); - assertTrue(response.hashCode() != 0); - response.setPayload(PAYLOAD); - assertTrue(response.hashCode() != 0); - response.setStatus(null); - assertTrue(response.hashCode() != 0); - } - - @Test - public void testLcmResponse() { - LcmResponse response = new LcmResponse(); - assertNull(response.getCommonHeader()); - assertNull(response.getPayload()); - assertNotNull(response.getStatus()); - } - - @Test - public void testToString() { - LcmResponse response = new LcmResponse(); - assertFalse(response.toString().isEmpty()); - } - - @Test - public void testEqualsObject() { - LcmResponse response = new LcmResponse(); - assertTrue(response.equals(response)); - assertFalse(response.equals(null)); - assertFalse(response.equals(new Object())); - - LcmResponse response2 = new LcmResponse(); - assertTrue(response.equals(response2)); - - response.setCommonHeader(new LcmCommonHeader()); - assertFalse(response.equals(response2)); - response2.setCommonHeader(response.getCommonHeader()); - assertTrue(response.equals(response2)); - - response.setPayload(PAYLOAD); - assertFalse(response.equals(response2)); - response2.setPayload(response.getPayload()); - assertTrue(response.equals(response2)); - - response.setCommonHeader(null); - assertFalse(response.equals(response2)); - response2.setCommonHeader(null); - assertTrue(response.equals(response2)); - - response.setPayload(null); - assertFalse(response.equals(response2)); - response2.setPayload(response.getPayload()); - assertTrue(response.equals(response2)); - - response.setStatus(null); - assertFalse(response.equals(response2)); - response2.setStatus(response.getStatus()); - assertTrue(response.equals(response2)); - - LcmResponseStatus status = new LcmResponseStatus(); - status.setCode(5); - response.setStatus(status); - response2.setStatus(new LcmResponseStatus()); - assertFalse(response.equals(response2)); - } - - @Test - public void testResponseRequest() { - LcmRequest request = new LcmRequest(); - request.setCommonHeader(new LcmCommonHeader()); - request.setPayload(PAYLOAD); - - LcmResponse response = new LcmResponse(request); - - assertTrue(response.getPayload().equals(PAYLOAD)); - } - -} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseWrapperTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseWrapperTest.java deleted file mode 100644 index 2fc04794e..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseWrapperTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============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.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; - -public class LcmResponseWrapperTest { - - @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/LcmWrapperTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmWrapperTest.java deleted file mode 100644 index a12b7f775..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmWrapperTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/*- - * ============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.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; - -public class LcmWrapperTest { - - @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/appclcm/util/SerializationTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/SerializationTest.java deleted file mode 100644 index 62f98644f..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/SerializationTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============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.util; - -import static org.junit.Assert.assertEquals; - -import java.time.Instant; -import java.time.ZoneId; -import java.time.ZonedDateTime; - -import org.junit.Test; - -public class SerializationTest { - - @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)); - } -} |