aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java9
-rw-r--r--src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java21
-rw-r--r--src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcTypes.java10
-rw-r--r--src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java2
-rw-r--r--src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java60
-rw-r--r--src/test/resources/csars/service-nested-vfc-csar.csarbin0 -> 47592 bytes
6 files changed, 94 insertions, 8 deletions
diff --git a/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java b/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java
index 45d8392..6c8f5df 100644
--- a/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java
+++ b/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java
@@ -368,6 +368,11 @@ public interface ISdcCsarHelper {
* @return VNF Configuration Node Template.
*/
public NodeTemplate getVnfConfig(String vfCustomizationUuid);
-
-
+
+ /**
+ * Check if Node Template has Topology Template
+ * @param nodeTemplate - Node Template to check
+ * @return true if node template has topology template, false if not.
+ */
+ public boolean hasTopology(NodeTemplate nodeTemplate);
}
diff --git a/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java b/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
index 0ed4c97..7b901ec 100644
--- a/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
+++ b/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
@@ -215,7 +215,10 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
List<NodeTemplate> serviceVfList = getServiceVfList();
NodeTemplate vfInstance = getNodeTemplateByCustomizationUuid(serviceVfList, vfCustomizationId);
- return getNodeTemplateBySdcType(vfInstance, SdcTypes.VFC);
+ List<NodeTemplate> vfcs = getNodeTemplateBySdcType(vfInstance, SdcTypes.VFC);
+ vfcs.addAll(getNodeTemplateBySdcType(vfInstance, SdcTypes.CVFC));
+
+ return vfcs;
}
@Override
@@ -649,6 +652,22 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
return vnfConfig;
}
+ @Override
+ public boolean hasTopology(NodeTemplate nodeTemplate) {
+ if (nodeTemplate == null) {
+ log.error("hasTopology - nodeTemplate - is null");
+ return false;
+ }
+
+ if (nodeTemplate.getMetaData() != null) {
+ String type = nodeTemplate.getMetaData().getValue("type");
+ log.debug("hasTopology - node template {} is a {} type", nodeTemplate.getName(), type);
+ return SdcTypes.isComplex(SdcTypes.valueOf(type));
+ }
+
+ return false;
+ }
+
/************************************* helper functions ***********************************/
private Map<String, String> filterProperties(Object property, String path, FilterType filterType, String pattern, Map<String, String> filterMap) {
diff --git a/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcTypes.java b/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcTypes.java
index 5b68aea..9f885f4 100644
--- a/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcTypes.java
+++ b/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcTypes.java
@@ -20,8 +20,16 @@
package org.openecomp.sdc.tosca.parser.impl;
+import java.util.Arrays;
+import java.util.List;
+
public enum SdcTypes {
- CP, VL, VF, VFC, PNF, SERVICE
+ CP, VL, VF, VFC, PNF, SERVICE, CVFC;
+
+ public static List<SdcTypes> complexTypes = Arrays.asList(VF, PNF, SERVICE, CVFC);
+ public static boolean isComplex(SdcTypes sdcType) {
+ return complexTypes.contains(sdcType);
+ }
}
diff --git a/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java b/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java
index 3af654e..471fbc0 100644
--- a/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java
+++ b/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java
@@ -27,6 +27,7 @@ public abstract class SdcToscaParserBasicTest {
static ISdcCsarHelper complexCps;
static ISdcCsarHelper fdntCsarHelperWithInputs;
static ISdcCsarHelper nfodCsarHlper;
+ static ISdcCsarHelper nestedVfcCsarHlper;
static Map<String, HashMap<String, List<String>>> fdntCsarHelper_Data;
@BeforeClass
@@ -39,6 +40,7 @@ public abstract class SdcToscaParserBasicTest {
complexCps = getCsarHelper("csars/service-consolidated-props-csar.csar");
fdntCsarHelperWithInputs = getCsarHelper("csars/service-ServiceFdnt-with-get-input.csar");
nfodCsarHlper = getCsarHelper("csars/service-NfodService-csar.csar");
+ nestedVfcCsarHlper = getCsarHelper("csars/service-nested-vfc-csar.csar");
fdntCsarHelper_Data = new HashMap<String, HashMap<String, List<String>>>(){
{
HashMap<String, List<String>> FDNT ;
diff --git a/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java b/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java
index 8470cbd..d8e065b 100644
--- a/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java
+++ b/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java
@@ -520,9 +520,7 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
}
//endregion
-
-
-
+ //region getVnfConfig
@Test
public void testGetVnfConfig() {
NodeTemplate vnfConfig = nfodCsarHlper.getVnfConfig("9bb2ef82-f8f6-4391-bc71-db063f15bf57");
@@ -554,5 +552,59 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
assertNotNull(vfcList);
assertEquals(2, vfcList.size());
}
-
+ //endregion
+
+ //region nested vfc
+ @Test
+ public void testNestedVfcByExistCvfc() {
+ List<NodeTemplate> vfcList = nestedVfcCsarHlper.getVfcListByVf("71389f8b-8671-4a43-a991-59fb621d3615");
+ assertNotNull(vfcList);
+ assertEquals(1, vfcList.size());
+ assertEquals("VF_VNF", vfcList.get(0).getName());
+ }
+
+ @Test
+ public void testNestedVfcByNullVf() {
+ List<NodeTemplate> vfcList = nestedVfcCsarHlper.getVfcListByVf(null);
+ assertNotNull(vfcList);
+ assertEquals(0, vfcList.size());
+ }
+
+ @Test
+ public void testNestedVfcByDummyVf() {
+ List<NodeTemplate> vfcList = nestedVfcCsarHlper.getVfcListByVf("dummy");
+ assertNotNull(vfcList);
+ assertEquals(0, vfcList.size());
+ }
+ //endregion
+
+ //region hasTopology
+ @Test
+ public void testHasTopologyByVF() {
+ List<NodeTemplate> vfList = nestedVfcCsarHlper.getServiceVfList();
+ boolean hasTopology = nestedVfcCsarHlper.hasTopology(vfList.get(0));
+ assertEquals(true, hasTopology);
+ }
+
+ @Test
+ public void testHasTopologyByCVFC() {
+ List<NodeTemplate> vfcList = nestedVfcCsarHlper.getVfcListByVf("71389f8b-8671-4a43-a991-59fb621d3615");
+ boolean hasTopology = nestedVfcCsarHlper.hasTopology(vfcList.get(0));
+ assertEquals(true, hasTopology);
+ }
+
+ @Test
+ public void testHasTopologyByVL() {
+ List<NodeTemplate> serviceVlList = fdntCsarHelper.getServiceVlList();
+ boolean hasTopology = fdntCsarHelper.hasTopology(serviceVlList.get(0));
+ assertEquals(false, hasTopology);
+ }
+
+ @Test
+ public void testHasTopologyByNull() {
+ boolean hasTopology = fdntCsarHelper.hasTopology(null);
+ assertEquals(false, hasTopology);
+ }
+ //endregion
+
}
diff --git a/src/test/resources/csars/service-nested-vfc-csar.csar b/src/test/resources/csars/service-nested-vfc-csar.csar
new file mode 100644
index 0000000..b141fe2
--- /dev/null
+++ b/src/test/resources/csars/service-nested-vfc-csar.csar
Binary files differ