From b078c9d89a9d6c07f7cb6e7196b34caf797138d6 Mon Sep 17 00:00:00 2001 From: Parshad Patel Date: Thu, 15 Nov 2018 11:59:54 +0900 Subject: Rename test classes in drools-applications Make test classes name consistence by putting 'Test' at end as per google java style guide Issue-ID: POLICY-1258 Change-Id: Id79e5d3fe3688f7f2569b7996613595cc6b746e7 Signed-off-by: Parshad Patel --- .../onap/policy/appclcm/LcmCommonHeaderTest.java | 143 +++++++++++++++++++++ .../org/onap/policy/appclcm/LcmRequestTest.java | 111 ++++++++++++++++ .../onap/policy/appclcm/LcmRequestWrapperTest.java | 66 ++++++++++ .../onap/policy/appclcm/LcmResonseCodeTest.java | 55 ++++++++ .../onap/policy/appclcm/LcmResponseStatusTest.java | 74 +++++++++++ .../policy/appclcm/LcmResponseWrapperTest.java | 65 ++++++++++ .../org/onap/policy/appclcm/LcmWrapperTest.java | 115 +++++++++++++++++ .../onap/policy/appclcm/TestLcmCommonHeader.java | 143 --------------------- .../org/onap/policy/appclcm/TestLcmRequest.java | 111 ---------------- .../onap/policy/appclcm/TestLcmRequestWrapper.java | 66 ---------- .../onap/policy/appclcm/TestLcmResonseCode.java | 55 -------- .../onap/policy/appclcm/TestLcmResponseStatus.java | 74 ----------- .../policy/appclcm/TestLcmResponseWrapper.java | 65 ---------- .../org/onap/policy/appclcm/TestLcmWrapper.java | 115 ----------------- .../policy/appclcm/util/SerializationTest.java | 57 ++++++++ .../policy/appclcm/util/TestSerialization.java | 57 -------- 16 files changed, 686 insertions(+), 686 deletions(-) create mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmCommonHeaderTest.java create mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestTest.java create mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestWrapperTest.java create mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResonseCodeTest.java create mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseStatusTest.java create mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseWrapperTest.java create mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmWrapperTest.java delete mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmCommonHeader.java delete mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmRequest.java delete mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmRequestWrapper.java delete mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResonseCode.java delete mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResponseStatus.java delete mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResponseWrapper.java delete mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmWrapper.java create mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/SerializationTest.java delete mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/TestSerialization.java (limited to 'controlloop/common/model-impl/appclcm/src/test') 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 new file mode 100644 index 000000000..d48771a5c --- /dev/null +++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmCommonHeaderTest.java @@ -0,0 +1,143 @@ +/*- + * ============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 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 new file mode 100644 index 000000000..5cc817d5e --- /dev/null +++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestTest.java @@ -0,0 +1,111 @@ +/*- + * ============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 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 new file mode 100644 index 000000000..42bb91876 --- /dev/null +++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestWrapperTest.java @@ -0,0 +1,66 @@ +/*- + * ============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 new file mode 100644 index 000000000..b83fc8d79 --- /dev/null +++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResonseCodeTest.java @@ -0,0 +1,55 @@ +/*- + * ============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 new file mode 100644 index 000000000..c1a78e10a --- /dev/null +++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseStatusTest.java @@ -0,0 +1,74 @@ +/*- + * ============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/LcmResponseWrapperTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseWrapperTest.java new file mode 100644 index 000000000..2fc04794e --- /dev/null +++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseWrapperTest.java @@ -0,0 +1,65 @@ +/*- + * ============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 new file mode 100644 index 000000000..a12b7f775 --- /dev/null +++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmWrapperTest.java @@ -0,0 +1,115 @@ +/*- + * ============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/TestLcmCommonHeader.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmCommonHeader.java deleted file mode 100644 index 49cc7f7de..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmCommonHeader.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 TestLcmCommonHeader { - - @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 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 deleted file mode 100644 index ce8b0415e..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmRequest.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 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 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 deleted file mode 100644 index 0f1b85a33..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmRequestWrapper.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 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 deleted file mode 100644 index cf42845cc..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResonseCode.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 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 deleted file mode 100644 index b5d4cf3a5..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResponseStatus.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 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 deleted file mode 100644 index bf448534f..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResponseWrapper.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 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 deleted file mode 100644 index d14cb4b24..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmWrapper.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 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/appclcm/util/SerializationTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/SerializationTest.java new file mode 100644 index 000000000..62f98644f --- /dev/null +++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/SerializationTest.java @@ -0,0 +1,57 @@ +/*- + * ============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)); + } +} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/TestSerialization.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/TestSerialization.java deleted file mode 100644 index 4e403ecb4..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/TestSerialization.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 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)); - } -} -- cgit 1.2.3-korg