From 04dee786c77757d8e9b86e9228cba46d717ecd40 Mon Sep 17 00:00:00 2001 From: kurczews Date: Fri, 2 Mar 2018 14:44:03 +0100 Subject: Improve coverage FlowControlNode #8 * refactor & test dependency info method * extract get flow sequence method Change-Id: I6c9ab49676b6c325196ec179e863038550b5dad6 Issue-ID: APPC-440 Signed-off-by: kurczews --- .../flow/controller/node/FlowControlNodeTest.java | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'appc-config/appc-flow-controller/provider/src/test/java/org') 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 index 200a02615..d171f5f8b 100644 --- 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 @@ -27,11 +27,18 @@ package org.onap.appc.flow.controller.node; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; 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.appc.flow.controller.interfaceData.DependencyInfo; +import org.onap.appc.flow.controller.interfaceData.Vnfcs; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; public class FlowControlNodeTest { @@ -70,4 +77,26 @@ public class FlowControlNodeTest { Assert.assertEquals("Capabilities [vnf=[vnf-1, vnf-2], vfModule=[vf-module-1], vm=[], vnfc=[]]", capabilitiesData.toString()); } + @Test + public void should_handle_dependency_config() throws Exception { + + Vnfcs vnfcs = new Vnfcs(); + vnfcs.setVnfcType("some-type"); + vnfcs.setResilience("some-resilence"); + vnfcs.setMandatory("some-mandatory"); + Map> input = new HashMap<>(); + List list = new ArrayList<>(); + list.add(vnfcs); + list.add(vnfcs); + input.put("vnfcs", list); + + String jsonPayload = new ObjectMapper().writeValueAsString(input); + + when(dbService.getDependencyInfo(ctx)).thenReturn(jsonPayload); + + FlowControlNode flowControlNode = new FlowControlNode(null, dbService); + DependencyInfo dependencyInfo = flowControlNode.getDependencyInfo(ctx); + + Assert.assertEquals("DependencyInfo [vnfcs=[Vnfcs [vnfcType=some-type, mandatory=some-mandatory, resilience=some-resilence, parents=[]], Vnfcs [vnfcType=some-type, mandatory=some-mandatory, resilience=some-resilence, parents=[]]]]", dependencyInfo.toString()); + } } -- cgit 1.2.3-korg