summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.test/src/test
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-02-18 15:28:39 -0500
committerJim Hahn <jrh3@att.com>2020-02-18 16:39:14 -0500
commit4ccc26577b51545b4b4db6823c6d926bc0ffc5a4 (patch)
tree81e84b3579d4ac7af81dcc25649db5e3d926c8e5 /models-interactions/model-actors/actor.test/src/test
parentca409ee108f3f653d66be804e8a9f95f794e26d4 (diff)
Validate request content of various actors
Created common junit superclass, BasicOperation, containing verifyRequest() method, among others. Issue-ID: POLICY-2363 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: I7ff4428e94bfd301ff4194e1766ef61906714dcf
Diffstat (limited to 'models-interactions/model-actors/actor.test/src/test')
-rw-r--r--models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperationTest.java30
-rw-r--r--models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicHttpOperationTest.java24
-rw-r--r--models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicOperationTest.java100
-rw-r--r--models-interactions/model-actors/actor.test/src/test/resources/actual.json19
-rw-r--r--models-interactions/model-actors/actor.test/src/test/resources/expected.json19
5 files changed, 138 insertions, 54 deletions
diff --git a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperationTest.java b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperationTest.java
index 4fd559101..9ec118e69 100644
--- a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperationTest.java
+++ b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperationTest.java
@@ -23,7 +23,6 @@ package org.onap.policy.controlloop.actor.test;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.eq;
@@ -81,30 +80,6 @@ public class BasicBidirectionalTopicOperationTest {
}
@Test
- public void testMakeContext() {
- oper.makeContext();
-
- assertTrue(oper.enrichment.isEmpty());
-
- assertSame(BasicBidirectionalTopicOperation.REQ_ID, oper.event.getRequestId());
- assertSame(oper.enrichment, oper.event.getAai());
-
- assertSame(oper.event, oper.context.getEvent());
-
- assertSame(oper.context, oper.params.getContext());
- assertSame(oper.service, oper.params.getActorService());
- assertSame(oper.executor, oper.params.getExecutor());
- assertEquals(ACTOR, oper.params.getActor());
- assertEquals(OPERATION, oper.params.getOperation());
- assertEquals(BasicBidirectionalTopicOperation.TARGET_ENTITY, oper.params.getTargetEntity());
- }
-
- @Test
- public void testMakePayload() {
- assertNull(oper.makePayload());
- }
-
- @Test
public void testInitOperator() {
oper.initOperator();
@@ -118,11 +93,6 @@ public class BasicBidirectionalTopicOperationTest {
}
@Test
- public void testMakeEnrichment() {
- assertTrue(oper.makeEnrichment().isEmpty());
- }
-
- @Test
public void testProvideResponse() {
String response = "{\"input\": 10}";
diff --git a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicHttpOperationTest.java b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicHttpOperationTest.java
index 096b8b80d..c463d6d49 100644
--- a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicHttpOperationTest.java
+++ b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicHttpOperationTest.java
@@ -72,25 +72,6 @@ public class BasicHttpOperationTest {
}
@Test
- public void testMakeContext() {
- oper.makeContext();
-
- assertTrue(oper.enrichment.isEmpty());
-
- assertSame(BasicHttpOperation.REQ_ID, oper.event.getRequestId());
- assertSame(oper.enrichment, oper.event.getAai());
-
- assertSame(oper.event, oper.context.getEvent());
-
- assertSame(oper.context, oper.params.getContext());
- assertSame(oper.service, oper.params.getActorService());
- assertSame(oper.executor, oper.params.getExecutor());
- assertEquals(ACTOR, oper.params.getActor());
- assertEquals(OPERATION, oper.params.getOperation());
- assertEquals(BasicHttpOperation.TARGET_ENTITY, oper.params.getTargetEntity());
- }
-
- @Test
public void testInitOperator() throws Exception {
oper.initOperator();
@@ -103,11 +84,6 @@ public class BasicHttpOperationTest {
}
@Test
- public void testMakeEnrichment() {
- assertTrue(oper.makeEnrichment().isEmpty());
- }
-
- @Test
public void testProvideResponse() throws Exception {
InvocationCallback<Response> cb = new InvocationCallback<>() {
@Override
diff --git a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicOperationTest.java b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicOperationTest.java
new file mode 100644
index 000000000..ee0e5cee4
--- /dev/null
+++ b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicOperationTest.java
@@ -0,0 +1,100 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop.actor.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Map;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.resources.ResourceUtils;
+import org.onap.policy.controlloop.actorserviceprovider.Util;
+
+public class BasicOperationTest {
+ private static final String ACTOR = "my-actor";
+ private static final String OPERATION = "my-operation";
+
+ private BasicOperation oper;
+
+
+ @Before
+ public void setUp() throws Exception {
+ oper = new BasicHttpOperation<>(ACTOR, OPERATION);
+ oper.setUp();
+ }
+
+ @Test
+ public void testBasicHttpOperation() {
+ oper = new BasicHttpOperation<>();
+ assertEquals(BasicHttpOperation.DEFAULT_ACTOR, oper.actorName);
+ assertEquals(BasicHttpOperation.DEFAULT_OPERATION, oper.operationName);
+ }
+
+ @Test
+ public void testBasicHttpOperationStringString() {
+ assertEquals(ACTOR, oper.actorName);
+ assertEquals(OPERATION, oper.operationName);
+ }
+
+ @Test
+ public void testSetUp() throws Exception {
+ assertNotNull(oper.future);
+ assertNotNull(oper.context);
+ assertNotNull(oper.outcome);
+ assertNotNull(oper.executor);
+ }
+
+ @Test
+ public void testMakeContext() {
+ oper.makeContext();
+
+ assertTrue(oper.enrichment.isEmpty());
+
+ assertSame(BasicHttpOperation.REQ_ID, oper.event.getRequestId());
+ assertSame(oper.enrichment, oper.event.getAai());
+
+ assertSame(oper.event, oper.context.getEvent());
+
+ assertSame(oper.context, oper.params.getContext());
+ assertSame(oper.service, oper.params.getActorService());
+ assertSame(oper.executor, oper.params.getExecutor());
+ assertEquals(ACTOR, oper.params.getActor());
+ assertEquals(OPERATION, oper.params.getOperation());
+ assertEquals(BasicHttpOperation.TARGET_ENTITY, oper.params.getTargetEntity());
+ }
+
+ @Test
+ public void testMakeEnrichment_testMakePayload() {
+ assertTrue(oper.makeEnrichment().isEmpty());
+ assertNull(oper.makePayload());
+ }
+
+ @Test
+ public void testVerifyRequest() throws CoderException {
+ Map<String, Object> map = Util.translateToMap("", ResourceUtils.getResourceAsString("actual.json"));
+ oper.verifyRequest("expected.json", map, "svc-request-id", "vnf-id");
+ }
+}
diff --git a/models-interactions/model-actors/actor.test/src/test/resources/actual.json b/models-interactions/model-actors/actor.test/src/test/resources/actual.json
new file mode 100644
index 000000000..c551cd05d
--- /dev/null
+++ b/models-interactions/model-actors/actor.test/src/test/resources/actual.json
@@ -0,0 +1,19 @@
+
+
+{
+ "input": {
+ "sdnc-request-header": {
+ "svc-request-id": "actual-value",
+ "svc-action": "update"
+ },
+ "request-information": {
+ "request-action": "SdwanBandwidthChange"
+ },
+ "service-information": {
+ "service-instance-id": "my-service"
+ },
+ "vnf-information": {
+ "vnf-id": "actual-value"
+ }
+ }
+}
diff --git a/models-interactions/model-actors/actor.test/src/test/resources/expected.json b/models-interactions/model-actors/actor.test/src/test/resources/expected.json
new file mode 100644
index 000000000..85fbc9957
--- /dev/null
+++ b/models-interactions/model-actors/actor.test/src/test/resources/expected.json
@@ -0,0 +1,19 @@
+{
+ "input": {
+ "sdnc-request-header": {
+ "svc-request-id": "expected-value",
+ "svc-action": "update"
+ },
+ "request-information": {
+ "request-action": "SdwanBandwidthChange"
+ },
+ "service-information": {
+ "service-instance-id": "my-service"
+ },
+ "vnf-information": {
+ "vnf-id": "expected-value"
+ }
+ }
+}
+
+