summaryrefslogtreecommitdiffstats
path: root/appc-config/appc-flow-controller/provider/src/test/java
diff options
context:
space:
mode:
authorkurczews <krzysztof.kurczewski@nokia.com>2018-03-02 14:10:26 +0100
committerTakamune Cho <tc012c@att.com>2018-03-12 15:12:42 +0000
commit20eaa8a699ea41b7c40bbee7364dd3554af45606 (patch)
tree30f0a6600dd27590fcd9b6cab0ee4f51e077b18b /appc-config/appc-flow-controller/provider/src/test/java
parentbb446bb30604c107be83b5cd10bee6b0a00eb8ad (diff)
Improve coverage FlowControlNode #7
* refactor & test capabilities data method Change-Id: I523d07e283a347a4ad16f3babc8a25e0dd5a6acc Issue-ID: APPC-440 Signed-off-by: kurczews <krzysztof.kurczewski@nokia.com>
Diffstat (limited to 'appc-config/appc-flow-controller/provider/src/test/java')
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowControlNodeTest.java73
1 files changed, 73 insertions, 0 deletions
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowControlNodeTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowControlNodeTest.java
new file mode 100644
index 000000000..200a02615
--- /dev/null
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowControlNodeTest.java
@@ -0,0 +1,73 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.flow.controller.node;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.appc.flow.controller.dbervices.FlowControlDBService;
+import org.onap.appc.flow.controller.interfaceData.Capabilities;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+
+public class FlowControlNodeTest {
+
+ private SvcLogicContext ctx;
+ private FlowControlDBService dbService;
+
+ @Before
+ public void setUp() {
+ ctx = mock(SvcLogicContext.class);
+ dbService = mock(FlowControlDBService.class);
+ }
+
+ @Test
+ public void should_handle_capabilities_full_config() throws Exception {
+
+ String jsonPayload = "{'vnf':['vnf-1', 'vnf-2'],'vf-module':['vf-module-1', 'vf-module-2'],'vnfc':['vnfc-1', 'vnfc-2'],'vm':['vm-1', 'vm-2']}";
+ when(dbService.getCapabilitiesData(ctx)).thenReturn(jsonPayload.replaceAll("'","\""));
+
+ FlowControlNode flowControlNode = new FlowControlNode(null, dbService);
+ Capabilities capabilitiesData = flowControlNode.getCapabilitiesData(ctx);
+
+ Assert.assertEquals("Capabilities [vnf=[vnf-1, vnf-2], vfModule=[vf-module-1, vf-module-2], vm=[vm-1, vm-2], vnfc=[vnfc-1, vnfc-2]]", capabilitiesData.toString());
+ }
+
+ @Test
+ public void should_handle_capabilities_config_with_missing_params() throws Exception {
+
+ // vm is empty, vnfc is absent
+ String jsonPayload = "{'vnf':['vnf-1', 'vnf-2'],'vf-module':['vf-module-1'],'vm':[]}";
+ when(dbService.getCapabilitiesData(ctx)).thenReturn(jsonPayload.replaceAll("'","\""));
+
+ FlowControlNode flowControlNode = new FlowControlNode(null, dbService);
+ Capabilities capabilitiesData = flowControlNode.getCapabilitiesData(ctx);
+
+ Assert.assertEquals("Capabilities [vnf=[vnf-1, vnf-2], vfModule=[vf-module-1], vm=[], vnfc=[]]", capabilitiesData.toString());
+ }
+
+}