summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.cds/src/test
diff options
context:
space:
mode:
authorRashmi Pujar <rashmi.pujar@bell.ca>2019-10-22 15:58:38 -0400
committerRashmi Pujar <rashmi.pujar@bell.ca>2019-10-23 13:29:15 -0400
commitfc3c22635307c5ff534a7f5673fcf2307e64a8ef (patch)
tree834b53e2af43ad53d42602513ec8ae540dc88fac /models-interactions/model-actors/actor.cds/src/test
parentd0cca771fa39943a46470240cd0106941056e974 (diff)
Flatten the CDS grpc request payload
Before: { "vfw-modify-config-request":{ "resolution-key":"1234567890", "aai-properties":{ "service-instance.service-instance-id":"1234", "generic-vnf.vnf-id":"5678" }, "policy-payload":{ "data":"{\"active-streams\":\"5\"}" } } } After: { "vfw-modify-config-request":{ "resolution-key":"1234567890", "vfw-modify-config-properties":{ "service-instance.service-instance-id":"1234", "generic-vnf.vnf-id":"5678", "data":"{\"active-streams\":\"5\"}" } } } Issue-ID: POLICY-2089 Signed-off-by: Rashmi Pujar <rashmi.pujar@bell.ca> Change-Id: I139a7ca3e1e2d0cd50bbd86d0cdf499f215be74f
Diffstat (limited to 'models-interactions/model-actors/actor.cds/src/test')
-rw-r--r--models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/request/CdsActionRequestTest.java54
1 files changed, 54 insertions, 0 deletions
diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/request/CdsActionRequestTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/request/CdsActionRequestTest.java
new file mode 100644
index 000000000..3f28bada4
--- /dev/null
+++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/request/CdsActionRequestTest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Bell Canada. 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.cds.request;
+
+import static org.junit.Assert.assertTrue;
+
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
+import org.junit.Test;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.controlloop.actor.cds.constants.CdsActorConstants;
+
+public class CdsActionRequestTest {
+
+ private static final String TEST_ACTION_NAME = "vfw-modify-config";
+
+ @Test
+ public void testGenerateCdsPayload() throws CoderException {
+ // Setup the CdsActionRequest object
+ CdsActionRequest req = new CdsActionRequest();
+ req.setActionName(TEST_ACTION_NAME);
+ req.setResolutionKey("1234567890");
+ Map<String, String> payloadProps = ImmutableMap.of("data", "{\"active-streams\":\"5\"}");
+ req.setPolicyPayload(payloadProps);
+
+ Map<String, String> aaiParams =
+ ImmutableMap.of("service-instance.service-instance-id", "1234", "generic-vnf.vnf-id", "5678");
+ req.setAaiProperties(aaiParams);
+
+ // Act
+ String result = req.generateCdsPayload();
+
+ // Assert
+ assertTrue(result.contains(TEST_ACTION_NAME + CdsActorConstants.CDS_REQUEST_PROPERTIES_SUFFIX));
+ assertTrue(result.contains(TEST_ACTION_NAME + CdsActorConstants.CDS_REQUEST_SUFFIX));
+ assertTrue(result.contains(CdsActorConstants.KEY_RESOLUTION_KEY));
+ }
+}