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 --- .../org/onap/policy/sdnr/PciCommonHeaderTest.java | 144 +++++++++++++++++++++ .../java/org/onap/policy/sdnr/PciRequestTest.java | 92 +++++++++++++ .../onap/policy/sdnr/PciRequestWrapperTest.java | 66 ++++++++++ .../org/onap/policy/sdnr/PciResponseCodeTest.java | 55 ++++++++ .../onap/policy/sdnr/PciResponseWrapperTest.java | 66 ++++++++++ .../java/org/onap/policy/sdnr/PciStatusTest.java | 74 +++++++++++ .../java/org/onap/policy/sdnr/PciWrapperTest.java | 115 ++++++++++++++++ .../org/onap/policy/sdnr/TestPciCommonHeader.java | 144 --------------------- .../java/org/onap/policy/sdnr/TestPciRequest.java | 92 ------------- .../onap/policy/sdnr/TestPciRequestWrapper.java | 66 ---------- .../org/onap/policy/sdnr/TestPciResponseCode.java | 55 -------- .../onap/policy/sdnr/TestPciResponseWrapper.java | 66 ---------- .../java/org/onap/policy/sdnr/TestPciStatus.java | 74 ----------- .../java/org/onap/policy/sdnr/TestPciWrapper.java | 115 ---------------- .../onap/policy/sdnr/util/SerializationTest.java | 57 ++++++++ .../onap/policy/sdnr/util/TestSerialization.java | 57 -------- 16 files changed, 669 insertions(+), 669 deletions(-) create mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java create mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestTest.java create mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestWrapperTest.java create mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseCodeTest.java create mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseWrapperTest.java create mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciStatusTest.java create mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java delete mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciCommonHeader.java delete mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciRequest.java delete mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciRequestWrapper.java delete mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciResponseCode.java delete mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciResponseWrapper.java delete mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciStatus.java delete mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciWrapper.java create mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/util/SerializationTest.java delete mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/util/TestSerialization.java (limited to 'controlloop/common/model-impl/sdnr') diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java new file mode 100644 index 000000000..4b3201440 --- /dev/null +++ b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java @@ -0,0 +1,144 @@ +/*- + * ============LICENSE_START======================================================= + * sdnr + * ================================================================================ + * Copyright (C) 2018 Wipro Limited 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.sdnr; + +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 PciCommonHeaderTest { + + @Test + public void testPciCommonHeader() { + PciCommonHeader commonHeader = new PciCommonHeader(); + assertNotNull(commonHeader); + assertNotNull(new PciCommonHeader(commonHeader)); + assertNotEquals(0, commonHeader.hashCode()); + + commonHeader.setApiVer("Kansas"); + assertEquals("Kansas", commonHeader.getApiVer()); + + Map flagMap = new HashMap<>(); + commonHeader.setFlags(flagMap); + assertEquals(flagMap, commonHeader.getFlags()); + + Map requestMap = new HashMap<>(); + commonHeader.setRequestTrack(requestMap); + assertEquals(requestMap, commonHeader.getRequestTrack()); + + 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)); + + PciCommonHeader copiedPciCommonHeader = new PciCommonHeader(); + copiedPciCommonHeader.setApiVer(commonHeader.getApiVer()); + copiedPciCommonHeader.setFlags(commonHeader.getFlags()); + copiedPciCommonHeader.setRequestId(commonHeader.getRequestId()); + copiedPciCommonHeader.setSubRequestId(commonHeader.getSubRequestId()); + copiedPciCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); + + assertTrue(commonHeader.equals(commonHeader)); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + assertFalse(commonHeader.equals(null)); + assertFalse(commonHeader.equals("Hello")); + + PciCommonHeader clonedPciCommonHeader = new PciCommonHeader(commonHeader); + clonedPciCommonHeader.setApiVer(commonHeader.getApiVer()); + clonedPciCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); + + assertTrue(commonHeader.equals(clonedPciCommonHeader)); + + commonHeader.setApiVer(null); + assertFalse(commonHeader.equals(copiedPciCommonHeader)); + copiedPciCommonHeader.setApiVer(null); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + commonHeader.setApiVer("Kansas"); + assertFalse(commonHeader.equals(copiedPciCommonHeader)); + copiedPciCommonHeader.setApiVer("Kansas"); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + + commonHeader.setFlags(null); + assertFalse(commonHeader.equals(copiedPciCommonHeader)); + copiedPciCommonHeader.setFlags(null); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + commonHeader.setFlags(flagMap); + assertFalse(commonHeader.equals(copiedPciCommonHeader)); + copiedPciCommonHeader.setFlags(flagMap); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + + commonHeader.setRequestTrack(null); + assertFalse(commonHeader.equals(copiedPciCommonHeader)); + copiedPciCommonHeader.setRequestTrack(null); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + commonHeader.setRequestTrack(requestMap); + assertFalse(commonHeader.equals(copiedPciCommonHeader)); + copiedPciCommonHeader.setRequestTrack(requestMap); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + + + commonHeader.setRequestId(null); + assertFalse(commonHeader.equals(copiedPciCommonHeader)); + copiedPciCommonHeader.setRequestId(null); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + commonHeader.setRequestId(requestId); + assertFalse(commonHeader.equals(copiedPciCommonHeader)); + copiedPciCommonHeader.setRequestId(requestId); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + + commonHeader.setSubRequestId(null); + assertFalse(commonHeader.equals(copiedPciCommonHeader)); + copiedPciCommonHeader.setSubRequestId(null); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + commonHeader.setSubRequestId("Can I go home?"); + assertFalse(commonHeader.equals(copiedPciCommonHeader)); + copiedPciCommonHeader.setSubRequestId("Can I go home?"); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + + commonHeader.setTimeStamp(null); + assertFalse(commonHeader.equals(copiedPciCommonHeader)); + copiedPciCommonHeader.setTimeStamp(null); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + commonHeader.setTimeStamp(timestamp); + assertFalse(commonHeader.equals(copiedPciCommonHeader)); + copiedPciCommonHeader.setTimeStamp(timestamp); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + } +} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestTest.java new file mode 100644 index 000000000..64d976710 --- /dev/null +++ b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestTest.java @@ -0,0 +1,92 @@ +/*- + * ============LICENSE_START======================================================= + * sdnr + * ================================================================================ + * Copyright (C) 2018 Wipro Limited 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.sdnr; + +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 PciRequestTest { + + @Test + public void testPciRequest() { + PciRequest request = new PciRequest(); + assertNotNull(request); + assertNotEquals(0, request.hashCode()); + + PciCommonHeader commonHeader = new PciCommonHeader(); + String requestPayload = ""; + + request.setCommonHeader(commonHeader); + assertEquals(commonHeader, request.getCommonHeader()); + + request.setPayload(requestPayload); + assertEquals(requestPayload, request.getPayload()); + + request.setAction("Modify"); + assertEquals("Modify", request.getAction()); + + assertNotEquals(0, request.hashCode()); + + assertEquals("PciRequest[commonHeader=CommonHeader [timeStamp=", request.toString().substring(0, 48)); + + PciRequest copiedPciRequest = new PciRequest(); + copiedPciRequest.setCommonHeader(request.getCommonHeader()); + copiedPciRequest.setAction(request.getAction()); + copiedPciRequest.setPayload(request.getPayload()); + + assertTrue(request.equals(request)); + assertTrue(request.equals(copiedPciRequest)); + assertFalse(request.equals(null)); + assertFalse(request.equals("Hello")); + + request.setCommonHeader(null); + assertFalse(request.equals(copiedPciRequest)); + copiedPciRequest.setCommonHeader(null); + assertTrue(request.equals(copiedPciRequest)); + request.setCommonHeader(commonHeader); + assertFalse(request.equals(copiedPciRequest)); + copiedPciRequest.setCommonHeader(commonHeader); + assertTrue(request.equals(copiedPciRequest)); + + request.setAction(null); + assertFalse(request.equals(copiedPciRequest)); + copiedPciRequest.setAction(null); + assertTrue(request.equals(copiedPciRequest)); + request.setAction("Modify"); + assertFalse(request.equals(copiedPciRequest)); + copiedPciRequest.setAction("Modify"); + assertTrue(request.equals(copiedPciRequest)); + + request.setPayload(null); + assertFalse(request.equals(copiedPciRequest)); + copiedPciRequest.setPayload(null); + assertTrue(request.equals(copiedPciRequest)); + request.setPayload(requestPayload); + assertFalse(request.equals(copiedPciRequest)); + copiedPciRequest.setPayload(requestPayload); + assertTrue(request.equals(copiedPciRequest)); + } +} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestWrapperTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestWrapperTest.java new file mode 100644 index 000000000..79f3c0d6f --- /dev/null +++ b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestWrapperTest.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * sdnr + * ================================================================================ + * Copyright (C) 2018 Wipro Limited 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.sdnr; + +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 PciRequestWrapperTest { + + @Test + public void testPciRequestWrapperWrapper() { + assertNotNull(new PciRequestWrapper(new PciRequest())); + PciRequestWrapper requestWrapper = new PciRequestWrapper(); + assertNotNull(requestWrapper); + assertNotEquals(0, requestWrapper.hashCode()); + + PciRequest request = new PciRequest(); + + requestWrapper.setBody(request); + assertEquals(request, requestWrapper.getBody()); + + assertNotEquals(0, requestWrapper.hashCode()); + + assertEquals("RequestWrapper [body=PciRequest[commonHeader=nul", requestWrapper.toString().substring(0, 48)); + + PciRequestWrapper copiedPciRequestWrapper = new PciRequestWrapper(); + copiedPciRequestWrapper.setBody(requestWrapper.getBody()); + + assertTrue(requestWrapper.equals(requestWrapper)); + assertTrue(requestWrapper.equals(copiedPciRequestWrapper)); + assertFalse(requestWrapper.equals(null)); + assertFalse(requestWrapper.equals("Hello")); + + requestWrapper.setBody(null); + assertFalse(requestWrapper.equals(copiedPciRequestWrapper)); + copiedPciRequestWrapper.setBody(null); + assertTrue(requestWrapper.equals(copiedPciRequestWrapper)); + requestWrapper.setBody(request); + assertFalse(requestWrapper.equals(copiedPciRequestWrapper)); + copiedPciRequestWrapper.setBody(request); + assertTrue(requestWrapper.equals(copiedPciRequestWrapper)); + } +} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseCodeTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseCodeTest.java new file mode 100644 index 000000000..355713133 --- /dev/null +++ b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseCodeTest.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * sdnr + * ================================================================================ + * Copyright (C) 2018 Wipro Limited 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.sdnr; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import org.junit.Test; + +public class PciResponseCodeTest { + + @Test + public void testPciResponseCode() { + assertNull(PciResponseCode.toResponseValue(0)); + + assertEquals(PciResponseCode.ACCEPTED, PciResponseCode.toResponseValue(100)); + assertEquals(PciResponseCode.SUCCESS, PciResponseCode.toResponseValue(200)); + assertEquals(PciResponseCode.REJECT, PciResponseCode.toResponseValue(300)); + assertEquals(PciResponseCode.ERROR, PciResponseCode.toResponseValue(400)); + assertEquals(PciResponseCode.FAILURE, PciResponseCode.toResponseValue(450)); + assertEquals(PciResponseCode.FAILURE, PciResponseCode.toResponseValue(401)); + assertEquals(PciResponseCode.FAILURE, PciResponseCode.toResponseValue(406)); + assertEquals(PciResponseCode.PARTIAL_SUCCESS, PciResponseCode.toResponseValue(500)); + assertEquals(PciResponseCode.PARTIAL_FAILURE, PciResponseCode.toResponseValue(501)); + assertEquals(PciResponseCode.PARTIAL_FAILURE, PciResponseCode.toResponseValue(599)); + + assertEquals("100", new PciResponseCode(100).toString()); + assertEquals("200", new PciResponseCode(200).toString()); + assertEquals("300", new PciResponseCode(300).toString()); + assertEquals("400", new PciResponseCode(400).toString()); + assertEquals("450", new PciResponseCode(450).toString()); + assertEquals("500", new PciResponseCode(500).toString()); + assertEquals("510", new PciResponseCode(510).toString()); + + assertEquals(300, new PciResponseCode(300).getCode()); + } +} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseWrapperTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseWrapperTest.java new file mode 100644 index 000000000..16f6f59e9 --- /dev/null +++ b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseWrapperTest.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * sdnr + * ================================================================================ + * Copyright (C) 2018 Wipro Limited 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.sdnr; + +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 PciResponseWrapperTest { + + @Test + public void testPciResponseWrapperWrapper() { + + PciResponseWrapper responseWrapper = new PciResponseWrapper(); + assertNotNull(responseWrapper); + assertNotEquals(0, responseWrapper.hashCode()); + + PciResponse response = new PciResponse(); + + responseWrapper.setBody(response); + assertEquals(response, responseWrapper.getBody()); + + assertNotEquals(0, responseWrapper.hashCode()); + + assertNotEquals("ResponseWrapper [body=Response [commonHeader=n", responseWrapper.toString().substring(0, 46)); + + PciResponseWrapper copiedPciResponseWrapper = new PciResponseWrapper(); + copiedPciResponseWrapper.setBody(responseWrapper.getBody()); + + assertTrue(responseWrapper.equals(responseWrapper)); + //assertTrue(responseWrapper.equals(copiedPciResponseWrapper)); + assertFalse(responseWrapper.equals(null)); + assertFalse(responseWrapper.equals("Hello")); + + responseWrapper.setBody(null); + assertFalse(responseWrapper.equals(copiedPciResponseWrapper)); + copiedPciResponseWrapper.setBody(null); + //assertTrue(responseWrapper.equals(copiedPciResponseWrapper)); + responseWrapper.setBody(response); + //assertFalse(responseWrapper.equals(copiedPciResponseWrapper)); + copiedPciResponseWrapper.setBody(response); + //assertTrue(responseWrapper.equals(copiedPciResponseWrapper)); + } +} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciStatusTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciStatusTest.java new file mode 100644 index 000000000..b38eed3e3 --- /dev/null +++ b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciStatusTest.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * sdnr + * ================================================================================ + * Copyright (C) 2018 Wipro Limited 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.sdnr; + +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 PciStatusTest { + + @Test + public void testResponseStatus() { + Status status = new Status(); + assertNotNull(status); + assertNotEquals(0, status.hashCode()); + + status.setCode(1234); + assertEquals(1234, status.getCode()); + + status.setValue("The wonderful land of Oz"); + assertEquals("The wonderful land of Oz", status.getValue()); + + assertEquals("Status [code = 1234, value = The wonderfu", status.toString().substring(0, 41)); + + Status copiedStatus = new Status(); + copiedStatus.setCode(status.getCode()); + copiedStatus.setValue(status.getValue()); + + 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.setValue(null); + assertFalse(status.equals(copiedStatus)); + copiedStatus.setValue(null); + assertTrue(status.equals(copiedStatus)); + status.setValue("The wonderful land of Oz"); + assertFalse(status.equals(copiedStatus)); + copiedStatus.setValue("The wonderful land of Oz"); + assertTrue(status.equals(copiedStatus)); + } +} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java new file mode 100644 index 000000000..a9501dddc --- /dev/null +++ b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java @@ -0,0 +1,115 @@ +/*- + * ============LICENSE_START======================================================= + * sdnr + * ================================================================================ + * Copyright (C) 2018 Wipro Limited 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.sdnr; + +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 PciWrapperTest { + + @Test + public void testPciWrapper() { + PciWrapper wrapper = new PciWrapper(); + 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)); + + PciWrapper copiedPciWrapper = new PciWrapper(); + copiedPciWrapper.setVersion(wrapper.getVersion()); + copiedPciWrapper.setCambriaPartition(wrapper.getCambriaPartition()); + copiedPciWrapper.setRpcName(wrapper.getRpcName()); + copiedPciWrapper.setCorrelationId(wrapper.getCorrelationId()); + copiedPciWrapper.setType(wrapper.getType()); + + assertTrue(wrapper.equals(wrapper)); + assertTrue(wrapper.equals(copiedPciWrapper)); + assertFalse(wrapper.equals(null)); + assertFalse(wrapper.equals("Hello")); + + wrapper.setVersion(null); + assertFalse(wrapper.equals(copiedPciWrapper)); + copiedPciWrapper.setVersion(null); + assertTrue(wrapper.equals(copiedPciWrapper)); + wrapper.setVersion("19.3.9"); + assertFalse(wrapper.equals(copiedPciWrapper)); + copiedPciWrapper.setVersion("19.3.9"); + assertTrue(wrapper.equals(copiedPciWrapper)); + + wrapper.setCambriaPartition(null); + assertFalse(wrapper.equals(copiedPciWrapper)); + copiedPciWrapper.setCambriaPartition(null); + assertTrue(wrapper.equals(copiedPciWrapper)); + wrapper.setCambriaPartition("The Emerald City"); + assertFalse(wrapper.equals(copiedPciWrapper)); + copiedPciWrapper.setCambriaPartition("The Emerald City"); + assertTrue(wrapper.equals(copiedPciWrapper)); + + wrapper.setRpcName(null); + assertFalse(wrapper.equals(copiedPciWrapper)); + copiedPciWrapper.setRpcName(null); + assertTrue(wrapper.equals(copiedPciWrapper)); + wrapper.setRpcName("Tornado"); + assertFalse(wrapper.equals(copiedPciWrapper)); + copiedPciWrapper.setRpcName("Tornado"); + assertTrue(wrapper.equals(copiedPciWrapper)); + + wrapper.setCorrelationId(null); + assertFalse(wrapper.equals(copiedPciWrapper)); + copiedPciWrapper.setCorrelationId(null); + assertTrue(wrapper.equals(copiedPciWrapper)); + wrapper.setCorrelationId("YellowBrickRoad"); + assertFalse(wrapper.equals(copiedPciWrapper)); + copiedPciWrapper.setCorrelationId("YellowBrickRoad"); + assertTrue(wrapper.equals(copiedPciWrapper)); + + wrapper.setType(null); + assertFalse(wrapper.equals(copiedPciWrapper)); + copiedPciWrapper.setType(null); + assertTrue(wrapper.equals(copiedPciWrapper)); + wrapper.setType("Munchkin"); + assertFalse(wrapper.equals(copiedPciWrapper)); + copiedPciWrapper.setType("Munchkin"); + assertTrue(wrapper.equals(copiedPciWrapper)); + } +} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciCommonHeader.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciCommonHeader.java deleted file mode 100644 index 5c4dec3bc..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciCommonHeader.java +++ /dev/null @@ -1,144 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.sdnr; - -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 TestPciCommonHeader { - - @Test - public void testPciCommonHeader() { - PciCommonHeader commonHeader = new PciCommonHeader(); - assertNotNull(commonHeader); - assertNotNull(new PciCommonHeader(commonHeader)); - assertNotEquals(0, commonHeader.hashCode()); - - commonHeader.setApiVer("Kansas"); - assertEquals("Kansas", commonHeader.getApiVer()); - - Map flagMap = new HashMap<>(); - commonHeader.setFlags(flagMap); - assertEquals(flagMap, commonHeader.getFlags()); - - Map requestMap = new HashMap<>(); - commonHeader.setRequestTrack(requestMap); - assertEquals(requestMap, commonHeader.getRequestTrack()); - - 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)); - - PciCommonHeader copiedPciCommonHeader = new PciCommonHeader(); - copiedPciCommonHeader.setApiVer(commonHeader.getApiVer()); - copiedPciCommonHeader.setFlags(commonHeader.getFlags()); - copiedPciCommonHeader.setRequestId(commonHeader.getRequestId()); - copiedPciCommonHeader.setSubRequestId(commonHeader.getSubRequestId()); - copiedPciCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); - - assertTrue(commonHeader.equals(commonHeader)); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - assertFalse(commonHeader.equals(null)); - assertFalse(commonHeader.equals("Hello")); - - PciCommonHeader clonedPciCommonHeader = new PciCommonHeader(commonHeader); - clonedPciCommonHeader.setApiVer(commonHeader.getApiVer()); - clonedPciCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); - - assertTrue(commonHeader.equals(clonedPciCommonHeader)); - - commonHeader.setApiVer(null); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setApiVer(null); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - commonHeader.setApiVer("Kansas"); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setApiVer("Kansas"); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - - commonHeader.setFlags(null); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setFlags(null); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - commonHeader.setFlags(flagMap); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setFlags(flagMap); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - - commonHeader.setRequestTrack(null); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setRequestTrack(null); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - commonHeader.setRequestTrack(requestMap); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setRequestTrack(requestMap); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - - - commonHeader.setRequestId(null); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setRequestId(null); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - commonHeader.setRequestId(requestId); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setRequestId(requestId); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - - commonHeader.setSubRequestId(null); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setSubRequestId(null); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - commonHeader.setSubRequestId("Can I go home?"); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setSubRequestId("Can I go home?"); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - - commonHeader.setTimeStamp(null); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setTimeStamp(null); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - commonHeader.setTimeStamp(timestamp); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setTimeStamp(timestamp); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - } -} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciRequest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciRequest.java deleted file mode 100644 index 3a84adcd4..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciRequest.java +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.sdnr; - -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 TestPciRequest { - - @Test - public void testPciRequest() { - PciRequest request = new PciRequest(); - assertNotNull(request); - assertNotEquals(0, request.hashCode()); - - PciCommonHeader commonHeader = new PciCommonHeader(); - String requestPayload = ""; - - request.setCommonHeader(commonHeader); - assertEquals(commonHeader, request.getCommonHeader()); - - request.setPayload(requestPayload); - assertEquals(requestPayload, request.getPayload()); - - request.setAction("Modify"); - assertEquals("Modify", request.getAction()); - - assertNotEquals(0, request.hashCode()); - - assertEquals("PciRequest[commonHeader=CommonHeader [timeStamp=", request.toString().substring(0, 48)); - - PciRequest copiedPciRequest = new PciRequest(); - copiedPciRequest.setCommonHeader(request.getCommonHeader()); - copiedPciRequest.setAction(request.getAction()); - copiedPciRequest.setPayload(request.getPayload()); - - assertTrue(request.equals(request)); - assertTrue(request.equals(copiedPciRequest)); - assertFalse(request.equals(null)); - assertFalse(request.equals("Hello")); - - request.setCommonHeader(null); - assertFalse(request.equals(copiedPciRequest)); - copiedPciRequest.setCommonHeader(null); - assertTrue(request.equals(copiedPciRequest)); - request.setCommonHeader(commonHeader); - assertFalse(request.equals(copiedPciRequest)); - copiedPciRequest.setCommonHeader(commonHeader); - assertTrue(request.equals(copiedPciRequest)); - - request.setAction(null); - assertFalse(request.equals(copiedPciRequest)); - copiedPciRequest.setAction(null); - assertTrue(request.equals(copiedPciRequest)); - request.setAction("Modify"); - assertFalse(request.equals(copiedPciRequest)); - copiedPciRequest.setAction("Modify"); - assertTrue(request.equals(copiedPciRequest)); - - request.setPayload(null); - assertFalse(request.equals(copiedPciRequest)); - copiedPciRequest.setPayload(null); - assertTrue(request.equals(copiedPciRequest)); - request.setPayload(requestPayload); - assertFalse(request.equals(copiedPciRequest)); - copiedPciRequest.setPayload(requestPayload); - assertTrue(request.equals(copiedPciRequest)); - } -} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciRequestWrapper.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciRequestWrapper.java deleted file mode 100644 index 7ab68a6ca..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciRequestWrapper.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.sdnr; - -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 TestPciRequestWrapper { - - @Test - public void testPciRequestWrapperWrapper() { - assertNotNull(new PciRequestWrapper(new PciRequest())); - PciRequestWrapper requestWrapper = new PciRequestWrapper(); - assertNotNull(requestWrapper); - assertNotEquals(0, requestWrapper.hashCode()); - - PciRequest request = new PciRequest(); - - requestWrapper.setBody(request); - assertEquals(request, requestWrapper.getBody()); - - assertNotEquals(0, requestWrapper.hashCode()); - - assertEquals("RequestWrapper [body=PciRequest[commonHeader=nul", requestWrapper.toString().substring(0, 48)); - - PciRequestWrapper copiedPciRequestWrapper = new PciRequestWrapper(); - copiedPciRequestWrapper.setBody(requestWrapper.getBody()); - - assertTrue(requestWrapper.equals(requestWrapper)); - assertTrue(requestWrapper.equals(copiedPciRequestWrapper)); - assertFalse(requestWrapper.equals(null)); - assertFalse(requestWrapper.equals("Hello")); - - requestWrapper.setBody(null); - assertFalse(requestWrapper.equals(copiedPciRequestWrapper)); - copiedPciRequestWrapper.setBody(null); - assertTrue(requestWrapper.equals(copiedPciRequestWrapper)); - requestWrapper.setBody(request); - assertFalse(requestWrapper.equals(copiedPciRequestWrapper)); - copiedPciRequestWrapper.setBody(request); - assertTrue(requestWrapper.equals(copiedPciRequestWrapper)); - } -} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciResponseCode.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciResponseCode.java deleted file mode 100644 index 056ce60e6..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciResponseCode.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.sdnr; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import org.junit.Test; - -public class TestPciResponseCode { - - @Test - public void testPciResponseCode() { - assertNull(PciResponseCode.toResponseValue(0)); - - assertEquals(PciResponseCode.ACCEPTED, PciResponseCode.toResponseValue(100)); - assertEquals(PciResponseCode.SUCCESS, PciResponseCode.toResponseValue(200)); - assertEquals(PciResponseCode.REJECT, PciResponseCode.toResponseValue(300)); - assertEquals(PciResponseCode.ERROR, PciResponseCode.toResponseValue(400)); - assertEquals(PciResponseCode.FAILURE, PciResponseCode.toResponseValue(450)); - assertEquals(PciResponseCode.FAILURE, PciResponseCode.toResponseValue(401)); - assertEquals(PciResponseCode.FAILURE, PciResponseCode.toResponseValue(406)); - assertEquals(PciResponseCode.PARTIAL_SUCCESS, PciResponseCode.toResponseValue(500)); - assertEquals(PciResponseCode.PARTIAL_FAILURE, PciResponseCode.toResponseValue(501)); - assertEquals(PciResponseCode.PARTIAL_FAILURE, PciResponseCode.toResponseValue(599)); - - assertEquals("100", new PciResponseCode(100).toString()); - assertEquals("200", new PciResponseCode(200).toString()); - assertEquals("300", new PciResponseCode(300).toString()); - assertEquals("400", new PciResponseCode(400).toString()); - assertEquals("450", new PciResponseCode(450).toString()); - assertEquals("500", new PciResponseCode(500).toString()); - assertEquals("510", new PciResponseCode(510).toString()); - - assertEquals(300, new PciResponseCode(300).getCode()); - } -} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciResponseWrapper.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciResponseWrapper.java deleted file mode 100644 index 2472d31c3..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciResponseWrapper.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.sdnr; - -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 TestPciResponseWrapper { - - @Test - public void testPciResponseWrapperWrapper() { - - PciResponseWrapper responseWrapper = new PciResponseWrapper(); - assertNotNull(responseWrapper); - assertNotEquals(0, responseWrapper.hashCode()); - - PciResponse response = new PciResponse(); - - responseWrapper.setBody(response); - assertEquals(response, responseWrapper.getBody()); - - assertNotEquals(0, responseWrapper.hashCode()); - - assertNotEquals("ResponseWrapper [body=Response [commonHeader=n", responseWrapper.toString().substring(0, 46)); - - PciResponseWrapper copiedPciResponseWrapper = new PciResponseWrapper(); - copiedPciResponseWrapper.setBody(responseWrapper.getBody()); - - assertTrue(responseWrapper.equals(responseWrapper)); - //assertTrue(responseWrapper.equals(copiedPciResponseWrapper)); - assertFalse(responseWrapper.equals(null)); - assertFalse(responseWrapper.equals("Hello")); - - responseWrapper.setBody(null); - assertFalse(responseWrapper.equals(copiedPciResponseWrapper)); - copiedPciResponseWrapper.setBody(null); - //assertTrue(responseWrapper.equals(copiedPciResponseWrapper)); - responseWrapper.setBody(response); - //assertFalse(responseWrapper.equals(copiedPciResponseWrapper)); - copiedPciResponseWrapper.setBody(response); - //assertTrue(responseWrapper.equals(copiedPciResponseWrapper)); - } -} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciStatus.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciStatus.java deleted file mode 100644 index b09922342..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciStatus.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.sdnr; - -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 TestPciStatus { - - @Test - public void testResponseStatus() { - Status status = new Status(); - assertNotNull(status); - assertNotEquals(0, status.hashCode()); - - status.setCode(1234); - assertEquals(1234, status.getCode()); - - status.setValue("The wonderful land of Oz"); - assertEquals("The wonderful land of Oz", status.getValue()); - - assertEquals("Status [code = 1234, value = The wonderfu", status.toString().substring(0, 41)); - - Status copiedStatus = new Status(); - copiedStatus.setCode(status.getCode()); - copiedStatus.setValue(status.getValue()); - - 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.setValue(null); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setValue(null); - assertTrue(status.equals(copiedStatus)); - status.setValue("The wonderful land of Oz"); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setValue("The wonderful land of Oz"); - assertTrue(status.equals(copiedStatus)); - } -} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciWrapper.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciWrapper.java deleted file mode 100644 index e0964df65..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciWrapper.java +++ /dev/null @@ -1,115 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.sdnr; - -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 TestPciWrapper { - - @Test - public void testPciWrapper() { - PciWrapper wrapper = new PciWrapper(); - 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)); - - PciWrapper copiedPciWrapper = new PciWrapper(); - copiedPciWrapper.setVersion(wrapper.getVersion()); - copiedPciWrapper.setCambriaPartition(wrapper.getCambriaPartition()); - copiedPciWrapper.setRpcName(wrapper.getRpcName()); - copiedPciWrapper.setCorrelationId(wrapper.getCorrelationId()); - copiedPciWrapper.setType(wrapper.getType()); - - assertTrue(wrapper.equals(wrapper)); - assertTrue(wrapper.equals(copiedPciWrapper)); - assertFalse(wrapper.equals(null)); - assertFalse(wrapper.equals("Hello")); - - wrapper.setVersion(null); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setVersion(null); - assertTrue(wrapper.equals(copiedPciWrapper)); - wrapper.setVersion("19.3.9"); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setVersion("19.3.9"); - assertTrue(wrapper.equals(copiedPciWrapper)); - - wrapper.setCambriaPartition(null); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setCambriaPartition(null); - assertTrue(wrapper.equals(copiedPciWrapper)); - wrapper.setCambriaPartition("The Emerald City"); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setCambriaPartition("The Emerald City"); - assertTrue(wrapper.equals(copiedPciWrapper)); - - wrapper.setRpcName(null); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setRpcName(null); - assertTrue(wrapper.equals(copiedPciWrapper)); - wrapper.setRpcName("Tornado"); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setRpcName("Tornado"); - assertTrue(wrapper.equals(copiedPciWrapper)); - - wrapper.setCorrelationId(null); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setCorrelationId(null); - assertTrue(wrapper.equals(copiedPciWrapper)); - wrapper.setCorrelationId("YellowBrickRoad"); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setCorrelationId("YellowBrickRoad"); - assertTrue(wrapper.equals(copiedPciWrapper)); - - wrapper.setType(null); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setType(null); - assertTrue(wrapper.equals(copiedPciWrapper)); - wrapper.setType("Munchkin"); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setType("Munchkin"); - assertTrue(wrapper.equals(copiedPciWrapper)); - } -} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/util/SerializationTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/util/SerializationTest.java new file mode 100644 index 000000000..e9793b286 --- /dev/null +++ b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/util/SerializationTest.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * sdnr + * ================================================================================ + * Copyright (C) 2018 Wipro Limited 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.sdnr.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/sdnr/src/test/java/org/onap/policy/sdnr/util/TestSerialization.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/util/TestSerialization.java deleted file mode 100644 index 7b139de73..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/util/TestSerialization.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.sdnr.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