aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-impl
diff options
context:
space:
mode:
Diffstat (limited to 'models-interactions/model-impl')
-rw-r--r--models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java78
-rw-r--r--models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java60
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java4
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java4
-rw-r--r--models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java159
-rw-r--r--models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java69
-rw-r--r--models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java60
-rw-r--r--models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java69
8 files changed, 136 insertions, 367 deletions
diff --git a/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java b/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java
index 30d4ed910..686e6a416 100644
--- a/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java
+++ b/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,6 +30,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
+import java.util.function.BiConsumer;
import org.junit.Test;
public class CommonHeaderTest {
@@ -94,67 +95,28 @@ public class CommonHeaderTest {
assertEquals(commonHeader, clonedCommonHeader);
- commonHeader.setApiVer(null);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setApiVer(null);
- assertEquals(commonHeader, copiedCommonHeader);
- commonHeader.setApiVer(KANSAS);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setApiVer(KANSAS);
- assertEquals(commonHeader, copiedCommonHeader);
+ checkField(KANSAS, CommonHeader::setApiVer);
+ checkField(flagSet, CommonHeader::setFlags);
+ checkField(DOROTHY, CommonHeader::setOriginatorId);
+ checkField(requestId, CommonHeader::setRequestId);
+ checkField(requestTrackSet, CommonHeader::setRequestTrack);
+ checkField(CAN_I_GO_HOME, CommonHeader::setSubRequestId);
+ checkField(timestamp, CommonHeader::setTimeStamp);
+ }
- commonHeader.setFlags(null);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setFlags(null);
- assertEquals(commonHeader, copiedCommonHeader);
- commonHeader.setFlags(flagSet);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setFlags(flagSet);
- assertEquals(commonHeader, copiedCommonHeader);
+ private <T> void checkField(T value, BiConsumer<CommonHeader, T> setter) {
+ CommonHeader header1 = new CommonHeader();
+ CommonHeader header2 = new CommonHeader(header1);
- commonHeader.setOriginatorId(null);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setOriginatorId(null);
- assertEquals(commonHeader, copiedCommonHeader);
- commonHeader.setOriginatorId(DOROTHY);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setOriginatorId(DOROTHY);
- assertEquals(commonHeader, copiedCommonHeader);
+ setter.accept(header2, null);
- commonHeader.setRequestId(null);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setRequestId(null);
- assertEquals(commonHeader, copiedCommonHeader);
- commonHeader.setRequestId(requestId);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setRequestId(requestId);
- assertEquals(commonHeader, copiedCommonHeader);
+ setter.accept(header1, value);
+ assertNotEquals(header1, header2);
- commonHeader.setRequestTrack(null);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setRequestTrack(null);
- assertEquals(commonHeader, copiedCommonHeader);
- commonHeader.setRequestTrack(requestTrackSet);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setRequestTrack(requestTrackSet);
- assertEquals(commonHeader, copiedCommonHeader);
+ setter.accept(header2, value);
+ assertEquals(header1, header2);
- commonHeader.setSubRequestId(null);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setSubRequestId(null);
- assertEquals(commonHeader, copiedCommonHeader);
- commonHeader.setSubRequestId(CAN_I_GO_HOME);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setSubRequestId(CAN_I_GO_HOME);
- assertEquals(commonHeader, copiedCommonHeader);
-
- commonHeader.setTimeStamp(null);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setTimeStamp(null);
- assertEquals(commonHeader, copiedCommonHeader);
- commonHeader.setTimeStamp(timestamp);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setTimeStamp(timestamp);
- assertEquals(commonHeader, copiedCommonHeader);
+ setter.accept(header1, null);
+ assertNotEquals(header1, header2);
}
}
diff --git a/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java b/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java
index 43686a747..5bff56b78 100644
--- a/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java
+++ b/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -27,6 +27,7 @@ import static org.junit.Assert.assertNotNull;
import java.util.HashMap;
import java.util.Map;
+import java.util.function.BiConsumer;
import org.junit.Test;
public class RequestTest {
@@ -77,49 +78,26 @@ public class RequestTest {
assertNotEquals(request, null);
assertNotEquals(request, (Object) "Hello");
- request.setCommonHeader(null);
- assertNotEquals(request, copiedRequest);
- copiedRequest.setCommonHeader(null);
- assertEquals(request, copiedRequest);
- request.setCommonHeader(commonHeader);
- assertNotEquals(request, copiedRequest);
- copiedRequest.setCommonHeader(commonHeader);
- assertEquals(request, copiedRequest);
+ checkField(commonHeader, Request::setCommonHeader);
+ checkField(GO_TO_OZ, Request::setAction);
+ checkField(WIZARD, Request::setObjectId);
+ checkField("Oz", Request::setTargetId);
+ checkField(payload, Request::setPayload);
+ }
- request.setAction(null);
- assertNotEquals(request, copiedRequest);
- copiedRequest.setAction(null);
- assertEquals(request, copiedRequest);
- request.setAction(GO_TO_OZ);
- assertNotEquals(request, copiedRequest);
- copiedRequest.setAction(GO_TO_OZ);
- assertEquals(request, copiedRequest);
+ private <T> void checkField(T value, BiConsumer<Request, T> setter) {
+ Request request1 = new Request();
+ Request request2 = new Request();
- request.setObjectId(null);
- assertNotEquals(request, copiedRequest);
- copiedRequest.setObjectId(null);
- assertEquals(request, copiedRequest);
- request.setObjectId(WIZARD);
- assertNotEquals(request, copiedRequest);
- copiedRequest.setObjectId(WIZARD);
- assertEquals(request, copiedRequest);
+ setter.accept(request2, null);
- request.setTargetId(null);
- assertNotEquals(request, copiedRequest);
- copiedRequest.setTargetId(null);
- assertEquals(request, copiedRequest);
- request.setTargetId("Oz");
- assertNotEquals(request, copiedRequest);
- copiedRequest.setTargetId("Oz");
- assertEquals(request, copiedRequest);
+ setter.accept(request1, value);
+ assertNotEquals(request1, request2);
- request.setPayload(new HashMap<>());
- assertNotEquals(request, copiedRequest);
- copiedRequest.setPayload(new HashMap<>());
- assertEquals(request, copiedRequest);
- request.setPayload(payload);
- assertNotEquals(request, copiedRequest);
- copiedRequest.setPayload(payload);
- assertEquals(request, copiedRequest);
+ setter.accept(request2, value);
+ assertEquals(request1, request2);
+
+ setter.accept(request1, null);
+ assertNotEquals(request1, request2);
}
}
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java
index 3106e3909..4f0dbf730 100644
--- a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* controlloop
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -54,7 +54,7 @@ public abstract class ControlLoopEvent implements Serializable {
*
* @param event the existing instance
*/
- public ControlLoopEvent(ControlLoopEvent event) {
+ protected ControlLoopEvent(ControlLoopEvent event) {
if (event == null) {
return;
}
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java
index c4c46d30a..890fb083a 100644
--- a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* controlloop
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -57,7 +57,7 @@ public abstract class ControlLoopNotification implements Serializable {
*
* @param event the event
*/
- public ControlLoopNotification(ControlLoopEvent event) {
+ protected ControlLoopNotification(ControlLoopEvent event) {
if (event == null) {
return;
}
diff --git a/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java b/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java
index 21df853f4..e5a887429 100644
--- a/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java
+++ b/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* rest
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -145,60 +145,39 @@ public class RestTest {
RestManager mgr = new RestManager();
Pair<Integer, String> result = mgr.get(getUri, null, null, null);
-
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("GOT: " + EXPECT_STRING, result.getRight());
+ checkResult(result, "GOT: " + EXPECT_STRING);
result = mgr.delete(deleteUri, null, null, null, null, null);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("DELETE: " + EXPECT_STRING, result.getRight());
+ checkResult(result, "DELETE: " + EXPECT_STRING);
result = mgr.delete(deleteUri, null, null, null);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("DELETE: " + EXPECT_STRING, result.getRight());
+ checkResult(result, "DELETE: " + EXPECT_STRING);
result = mgr.put(putUri, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PUT: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "PUT: " + PAYLOAD + EXPECT_STRING);
result = mgr.put(putUriBlank, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PUT: " + PAYLOAD + RETURN_STRING, result.getRight());
+ checkResult(result, "PUT: " + PAYLOAD + RETURN_STRING);
result = mgr.post(postUri, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("POST: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "POST: " + PAYLOAD + EXPECT_STRING);
result = mgr.post(postUriBlank, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("POST: " + PAYLOAD + RETURN_STRING, result.getRight());
+ checkResult(result, "POST: " + PAYLOAD + RETURN_STRING);
result = mgr.patch(patchUri, null, null, null, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PATCH: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "PATCH: " + PAYLOAD + EXPECT_STRING);
result = mgr.patch(patchUriBlank, null, null, null, PAYLOAD);
+ checkResult(result, "PATCH: " + PAYLOAD + RETURN_STRING);
+
+ }
+
+ private void checkResult(Pair<Integer, String> result, String expectedText) {
assertEquals((Integer) 200, result.getLeft());
assertNotNull(result.getRight());
assertTrue(result.getRight().length() > 0);
- assertEquals("PATCH: " + PAYLOAD + RETURN_STRING, result.getRight());
-
+ assertEquals(expectedText, result.getRight());
}
@Test
@@ -206,53 +185,28 @@ public class RestTest {
RestManager mgr = new RestManager();
Pair<Integer, String> result = mgr.get(getUri, "", null, null);
-
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("GOT: " + EXPECT_STRING, result.getRight());
+ checkResult(result, "GOT: " + EXPECT_STRING);
result = mgr.delete(deleteUri, "", null, null, null, null);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("DELETE: " + EXPECT_STRING, result.getRight());
+ checkResult(result, "DELETE: " + EXPECT_STRING);
result = mgr.put(putUri, "", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PUT: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "PUT: " + PAYLOAD + EXPECT_STRING);
result = mgr.put(putUriBlank, "", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PUT: " + PAYLOAD + RETURN_STRING, result.getRight());
+ checkResult(result, "PUT: " + PAYLOAD + RETURN_STRING);
result = mgr.post(postUri, "", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("POST: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "POST: " + PAYLOAD + EXPECT_STRING);
result = mgr.post(postUriBlank, "", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("POST: " + PAYLOAD + RETURN_STRING, result.getRight());
+ checkResult(result, "POST: " + PAYLOAD + RETURN_STRING);
result = mgr.patch(patchUri, "", null, null, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PATCH: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "PATCH: " + PAYLOAD + EXPECT_STRING);
result = mgr.patch(patchUriBlank, "", null, null, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PATCH: " + PAYLOAD + RETURN_STRING, result.getRight());
+ checkResult(result, "PATCH: " + PAYLOAD + RETURN_STRING);
}
@@ -261,53 +215,28 @@ public class RestTest {
RestManager mgr = new RestManager();
Pair<Integer, String> result = mgr.get(getUri, "user", null, null);
-
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("GOT: " + EXPECT_STRING, result.getRight());
+ checkResult(result, "GOT: " + EXPECT_STRING);
result = mgr.delete(deleteUri, "user", null, null, null, null);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("DELETE: " + EXPECT_STRING, result.getRight());
+ checkResult(result, "DELETE: " + EXPECT_STRING);
result = mgr.put(putUri, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PUT: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "PUT: " + PAYLOAD + EXPECT_STRING);
result = mgr.put(putUriBlank, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PUT: " + PAYLOAD + RETURN_STRING, result.getRight());
+ checkResult(result, "PUT: " + PAYLOAD + RETURN_STRING);
result = mgr.post(postUri, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("POST: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "POST: " + PAYLOAD + EXPECT_STRING);
result = mgr.post(postUriBlank, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("POST: " + PAYLOAD + RETURN_STRING, result.getRight());
+ checkResult(result, "POST: " + PAYLOAD + RETURN_STRING);
result = mgr.patch(patchUri, "user", null, null, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PATCH: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "PATCH: " + PAYLOAD + EXPECT_STRING);
result = mgr.patch(patchUriBlank, "user", null, null, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PATCH: " + PAYLOAD + RETURN_STRING, result.getRight());
+ checkResult(result, "PATCH: " + PAYLOAD + RETURN_STRING);
}
@@ -338,37 +267,21 @@ public class RestTest {
RestManager mgr = new RestManager();
Pair<Integer, String> result = mgr.get(baseUri + "RestTest/GetHello/" + NAME_PARAM, null, null, null);
-
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("GOT: " + RETURN_STRING + NAME_PARAM + " aged 90", result.getRight());
+ checkResult(result, "GOT: " + RETURN_STRING + NAME_PARAM + " aged 90");
result = mgr.delete(baseUri + "RestTest/DeleteHello/" + NAME_PARAM, null, null, null, null, null);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("DELETE: " + RETURN_STRING + NAME_PARAM + " aged 90", result.getRight());
+ checkResult(result, "DELETE: " + RETURN_STRING + NAME_PARAM + " aged 90");
result = mgr.put(baseUri + "RestTest/PutHello/" + NAME_PARAM, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PUT: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90", result.getRight());
+ checkResult(result, "PUT: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90");
result = mgr.post(baseUri + "RestTest/PostHello/" + NAME_PARAM, null, null,
null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("POST: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90", result.getRight());
+ checkResult(result, "POST: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90");
result = mgr.patch(baseUri + "RestTest/PatchHello/" + NAME_PARAM, null, null,
null, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PATCH: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90", result.getRight());
+ checkResult(result, "PATCH: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90");
}
diff --git a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java
index f4c0bf32d..9d497602f 100644
--- a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java
+++ b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-2021 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.
@@ -30,6 +30,7 @@ import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
+import java.util.function.BiConsumer;
import org.junit.Test;
public class PciCommonHeaderTest {
@@ -88,59 +89,27 @@ public class PciCommonHeaderTest {
assertEquals(commonHeader, clonedPciCommonHeader);
- commonHeader.setApiVer(null);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setApiVer(null);
- assertEquals(commonHeader, copiedPciCommonHeader);
- commonHeader.setApiVer(KANSAS);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setApiVer(KANSAS);
- assertEquals(commonHeader, copiedPciCommonHeader);
-
- commonHeader.setFlags(null);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setFlags(null);
- assertEquals(commonHeader, copiedPciCommonHeader);
- commonHeader.setFlags(flagMap);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setFlags(flagMap);
- assertEquals(commonHeader, copiedPciCommonHeader);
+ checkField(KANSAS, PciCommonHeader::setApiVer);
+ checkField(flagMap, PciCommonHeader::setFlags);
+ checkField(requestMap, PciCommonHeader::setRequestTrack);
+ checkField(requestId, PciCommonHeader::setRequestId);
+ checkField(CAN_I_GO_HOME, PciCommonHeader::setSubRequestId);
+ checkField(timestamp, PciCommonHeader::setTimeStamp);
+ }
- commonHeader.setRequestTrack(null);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setRequestTrack(null);
- assertEquals(commonHeader, copiedPciCommonHeader);
- commonHeader.setRequestTrack(requestMap);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setRequestTrack(requestMap);
- assertEquals(commonHeader, copiedPciCommonHeader);
+ private <T> void checkField(T value, BiConsumer<PciCommonHeader, T> setter) {
+ PciCommonHeader details1 = new PciCommonHeader();
+ PciCommonHeader details2 = new PciCommonHeader(details1);
+ setter.accept(details2, null);
- commonHeader.setRequestId(null);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setRequestId(null);
- assertEquals(commonHeader, copiedPciCommonHeader);
- commonHeader.setRequestId(requestId);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setRequestId(requestId);
- assertEquals(commonHeader, copiedPciCommonHeader);
+ setter.accept(details1, value);
+ assertNotEquals(details1, details2);
- commonHeader.setSubRequestId(null);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setSubRequestId(null);
- assertEquals(commonHeader, copiedPciCommonHeader);
- commonHeader.setSubRequestId(CAN_I_GO_HOME);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setSubRequestId(CAN_I_GO_HOME);
- assertEquals(commonHeader, copiedPciCommonHeader);
+ setter.accept(details2, value);
+ assertEquals(details1, details2);
- commonHeader.setTimeStamp(null);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setTimeStamp(null);
- assertEquals(commonHeader, copiedPciCommonHeader);
- commonHeader.setTimeStamp(timestamp);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setTimeStamp(timestamp);
- assertEquals(commonHeader, copiedPciCommonHeader);
+ setter.accept(details1, null);
+ assertNotEquals(details1, details2);
}
}
diff --git a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java
index 914974691..91d42a3bf 100644
--- a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java
+++ b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-2021 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.
@@ -26,6 +26,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
+import java.util.function.BiConsumer;
import org.junit.Test;
public class PciWrapperTest {
@@ -73,49 +74,26 @@ public class PciWrapperTest {
assertNotEquals(wrapper, null);
assertNotEquals(wrapper, (Object) "Hello");
- wrapper.setVersion(null);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setVersion(null);
- assertEquals(wrapper, copiedPciWrapper);
- wrapper.setVersion(VERSION_19);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setVersion(VERSION_19);
- assertEquals(wrapper, copiedPciWrapper);
+ checkField(VERSION_19, PciWrapper::setVersion);
+ checkField(THE_EMERALD_CITY, PciWrapper::setCambriaPartition);
+ checkField(TORNADO, PciWrapper::setRpcName);
+ checkField(YELLOW_BRICK_ROAD, PciWrapper::setCorrelationId);
+ checkField(MUNCHKIN, PciWrapper::setType);
+ }
- wrapper.setCambriaPartition(null);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setCambriaPartition(null);
- assertEquals(wrapper, copiedPciWrapper);
- wrapper.setCambriaPartition(THE_EMERALD_CITY);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setCambriaPartition(THE_EMERALD_CITY);
- assertEquals(wrapper, copiedPciWrapper);
+ private <T> void checkField(T value, BiConsumer<PciWrapper, T> setter) {
+ PciWrapper details1 = new PciWrapper();
+ PciWrapper details2 = new PciWrapper();
- wrapper.setRpcName(null);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setRpcName(null);
- assertEquals(wrapper, copiedPciWrapper);
- wrapper.setRpcName(TORNADO);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setRpcName(TORNADO);
- assertEquals(wrapper, copiedPciWrapper);
+ setter.accept(details2, null);
- wrapper.setCorrelationId(null);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setCorrelationId(null);
- assertEquals(wrapper, copiedPciWrapper);
- wrapper.setCorrelationId(YELLOW_BRICK_ROAD);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setCorrelationId(YELLOW_BRICK_ROAD);
- assertEquals(wrapper, copiedPciWrapper);
+ setter.accept(details1, value);
+ assertNotEquals(details1, details2);
- wrapper.setType(null);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setType(null);
- assertEquals(wrapper, copiedPciWrapper);
- wrapper.setType(MUNCHKIN);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setType(MUNCHKIN);
- assertEquals(wrapper, copiedPciWrapper);
+ setter.accept(details2, value);
+ assertEquals(details1, details2);
+
+ setter.accept(details1, null);
+ assertNotEquals(details1, details2);
}
}
diff --git a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java
index 43d5cd38a..66de1b2cd 100644
--- a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java
+++ b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java
@@ -3,8 +3,7 @@
* so
* ================================================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * ================================================================================
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved
+ * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,6 +29,7 @@ import static org.junit.Assert.assertNull;
import java.util.ArrayList;
import java.util.List;
+import java.util.function.BiConsumer;
import org.junit.Test;
public class SoRequestDetailsTest {
@@ -118,58 +118,27 @@ public class SoRequestDetailsTest {
assertNotEquals(details, null);
assertNotEquals(details, (Object) "Hello");
- details.setCloudConfiguration(null);
- assertNotEquals(details, copiedDetails);
- copiedDetails.setCloudConfiguration(null);
- assertEquals(details, copiedDetails);
- details.setCloudConfiguration(cloudConfiguration);
- assertNotEquals(details, copiedDetails);
- copiedDetails.setCloudConfiguration(cloudConfiguration);
- assertEquals(details, copiedDetails);
+ checkField(cloudConfiguration, SoRequestDetails::setCloudConfiguration);
+ checkField(modelInfo, SoRequestDetails::setModelInfo);
+ checkField(requestInfo, SoRequestDetails::setRequestInfo);
+ checkField(requestParameters, SoRequestDetails::setRequestParameters);
+ checkField(subscriberInfo, SoRequestDetails::setSubscriberInfo);
+ checkField(relatedInstanceList, SoRequestDetails::setRelatedInstanceList);
+ }
- details.setModelInfo(null);
- assertNotEquals(details, copiedDetails);
- copiedDetails.setModelInfo(null);
- assertEquals(details, copiedDetails);
- details.setModelInfo(modelInfo);
- assertNotEquals(details, copiedDetails);
- copiedDetails.setModelInfo(modelInfo);
- assertEquals(details, copiedDetails);
+ private <T> void checkField(T value, BiConsumer<SoRequestDetails, T> setter) {
+ SoRequestDetails details1 = new SoRequestDetails();
+ SoRequestDetails details2 = new SoRequestDetails(details1);
- details.setRequestInfo(null);
- assertNotEquals(details, copiedDetails);
- copiedDetails.setRequestInfo(null);
- assertEquals(details, copiedDetails);
- details.setRequestInfo(requestInfo);
- assertNotEquals(details, copiedDetails);
- copiedDetails.setRequestInfo(requestInfo);
- assertEquals(details, copiedDetails);
+ setter.accept(details2, null);
- details.setRequestParameters(null);
- assertNotEquals(details, copiedDetails);
- copiedDetails.setRequestParameters(null);
- assertEquals(details, copiedDetails);
- details.setRequestParameters(requestParameters);
- assertNotEquals(details, copiedDetails);
- copiedDetails.setRequestParameters(requestParameters);
- assertEquals(details, copiedDetails);
+ setter.accept(details1, value);
+ assertNotEquals(details1, details2);
- details.setSubscriberInfo(null);
- assertNotEquals(details, copiedDetails);
- copiedDetails.setSubscriberInfo(null);
- assertEquals(details, copiedDetails);
- details.setSubscriberInfo(subscriberInfo);
- assertNotEquals(details, copiedDetails);
- copiedDetails.setSubscriberInfo(subscriberInfo);
- assertEquals(details, copiedDetails);
+ setter.accept(details2, value);
+ assertEquals(details1, details2);
- details.setRelatedInstanceList(null);
- assertNotEquals(details, copiedDetails);
- copiedDetails.setRelatedInstanceList(null);
- assertEquals(details, copiedDetails);
- details.setRelatedInstanceList(relatedInstanceList);
- assertNotEquals(details, copiedDetails);
- copiedDetails.setRelatedInstanceList(relatedInstanceList);
- assertEquals(details, copiedDetails);
+ setter.accept(details1, null);
+ assertNotEquals(details1, details2);
}
}