summaryrefslogtreecommitdiffstats
path: root/appc-dg/appc-dg-shared/appc-dg-common/src
diff options
context:
space:
mode:
authorRamya Balaji <rb111y@att.com>2018-01-02 21:58:59 -0500
committerSkip Wonnell <skip@att.com>2018-01-04 21:10:36 +0000
commit13b9505921e2cbbd4b155a78bfdaa5caa3375ec0 (patch)
tree7c661f5c3c8b7895cad1d4c3c90b9077ba74c1fd /appc-dg/appc-dg-shared/appc-dg-common/src
parent9ebb5ddcb60345dea668049c73f5f2d9c3cdf731 (diff)
Updated SDC listener and dependent bundles
Changes related to SDC adapter.Also includes sequence generator changes and changes to appc-dg-shared. Issue-ID: APPC-355 Change-Id: Ib8a0b1d304199db6d2595291539b266885842d63 Signed-off-by: Ramya Balaji <rb111y@att.com>
Diffstat (limited to 'appc-dg/appc-dg-shared/appc-dg-common/src')
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/JsonDgUtilImpl.java4
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/VnfExecutionFlowImpl.java137
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/DCAEReporterPluginImplTest.java5
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/VnfExecutionFlowImplTest.java (renamed from appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestVnfExecutionFlowImpl.java)105
4 files changed, 144 insertions, 107 deletions
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/JsonDgUtilImpl.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/JsonDgUtilImpl.java
index fff43cbf5..caad8b809 100644
--- a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/JsonDgUtilImpl.java
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/JsonDgUtilImpl.java
@@ -29,7 +29,7 @@ import java.text.SimpleDateFormat;
import java.util.Map;
import java.util.Set;
-import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.onap.appc.dg.common.JsonDgUtil;
import org.onap.appc.exceptions.APPCException;
@@ -63,7 +63,7 @@ public class JsonDgUtilImpl implements JsonDgUtil {
try {
String paramName = Constants.PAYLOAD;
String payload = params.get(paramName);
- if (payload == "")
+ if (payload == null || payload.isEmpty())
payload = ctx.getAttribute("input.payload");
if (!StringUtils.isEmpty(payload)) {
Map<String, String> flatMap = JsonUtil.convertJsonStringToFlatMap(payload);
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/VnfExecutionFlowImpl.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/VnfExecutionFlowImpl.java
index 65b364f62..8129e2e02 100644
--- a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/VnfExecutionFlowImpl.java
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/VnfExecutionFlowImpl.java
@@ -28,6 +28,7 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.att.eelf.i18n.EELFResourceManager;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.appc.exceptions.APPCException;
import java.util.*;
@@ -36,7 +37,7 @@ import org.onap.appc.dg.dependencymanager.DependencyManager;
import org.onap.appc.dg.dependencymanager.exception.DependencyModelNotFound;
import org.onap.appc.dg.dependencymanager.impl.DependencyModelFactory;
import org.onap.appc.dg.flowbuilder.FlowBuilder;
-import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModel;
+import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException;
import org.onap.appc.dg.flowbuilder.impl.FlowBuilderFactory;
import org.onap.appc.dg.objects.*;
import org.onap.appc.domainmodel.Vnf;
@@ -47,10 +48,15 @@ import org.onap.appc.metadata.objects.DependencyModelIdentifier;
public class VnfExecutionFlowImpl implements VnfExecutionFlow {
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(VnfExecutionFlowImpl.class);
-
+ private final EELFLogger logger = EELFManager.getInstance().getLogger(VnfExecutionFlowImpl.class);
+ private static final String VNFC_FLOW="vnfcFlow[";
+ private static final String VNF_VNFC="vnf.vnfc[";
+ /**
+ * Constructor
+ * <p>Used through blueprint
+ */
public VnfExecutionFlowImpl(){
-
+ // do nothing
}
@Override
@@ -58,7 +64,7 @@ public class VnfExecutionFlowImpl implements VnfExecutionFlow {
String dependencyType = params.get(Constants.DEPENDENCY_TYPE);
String flowStrategy = params.get(Constants.FLOW_STRATEGY);
DependencyModelIdentifier modelIdentifier = readDependencyModelIdentifier(params);
- VnfcDependencyModel dependencyModel = null;
+ VnfcDependencyModel dependencyModel;
try {
validateInput(dependencyType, flowStrategy, params);
@@ -69,8 +75,6 @@ public class VnfExecutionFlowImpl implements VnfExecutionFlow {
}
DependencyManager dependencyManager = DependencyModelFactory.createDependencyManager();
-
-
dependencyModel = dependencyManager.getVnfcDependencyModel(
modelIdentifier, DependencyTypes.findByString(dependencyType));
} catch (DependencyModelNotFound e) {
@@ -79,12 +83,17 @@ public class VnfExecutionFlowImpl implements VnfExecutionFlow {
context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE,msg);
context.setAttribute("dependencyModelFound","false");
return;
- } catch (InvalidDependencyModel e){
+ } catch (InvalidDependencyModelException e){
String msg = EELFResourceManager.format(Msg.INVALID_DEPENDENCY_MODEL,params.get(Constants.VNF_TYPE), e.getMessage());
logger.error(msg);
context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE,msg);
- throw e;
- }catch (RuntimeException e){
+ throw new RuntimeException(e.getMessage(),e);
+ } catch (APPCException e){
+ logger.error(e.getMessage());
+ context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE,e.getMessage());
+ throw new RuntimeException(e.getMessage(),e);
+ }
+ catch (RuntimeException e){
logger.error(e.getMessage());
context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE,e.getMessage());
throw e;
@@ -96,7 +105,14 @@ public class VnfExecutionFlowImpl implements VnfExecutionFlow {
logger.debug("Dependency Model = " +dependencyModel);
}
logger.info("Building Inventory Model from DG context");
- InventoryModel inventoryModel = readInventoryModel(context);
+ InventoryModel inventoryModel = null;
+ try {
+ inventoryModel = readInventoryModel(context);
+ } catch (APPCException e) {
+ logger.error(e.getMessage());
+ context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE,e.getMessage());
+ throw new RuntimeException(e.getMessage(),e);
+ }
if(logger.isDebugEnabled()){
logger.debug("Inventory Model = " +inventoryModel);
}
@@ -106,25 +122,26 @@ public class VnfExecutionFlowImpl implements VnfExecutionFlow {
}
try {
validateInventoryModelWithDependencyModel(dependencyModel, inventoryModel);
- }catch (RuntimeException e){
+ }
+ catch (APPCException e){
logger.error(e.getMessage());
context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE,e.getMessage());
- throw e;
+ throw new RuntimeException(e.getMessage(),e);
}
logger.info("Creating flow builder");
FlowBuilder flowBuilder = FlowBuilderFactory.getInstance().getFlowBuilder(
FlowStrategies.findByString(flowStrategy));
logger.info("Building Vnf flow model");
- VnfcFlowModel flowModel = null;
+ VnfcFlowModel flowModel;
try{
flowModel = flowBuilder.buildFlowModel(dependencyModel,inventoryModel);
}
- catch (InvalidDependencyModel e){
+ catch (InvalidDependencyModelException e){
String msg = EELFResourceManager.format(Msg.INVALID_DEPENDENCY_MODEL,params.get(Constants.VNF_TYPE), e.getMessage());
logger.error(msg);
context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE,msg);
- throw e;
+ throw new RuntimeException(e.getMessage(),e);
}
// remove VNFCs from the flow model where vserver list is empty
@@ -137,22 +154,22 @@ public class VnfExecutionFlowImpl implements VnfExecutionFlow {
context.setAttribute(org.onap.appc.Constants.ATTRIBUTE_SUCCESS_MESSAGE, msg);
}
- private void validateInput(String dependencyType, String flowStrategy, Map<String, String> params) {
+ private void validateInput(String dependencyType, String flowStrategy, Map<String, String> params) throws APPCException {
DependencyTypes dependencyTypes = DependencyTypes.findByString(dependencyType);
if(dependencyTypes == null){
- throw new RuntimeException("Dependency type from the input : " + dependencyType +" is invalid.");
+ throw new APPCException("Dependency type from the input : " + dependencyType +" is invalid.");
}
FlowStrategies flowStrategies = FlowStrategies.findByString(flowStrategy);
if(flowStrategies == null){
- throw new RuntimeException("Flow Strategy from the input : " + flowStrategy +" is invalid.");
+ throw new APPCException("Flow Strategy from the input : " + flowStrategy +" is invalid.");
}
String vnfType = params.get(Constants.VNF_TYPE);
if(vnfType ==null || vnfType.length() ==0){
- throw new RuntimeException("Vnf Type is not passed in the input");
+ throw new APPCException("Vnf Type is not passed in the input");
}
String vnfVersion = params.get(Constants.VNF_VERION);
if(vnfVersion == null || vnfVersion.length() ==0){
- throw new RuntimeException("Vnf Version not found");
+ throw new APPCException("Vnf Version not found");
}
}
@@ -167,13 +184,13 @@ public class VnfExecutionFlowImpl implements VnfExecutionFlow {
Iterator<List<Vnfc>> iterator = flowModel.getModelIterator();
while (iterator.hasNext()){
for(Vnfc vnfc:iterator.next()){
- context.setAttribute("vnfcFlow["+flowIndex+"].vnfcName",vnfc.getVnfcName());
- context.setAttribute("vnfcFlow["+flowIndex+"].vnfcType",vnfc.getVnfcType());
- context.setAttribute("vnfcFlow["+flowIndex+"].resilienceType",vnfc.getResilienceType());
- context.setAttribute("vnfcFlow["+flowIndex+"].vmCount",Integer.toString(vnfc.getVserverList().size()));
+ context.setAttribute(VNFC_FLOW+flowIndex+"].vnfcName",vnfc.getVnfcName());
+ context.setAttribute(VNFC_FLOW+flowIndex+"].vnfcType",vnfc.getVnfcType());
+ context.setAttribute(VNFC_FLOW+flowIndex+"].resilienceType",vnfc.getResilienceType());
+ context.setAttribute(VNFC_FLOW+flowIndex+"].vmCount",Integer.toString(vnfc.getVserverList().size()));
int vmIndex =0;
for(Vserver vm :vnfc.getVserverList()){
- context.setAttribute("vnfcFlow["+flowIndex+"].vm["+vmIndex+"].url",vm.getUrl());
+ context.setAttribute(VNFC_FLOW+flowIndex+"].vm["+vmIndex+"].url",vm.getUrl());
vmIndex++;
}
flowIndex++;
@@ -182,73 +199,88 @@ public class VnfExecutionFlowImpl implements VnfExecutionFlow {
context.setAttribute("vnfcFlowCount",Integer.toString(flowIndex));
}
- private InventoryModel readInventoryModel(SvcLogicContext context) {
+ private InventoryModel readInventoryModel(SvcLogicContext context) throws APPCException {
String vnfId = context.getAttribute("input.action-identifiers.vnf-id");
String vnfType = context.getAttribute("vnf.type");
String vnfVersion = context.getAttribute("vnf.version");
String vnfcCountStr = context.getAttribute("vnf.vnfcCount");
Integer vnfcCount = Integer.parseInt(vnfcCountStr);
-
- Vnf vnf = new Vnf(vnfId,vnfType,vnfVersion);
-
+ Vnf vnf = createVnf(vnfId, vnfType, vnfVersion);
for(Integer i=0;i<vnfcCount;i++){
- String vnfcName = context.getAttribute("vnf.vnfc["+ i+"].name");
- String vnfcType = context.getAttribute("vnf.vnfc["+ i+"].type");
- String vmCountStr = context.getAttribute("vnf.vnfc["+ i+"].vm_count");
+ String vnfcName = context.getAttribute(VNF_VNFC+ i+"].name");
+ String vnfcType = context.getAttribute(VNF_VNFC+ i+"].type");
+ String vmCountStr = context.getAttribute(VNF_VNFC+ i+"].vm_count");
if(vnfcType ==null || vnfcType.length() ==0){
- throw new RuntimeException("Could not retrieve VNFC Type from DG Context for vnf.vnfc["+ i+"].type");
+ throw new APPCException("Could not retrieve VNFC Type from DG Context for vnf.vnfc["+ i+"].type");
}
Integer vmCount = Integer.parseInt(vmCountStr);
- Vnfc vnfc = new Vnfc(vnfcType,null,vnfcName);
+ Vnfc vnfc = createVnfc(vnfcName, vnfcType);
for(Integer j=0;j<vmCount;j++){
- String vmURL = context.getAttribute("vnf.vnfc["+i+"].vm["+j+"].url");
- Vserver vm = new Vserver(vmURL);
- vnfc.addVm(vm);
+ String vmURL = context.getAttribute(VNF_VNFC+i+"].vm["+j+"].url");
+ Vserver vm = createVserver(vmURL);
+ vm.setVnfc(vnfc);
+ vnfc.addVserver(vm);
+ vnf.addVserver(vm);
}
- vnf.addVnfc(vnfc);
}
return new InventoryModel(vnf);
}
+ private Vserver createVserver(String vmURL) {
+ Vserver vserver = new Vserver();
+ vserver.setUrl(vmURL);
+ return vserver;
+ }
+
+ private Vnfc createVnfc(String vnfcName, String vnfcType) {
+ Vnfc vnfc =new Vnfc();
+ vnfc.setVnfcName(vnfcName);
+ vnfc.setVnfcType(vnfcType);
+ return vnfc;
+ }
+
+ private Vnf createVnf(String vnfId, String vnfType, String vnfVersion) {
+ Vnf vnf =new Vnf();
+ vnf.setVnfType(vnfType);
+ vnf.setVnfId(vnfId);
+ vnf.setVnfVersion(vnfVersion);
+ return vnf;
+ }
+
private DependencyModelIdentifier readDependencyModelIdentifier(Map<String, String> params) {
String vnfType = params.get(Constants.VNF_TYPE);
String catalogVersion = params.get(Constants.VNF_VERION);
return new DependencyModelIdentifier(vnfType,catalogVersion);
}
- private void validateInventoryModelWithDependencyModel(VnfcDependencyModel dependencyModel, InventoryModel inventoryModel) {
- Set<String> dependencyModelVnfcSet = new HashSet<String>();
- Set<String> dependencyModelMandatoryVnfcSet = new HashSet<String>();
- Set<String> inventoryModelVnfcsSet = new HashSet<String>();
-
+ private void validateInventoryModelWithDependencyModel(VnfcDependencyModel dependencyModel, InventoryModel inventoryModel) throws APPCException {
+ Set<String> dependencyModelVnfcSet = new HashSet<>();
+ Set<String> dependencyModelMandatoryVnfcSet = new HashSet<>();
+ Set<String> inventoryModelVnfcsSet = new HashSet<>();
for (Node<Vnfc> node : dependencyModel.getDependencies()) {
dependencyModelVnfcSet.add(node.getChild().getVnfcType().toLowerCase());
if (node.getChild().isMandatory()) {
dependencyModelMandatoryVnfcSet.add(node.getChild().getVnfcType().toLowerCase());
}
}
-
for (Vnfc vnfc : inventoryModel.getVnf().getVnfcs()) {
inventoryModelVnfcsSet.add(vnfc.getVnfcType().toLowerCase());
}
-
// if dependency model and inventory model contains same set of VNFCs, validation succeed and hence return
if (dependencyModelVnfcSet.equals(inventoryModelVnfcsSet)) {
return;
}
-
if (inventoryModelVnfcsSet.size() >= dependencyModelVnfcSet.size()) {
- Set<String> difference = new HashSet<String>(inventoryModelVnfcsSet);
+ Set<String> difference = new HashSet<>(inventoryModelVnfcsSet);
difference.removeAll(dependencyModelVnfcSet);
logger.error("Dependency model is missing following vnfc type(s): " + difference);
- throw new RuntimeException("Dependency model is missing following vnfc type(s): " + difference);
+ throw new APPCException("Dependency model is missing following vnfc type(s): " + difference);
} else {
- Set<String> difference = new HashSet<String>(dependencyModelVnfcSet);
+ Set<String> difference = new HashSet<>(dependencyModelMandatoryVnfcSet);
difference.removeAll(inventoryModelVnfcsSet);
- difference.retainAll(dependencyModelMandatoryVnfcSet);
if (difference.size() > 0) {
logger.error("Inventory model is missing following mandatory vnfc type(s): " + difference);
- throw new RuntimeException("Inventory model is missing following mandatory vnfc type(s): " + difference);
+ throw new APPCException("Inventory model is missing following mandatory vnfc type(s): " + difference);
}
}
}
@@ -268,4 +300,5 @@ public class VnfExecutionFlowImpl implements VnfExecutionFlow {
}
}
}
+
}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/DCAEReporterPluginImplTest.java b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/DCAEReporterPluginImplTest.java
index 7c36360f8..42f7a6bc6 100644
--- a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/DCAEReporterPluginImplTest.java
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/DCAEReporterPluginImplTest.java
@@ -28,7 +28,10 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.*;
+import org.mockito.InjectMocks;
+import org.mockito.Matchers;
+import org.mockito.Mockito;
+import org.mockito.Spy;
import org.onap.appc.adapter.message.EventSender;
import org.onap.appc.adapter.message.MessageDestination;
import org.onap.appc.adapter.message.event.EventMessage;
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestVnfExecutionFlowImpl.java b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/VnfExecutionFlowImplTest.java
index bad862030..558a463ac 100644
--- a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestVnfExecutionFlowImpl.java
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/VnfExecutionFlowImplTest.java
@@ -26,23 +26,19 @@ package org.onap.appc.dg.common.impl;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Matchers;
import org.onap.appc.dg.common.VnfExecutionFlow;
-import org.onap.appc.dg.common.impl.Constants;
-import org.onap.appc.dg.common.impl.VnfExecutionFlowImpl;
import org.onap.appc.dg.dependencymanager.DependencyManager;
import org.onap.appc.dg.dependencymanager.exception.DependencyModelNotFound;
import org.onap.appc.dg.dependencymanager.impl.DependencyModelFactory;
-import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModel;
-import org.onap.appc.dg.objects.DependencyTypes;
+import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException;
import org.onap.appc.dg.objects.Node;
import org.onap.appc.dg.objects.VnfcDependencyModel;
import org.onap.appc.domainmodel.Vnfc;
-import org.onap.appc.metadata.objects.DependencyModelIdentifier;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.osgi.framework.FrameworkUtil;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
@@ -54,10 +50,11 @@ import java.util.Map;
import java.util.Set;
@RunWith(PowerMockRunner.class)
-@PrepareForTest({TestVnfExecutionFlowImpl.class, FrameworkUtil.class,DependencyManager.class,DependencyModelFactory.class})
-public class TestVnfExecutionFlowImpl {
+@PrepareForTest({VnfExecutionFlowImplTest.class, FrameworkUtil.class,DependencyManager.class,DependencyModelFactory.class})
+@SuppressWarnings("unchecked")
+public class VnfExecutionFlowImplTest {
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(TestVnfExecutionFlowImpl.class);
+ private final EELFLogger logger = EELFManager.getInstance().getLogger(VnfExecutionFlowImplTest.class);
@Before
public void setUp() {
@@ -65,7 +62,7 @@ public class TestVnfExecutionFlowImpl {
}
@Test
- public void testPositiveFlow() throws DependencyModelNotFound {
+ public void testPositiveFlow() throws DependencyModelNotFound, InvalidDependencyModelException {
Map<String, String> params = prepareParams();
SvcLogicContext context = prepareContext();
VnfcDependencyModel dependencyModel = readDependencyModel();
@@ -74,8 +71,7 @@ public class TestVnfExecutionFlowImpl {
DependencyManager dependencyManager = PowerMockito.mock(DependencyManager.class);
PowerMockito.when(DependencyModelFactory.createDependencyManager()).thenReturn(dependencyManager);
- PowerMockito.when(dependencyManager.getVnfcDependencyModel((
- DependencyModelIdentifier) Matchers.any(),(DependencyTypes) Matchers.any()))
+ PowerMockito.when(dependencyManager.getVnfcDependencyModel(Matchers.any(), Matchers.any()))
.thenReturn(dependencyModel);
VnfExecutionFlow vnfExecutionFlow = new VnfExecutionFlowImpl();
@@ -83,7 +79,7 @@ public class TestVnfExecutionFlowImpl {
}
@Test
- public void testComplexFlow() throws DependencyModelNotFound {
+ public void testComplexFlow() throws DependencyModelNotFound, InvalidDependencyModelException {
Map<String, String> params = prepareParams();
SvcLogicContext context = prepareContextForComplexDependency();
VnfcDependencyModel dependencyModel = readComplexDependencyModel();
@@ -92,16 +88,15 @@ public class TestVnfExecutionFlowImpl {
DependencyManager dependencyManager = PowerMockito.mock(DependencyManager.class);
PowerMockito.when(DependencyModelFactory.createDependencyManager()).thenReturn(dependencyManager);
- PowerMockito.when(dependencyManager.getVnfcDependencyModel((
- DependencyModelIdentifier) Matchers.any(),(DependencyTypes) Matchers.any()))
+ PowerMockito.when(dependencyManager.getVnfcDependencyModel(Matchers.any(), Matchers.any()))
.thenReturn(dependencyModel);
VnfExecutionFlow vnfExecutionFlow = new VnfExecutionFlowImpl();
vnfExecutionFlow.getVnfExecutionFlowData(params,context);
}
- @Test(expected = InvalidDependencyModel.class)
- public void testCycleFlow() throws DependencyModelNotFound {
+ @Test(expected = RuntimeException.class)
+ public void testCycleFlow() throws DependencyModelNotFound, InvalidDependencyModelException {
Map<String, String> params = prepareParams();
SvcLogicContext context = prepareContextForComplexDependency();
VnfcDependencyModel dependencyModel = readCyclicDependencyModel();
@@ -109,8 +104,7 @@ public class TestVnfExecutionFlowImpl {
DependencyManager dependencyManager = PowerMockito.mock(DependencyManager.class);
PowerMockito.when(DependencyModelFactory.createDependencyManager()).thenReturn(dependencyManager);
- PowerMockito.when(dependencyManager.getVnfcDependencyModel((
- DependencyModelIdentifier) Matchers.any(),(DependencyTypes) Matchers.any()))
+ PowerMockito.when(dependencyManager.getVnfcDependencyModel(Matchers.any(), Matchers.any()))
.thenReturn(dependencyModel);
VnfExecutionFlow vnfExecutionFlow = new VnfExecutionFlowImpl();
@@ -119,13 +113,13 @@ public class TestVnfExecutionFlowImpl {
private VnfcDependencyModel readCyclicDependencyModel() {
- Vnfc a = new Vnfc("A","Active-Passive",null);
- Vnfc b = new Vnfc("B","Active-Active",null);
- Vnfc c = new Vnfc("C","Active-Active",null);
- Vnfc d = new Vnfc("D","Active-Active",null);
- Vnfc e = new Vnfc("E","Active-Active",null);
- Vnfc f = new Vnfc("F","Active-Active",null);
- Vnfc g = new Vnfc("G","Active-Active",null);
+ Vnfc a = createVnfc("A","Active-Passive",null,false);
+ Vnfc b = createVnfc("B","Active-Active",null,false);
+ Vnfc c = createVnfc("C","Active-Active",null,false);
+ Vnfc d = createVnfc("D","Active-Active",null,false);
+ Vnfc e = createVnfc("E","Active-Active",null,false);
+ Vnfc f = createVnfc("F","Active-Active",null,false);
+ Vnfc g = createVnfc("G","Active-Active",null,false);
Node aNode = new Node(a);
Node bNode = new Node(b);
@@ -155,6 +149,15 @@ public class TestVnfExecutionFlowImpl {
}
+ private Vnfc createVnfc(String vnfcType,String resilienceType,String vnfcName,boolean mandatory) {
+ Vnfc vnfc = new Vnfc();
+ vnfc.setVnfcType(vnfcType);
+ vnfc.setResilienceType(resilienceType);
+ vnfc.setVnfcName(vnfcName);
+ vnfc.setMandatory(mandatory);
+ return vnfc;
+ }
+
private SvcLogicContext prepareContextForComplexDependency() {
SvcLogicContext context = new SvcLogicContext();
context.setAttribute("input.action-identifiers.vnf-id","1");
@@ -212,13 +215,13 @@ public class TestVnfExecutionFlowImpl {
}
private VnfcDependencyModel readComplexDependencyModel() {
- Vnfc a = new Vnfc("A","Active-Passive",null);
- Vnfc b = new Vnfc("B","Active-Active",null);
- Vnfc c = new Vnfc("C","Active-Active",null);
- Vnfc d = new Vnfc("D","Active-Active",null);
- Vnfc e = new Vnfc("E","Active-Active",null);
- Vnfc f = new Vnfc("F","Active-Active",null);
- Vnfc g = new Vnfc("G","Active-Active",null);
+ Vnfc a = createVnfc("A","Active-Passive",null,false);
+ Vnfc b = createVnfc("B","Active-Active",null,false);
+ Vnfc c = createVnfc("C","Active-Active",null,false);
+ Vnfc d = createVnfc("D","Active-Active",null,false);
+ Vnfc e = createVnfc("E","Active-Active",null,false);
+ Vnfc f = createVnfc("F","Active-Active",null,false);
+ Vnfc g = createVnfc("G","Active-Active",null,false);
Node aNode = new Node(a);
@@ -254,9 +257,9 @@ public class TestVnfExecutionFlowImpl {
private VnfcDependencyModel readDependencyModel() {
- Vnfc smp = new Vnfc("SMP","Active-Passive",null);
- Vnfc be = new Vnfc("BE","Active-Active",null);
- Vnfc fe = new Vnfc("FE","Active-Active",null);
+ Vnfc smp = createVnfc("SMP","Active-Passive",null,false);
+ Vnfc be = createVnfc("BE","Active-Active",null,false);
+ Vnfc fe = createVnfc("FE","Active-Active",null,false);
Node smpNode = new Node(smp);
@@ -316,7 +319,7 @@ public class TestVnfExecutionFlowImpl {
}
@Test(expected = RuntimeException.class)
- public void testMissingVnfcTypeInDependencyModel() throws DependencyModelNotFound {
+ public void testMissingVnfcTypeInDependencyModel() throws DependencyModelNotFound, InvalidDependencyModelException {
Map<String, String> params = prepareParams();
SvcLogicContext context = prepareContext();
context.setAttribute("vnf.vnfc[3].name","XEname");
@@ -332,8 +335,7 @@ public class TestVnfExecutionFlowImpl {
DependencyManager dependencyManager = PowerMockito.mock(DependencyManager.class);
PowerMockito.when(DependencyModelFactory.createDependencyManager()).thenReturn(dependencyManager);
- PowerMockito.when(dependencyManager.getVnfcDependencyModel((
- DependencyModelIdentifier) Matchers.any(),(DependencyTypes) Matchers.any()))
+ PowerMockito.when(dependencyManager.getVnfcDependencyModel(Matchers.any(), Matchers.any()))
.thenReturn(dependencyModel);
VnfExecutionFlow vnfExecutionFlow = new VnfExecutionFlowImpl();
@@ -341,12 +343,12 @@ public class TestVnfExecutionFlowImpl {
}
@Test(expected = RuntimeException.class)
- public void testMissingMandatoryVnfcTypeInInventoryModel() throws DependencyModelNotFound {
+ public void testMissingMandatoryVnfcTypeInInventoryModel() throws DependencyModelNotFound, InvalidDependencyModelException {
Map<String, String> params = prepareParams();
SvcLogicContext context = prepareContext();
VnfcDependencyModel dependencyModel = readDependencyModel();
- Vnfc xe = new Vnfc("XE","Active-Active",null, true);
+ Vnfc xe = createVnfc("XE","Active-Active",null, true);
Node xeNode = new Node(xe);
dependencyModel.getDependencies().add(xeNode);
@@ -354,8 +356,7 @@ public class TestVnfExecutionFlowImpl {
DependencyManager dependencyManager = PowerMockito.mock(DependencyManager.class);
PowerMockito.when(DependencyModelFactory.createDependencyManager()).thenReturn(dependencyManager);
- PowerMockito.when(dependencyManager.getVnfcDependencyModel((
- DependencyModelIdentifier) Matchers.any(),(DependencyTypes) Matchers.any()))
+ PowerMockito.when(dependencyManager.getVnfcDependencyModel(Matchers.any(), Matchers.any()))
.thenReturn(dependencyModel);
VnfExecutionFlow vnfExecutionFlow = new VnfExecutionFlowImpl();
@@ -363,12 +364,12 @@ public class TestVnfExecutionFlowImpl {
}
@Test
- public void testMissingOptionalVnfcTypeInInventoryModel() throws DependencyModelNotFound {
+ public void testMissingOptionalVnfcTypeInInventoryModel() throws DependencyModelNotFound, InvalidDependencyModelException {
Map<String, String> params = prepareParams();
SvcLogicContext context = prepareContext();
VnfcDependencyModel dependencyModel = readDependencyModel();
- Vnfc xe = new Vnfc("XE","Active-Active",null, false);
+ Vnfc xe = createVnfc("XE","Active-Active",null, false);
Node xeNode = new Node(xe);
dependencyModel.getDependencies().add(xeNode);
@@ -376,8 +377,7 @@ public class TestVnfExecutionFlowImpl {
DependencyManager dependencyManager = PowerMockito.mock(DependencyManager.class);
PowerMockito.when(DependencyModelFactory.createDependencyManager()).thenReturn(dependencyManager);
- PowerMockito.when(dependencyManager.getVnfcDependencyModel((
- DependencyModelIdentifier) Matchers.any(),(DependencyTypes) Matchers.any()))
+ PowerMockito.when(dependencyManager.getVnfcDependencyModel(Matchers.any(), Matchers.any()))
.thenReturn(dependencyModel);
VnfExecutionFlow vnfExecutionFlow = new VnfExecutionFlowImpl();
@@ -385,7 +385,7 @@ public class TestVnfExecutionFlowImpl {
}
@Test
- public void testMissingOptionalVnfcTypeInInventoryModelWithDependentChild() throws DependencyModelNotFound {
+ public void testMissingOptionalVnfcTypeInInventoryModelWithDependentChild() throws DependencyModelNotFound, InvalidDependencyModelException {
Map<String, String> params = prepareParams();
SvcLogicContext context = prepareContext();
context.setAttribute("vnf.vnfc[3].name","YEname");
@@ -397,8 +397,8 @@ public class TestVnfExecutionFlowImpl {
VnfcDependencyModel dependencyModel = readDependencyModel();
- Vnfc xe = new Vnfc("XE","Active-Active",null, false);
- Vnfc ye = new Vnfc("YE","Active-Active",null, true);
+ Vnfc xe = createVnfc("XE","Active-Active",null, false);
+ Vnfc ye = createVnfc("YE","Active-Active",null, true);
Node xeNode = new Node(xe);
Node yeNode = new Node(ye);
yeNode.addParent(xe);
@@ -410,11 +410,12 @@ public class TestVnfExecutionFlowImpl {
DependencyManager dependencyManager = PowerMockito.mock(DependencyManager.class);
PowerMockito.when(DependencyModelFactory.createDependencyManager()).thenReturn(dependencyManager);
- PowerMockito.when(dependencyManager.getVnfcDependencyModel((
- DependencyModelIdentifier) Matchers.any(),(DependencyTypes) Matchers.any()))
+ PowerMockito.when(dependencyManager.getVnfcDependencyModel(Matchers.any(), Matchers.any()))
.thenReturn(dependencyModel);
VnfExecutionFlow vnfExecutionFlow = new VnfExecutionFlowImpl();
vnfExecutionFlow.getVnfExecutionFlowData(params,context);
}
+
+
}