summaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
authorPavel Aharoni <pa0916@att.com>2017-08-21 21:37:17 +0300
committerPavel Aharoni <pa0916@att.com>2017-08-21 21:37:17 +0300
commitc0d03886fbf71cbc843e9a7c7d47221ae4f8d2eb (patch)
treecd42d4b376fd82bee09f07480fb186d259d4e513 /src/test/java/org
parent20e20e9cd5d471d505ffcec2b5498f57a1793bc7 (diff)
[SDC-243] sdc-tosca for port mirroring
Change-Id: I9fc74a79a6fd5c6f4bafc4767b78241c3ebcc021 Signed-off-by: Pavel Aharoni <pa0916@att.com>
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java2
-rw-r--r--src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java35
-rw-r--r--src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java21
-rw-r--r--src/test/java/org/openecomp/sdc/impl/ToscaParserReqAndCapTest.java97
-rw-r--r--src/test/java/org/openecomp/sdc/impl/ToscaParserSubsMappingsTest.java154
5 files changed, 230 insertions, 79 deletions
diff --git a/src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java b/src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java
index d7321d1..8435c12 100644
--- a/src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java
+++ b/src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java
@@ -20,7 +20,7 @@ public class ToscaParserGroupTest extends SdcToscaParserBasicTest{
for (Group group : vfModulesByVf){
assertTrue(group.getName().startsWith("fdnt1"));
assertNotNull(group.getMetadata());
- assertNotNull(group.getMetadata().getValue("vfModuleCustomizationUUID"));
+ assertNotNull(group.getMetadata().getValue("vfModuleModelCustomizationUUID"));
}
}
diff --git a/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java b/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java
index cd80f3a..70bd9c9 100644
--- a/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java
+++ b/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java
@@ -1,8 +1,10 @@
package org.openecomp.sdc.impl;
+import org.openecomp.sdc.toscaparser.api.NodeTemplate;
import org.testng.annotations.Test;
import org.openecomp.sdc.toscaparser.api.elements.Metadata;
+import java.util.List;
import java.util.Map;
import static org.testng.Assert.assertEquals;
@@ -81,4 +83,37 @@ public class ToscaParserMetadataTest extends SdcToscaParserBasicTest {
assertEquals(metadata.get("namingPolicy"),"test");
}
//endregion
+
+ //region getServiceMetadataAllProperties
+ @Test
+ public void testNullServiceMetadataAllPropertiesMap() {
+ Map<String, String> metadata = rainyCsarHelperSingleVf.getServiceMetadataAllProperties();
+ assertNull(metadata);
+ }
+
+ @Test
+ public void testServiceMetadataAllPropertiesMap() {
+ Map<String, String> metadata = fdntCsarHelper.getServiceMetadataAllProperties();
+ assertNotNull(metadata);
+ assertEquals(metadata.size(),9);
+ assertEquals(metadata.get("namingPolicy"),"test");
+ }
+ //endregion
+
+ //region getNodeTemplateMetadata
+ @Test
+ public void testGetNodeTemplateMetadata() {
+ List<NodeTemplate> vfs = fdntCsarHelper.getServiceVfList();
+ Metadata metadata = fdntCsarHelper.getNodeTemplateMetadata(vfs.get(0));
+ assertNotNull(metadata);
+ assertEquals("VF", metadata.getValue("type"));
+ assertEquals("1.0", metadata.getValue("version"));
+ }
+
+ @Test
+ public void testGetNodeTemplateMetadataByNull() {
+ Metadata metadata = fdntCsarHelper.getNodeTemplateMetadata(null);
+ assertNull(metadata);
+ }
+ //endregion
}
diff --git a/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java b/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java
index 80bf1b9..dc0fa70 100644
--- a/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java
+++ b/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java
@@ -729,6 +729,27 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
}
}
+ //region getServiceNodeTemplateByNodeName
+ @Test
+ public void testGetServiceNodeTemplateByRealNodeName() {
+ NodeTemplate nodeTemplate = fdntCsarHelper.getServiceNodeTemplateByNodeName("FDNT 1");
+ assertNotNull(nodeTemplate);
+ assertEquals(nodeTemplate.getName(), "FDNT 1");
+ assertEquals(nodeTemplate.getMetaData().getValue("type"), "VF");
+ }
+
+ @Test
+ public void testGetServiceNodeTemplateByNullNodeName() {
+ NodeTemplate nodeTemplate = fdntCsarHelper.getServiceNodeTemplateByNodeName(null);
+ assertNull(nodeTemplate);
+ }
+
+ @Test
+ public void testGetServiceNodeTemplateByDummyNodeName() {
+ NodeTemplate nodeTemplate = fdntCsarHelper.getServiceNodeTemplateByNodeName("dummy");
+ assertNull(nodeTemplate);
+ }
+ //endregion
//region resolve get_input
@Test
public void testResolveGetInputForComplexTypeAndList() {
diff --git a/src/test/java/org/openecomp/sdc/impl/ToscaParserReqAndCapTest.java b/src/test/java/org/openecomp/sdc/impl/ToscaParserReqAndCapTest.java
new file mode 100644
index 0000000..797aa54
--- /dev/null
+++ b/src/test/java/org/openecomp/sdc/impl/ToscaParserReqAndCapTest.java
@@ -0,0 +1,97 @@
+package org.openecomp.sdc.impl;
+
+import org.openecomp.sdc.tosca.parser.impl.SdcTypes;
+import org.openecomp.sdc.toscaparser.api.CapabilityAssignment;
+import org.openecomp.sdc.toscaparser.api.CapabilityAssignments;
+import org.openecomp.sdc.toscaparser.api.NodeTemplate;
+import org.openecomp.sdc.toscaparser.api.RequirementAssignments;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+
+public class ToscaParserReqAndCapTest extends SdcToscaParserBasicTest {
+
+ //region getCapabilitiesOf
+ @Test
+ public void testGetCapabilitiesOfNodeTemplate() {
+ List<NodeTemplate> vfs = fdntCsarHelper.getServiceVfList();
+ CapabilityAssignments capabilityAssignments = fdntCsarHelper.getCapabilitiesOf(vfs.get(0));
+ assertNotNull(capabilityAssignments);
+ assertEquals(13, capabilityAssignments.getAll().size());
+ assertNotNull(capabilityAssignments.getCapabilityByName("DNT_FW_RHRG.binding_DNT_FW_INT_DNS_TRUSTED_RVMI"));
+ assertEquals(6, capabilityAssignments.getCapabilitiesByType("tosca.capabilities.network.Bindable").getAll().size());
+ }
+
+ @Test
+ public void testGetCapabilitiesOfNull() {
+ CapabilityAssignments capabilityAssignments = fdntCsarHelper.getCapabilitiesOf(null);
+ assertNull(capabilityAssignments);
+ }
+ //endregion
+
+ //region getRequirementsOf
+ @Test
+ public void testGetRequirementsOfNodeTemplate() {
+ List<NodeTemplate> vfs = fdntCsarHelper.getServiceVfList();
+ List<NodeTemplate> cps = fdntCsarHelper.getNodeTemplateBySdcType(vfs.get(0), SdcTypes.CP);
+ RequirementAssignments requirementAssignments = fdntCsarHelper.getRequirementsOf(cps.get(0));
+ assertNotNull(requirementAssignments);
+ assertEquals(1, requirementAssignments.getAll().size());
+ assertEquals("DNT_FW_RHRG", requirementAssignments.getRequirementsByName("binding").getAll().get(0).getNodeTemplateName());
+ }
+
+ @Test
+ public void testGetRequirementsOfNull() {
+ RequirementAssignments requirementAssignments = fdntCsarHelper.getRequirementsOf(null);
+ assertNull(requirementAssignments);
+ }
+ //endregion
+
+ //region getCapabilityPropertyLeafValue
+ @Test
+ public void testGetCapabilityPropertyLeafValue() {
+ NodeTemplate vf = fdntCsarHelper.getServiceNodeTemplateByNodeName("FDNT 1");
+ CapabilityAssignment capabilityAssignment = vf.getCapabilities().getCapabilityByName("DNT_FW_RHRG.scalable_DNT_FW_SERVER");
+ assertNotNull(capabilityAssignment);
+ String propValue = fdntCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, "max_instances#type");
+ assertEquals("integer", propValue);
+ }
+
+ @Test
+ public void testGetCapabilityHierarchyPropertyLeafValue() {
+ NodeTemplate vf = fdntCsarHelper.getServiceNodeTemplateByNodeName("FDNT 1");
+ CapabilityAssignment capabilityAssignment = vf.getCapabilities().getCapabilityByName("DNT_FW_RHRG.endpoint_DNT_FW_SERVER");
+ assertNotNull(capabilityAssignment);
+ String propValue = fdntCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, "ports#entry_schema#type");
+ assertEquals("PortSpec", propValue);
+ }
+
+ @Test
+ public void testGetCapabilityDummyPropertyLeafValue() {
+ NodeTemplate vf = fdntCsarHelper.getServiceNodeTemplateByNodeName("FDNT 1");
+ CapabilityAssignment capabilityAssignment = vf.getCapabilities().getCapabilityByName("DNT_FW_RHRG.scalable_DNT_FW_SERVER");
+ assertNotNull(capabilityAssignment);
+ String propValue = fdntCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, "dummy");
+ assertNull(propValue);
+ }
+
+ @Test
+ public void testGetCapabilityNullPropertyLeafValue() {
+ NodeTemplate vf = fdntCsarHelper.getServiceNodeTemplateByNodeName("FDNT 1");
+ CapabilityAssignment capabilityAssignment = vf.getCapabilities().getCapabilityByName("DNT_FW_RHRG.scalable_DNT_FW_SERVER");
+ assertNotNull(capabilityAssignment);
+ String propValue = fdntCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, null);
+ assertNull(propValue);
+ }
+
+ @Test
+ public void testGetNullCapabilityPropertyLeafValue() {
+ String propValue = fdntCsarHelper.getCapabilityPropertyLeafValue(null, "max_instances#type");
+ assertNull(propValue);
+ }
+ //endregion
+}
diff --git a/src/test/java/org/openecomp/sdc/impl/ToscaParserSubsMappingsTest.java b/src/test/java/org/openecomp/sdc/impl/ToscaParserSubsMappingsTest.java
index 6461a92..7570ced 100644
--- a/src/test/java/org/openecomp/sdc/impl/ToscaParserSubsMappingsTest.java
+++ b/src/test/java/org/openecomp/sdc/impl/ToscaParserSubsMappingsTest.java
@@ -3,15 +3,13 @@ package org.openecomp.sdc.impl;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.LinkedHashMap;
-import java.util.List;
+import java.util.*;
import java.util.stream.Collectors;
import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
-import org.openecomp.sdc.toscaparser.api.Capability;
+import org.openecomp.sdc.toscaparser.api.CapabilityAssignment;
import org.openecomp.sdc.toscaparser.api.NodeTemplate;
+import org.openecomp.sdc.toscaparser.api.RequirementAssignment;
import org.openecomp.sdc.toscaparser.api.elements.CapabilityTypeDef;
//import org.testng.ReporterConfig.Property;
import org.testng.annotations.Test;
@@ -38,81 +36,81 @@ public class ToscaParserSubsMappingsTest extends SdcToscaParserBasicTest {
//Added by QA - Check for Capabilities in VF level (Capabilities QTY and Names).
//@Test // - BUG 283369
- public void testCapabilitiesofVFNames_QTY() throws SdcToscaParserException {
- List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
- String sName = serviceVfList.get(0).getName();
- assertEquals(sName,fdntCsarHelper_Data.get("FDNT").get("VF Name").get(0));
- LinkedHashMap<String, Capability> lCapabilitys = serviceVfList.get(0).getCapabilities();
- List<String> CPkeys = new ArrayList<>(lCapabilitys.keySet());
- List<String> CapabilitiesNames = new ArrayList<String>(CPkeys.size());
-
- for (int i = 0; i < CPkeys.size(); i++) {
-
- Capability cCp = lCapabilitys.get(CPkeys.get(i));
-
- CapabilitiesNames.add(cCp.getName());
-
- assertEquals(CPkeys.get(i).toLowerCase(), CapabilitiesNames.get(i).toLowerCase());// Compare keys to values, Should it be checked as Case sensitive????
-
- //System.out.println(String.format("Value of key: %s , Value of capability: %s", keys.get(i).toLowerCase(), Capabilities.get(i).toLowerCase()));
- //System.out.println(String.format("Value of key: %s , Value of capability: %s", ActualValues.get(i).toLowerCase(), Capabilities.get(i).toLowerCase()));
- //System.out.println(String.format("*******%d*******",i));
- }
-
- for (int i = 0; i < CPkeys.size(); i++) {
- assertEquals(true, CapabilitiesNames.stream().map(String::toLowerCase).collect(Collectors.toList()).contains(fdntCsarHelper_Data.get("FDNT").get("capabilities").get(i).toLowerCase())); // Compare capabilities predefined list to actual one.
- }
-
- assertEquals(fdntCsarHelper_Data.get("FDNT").get("capabilities").size(), CapabilitiesNames.size()); // Compare capabilities qty expected vs actual
- }
+// public void testCapabilitiesofVFNames_QTY() throws SdcToscaParserException {
+// List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
+// String sName = serviceVfList.get(0).getName();
+// assertEquals(sName,fdntCsarHelper_Data.get("FDNT").get("VF Name").get(0));
+// Map<String, CapabilityAssignment> lCapabilitys = serviceVfList.get(0).getCapabilities().getAll();
+// List<String> CPkeys = new ArrayList<>(lCapabilitys.keySet());
+// List<String> CapabilitiesNames = new ArrayList<String>(CPkeys.size());
+//
+// for (int i = 0; i < CPkeys.size(); i++) {
+//
+// CapabilityAssignment cCp = lCapabilitys.get(CPkeys.get(i));
+//
+// CapabilitiesNames.add(cCp.getName());
+//
+// assertEquals(CPkeys.get(i).toLowerCase(), CapabilitiesNames.get(i).toLowerCase());// Compare keys to values, Should it be checked as Case sensitive????
+//
+// //System.out.println(String.format("Value of key: %s , Value of capability: %s", keys.get(i).toLowerCase(), Capabilities.get(i).toLowerCase()));
+// //System.out.println(String.format("Value of key: %s , Value of capability: %s", ActualValues.get(i).toLowerCase(), Capabilities.get(i).toLowerCase()));
+// //System.out.println(String.format("*******%d*******",i));
+// }
+//
+// for (int i = 0; i < CPkeys.size(); i++) {
+// assertEquals(true, CapabilitiesNames.stream().map(String::toLowerCase).collect(Collectors.toList()).contains(fdntCsarHelper_Data.get("FDNT").get("capabilities").get(i).toLowerCase())); // Compare capabilities predefined list to actual one.
+// }
+//
+// assertEquals(fdntCsarHelper_Data.get("FDNT").get("capabilities").size(), CapabilitiesNames.size()); // Compare capabilities qty expected vs actual
+// }
//Added by QA - Check for Capabilities in VF level (Capabilities Types and Properties).
//@Test
- public void testCapabilitiesofVFTypes_Properties() throws SdcToscaParserException {
- List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
- String sName = serviceVfList.get(0).getName();
- assertEquals(sName,fdntCsarHelper_Data.get("FDNT").get("VF Name").get(0));
- LinkedHashMap<String, Capability> lCapabilitys = serviceVfList.get(0).getCapabilities();
-
- List<String> CPkeys = new ArrayList<>(lCapabilitys.keySet());
- List<String> CPPropkeys = new ArrayList<>(lCapabilitys.keySet());
- List<String> CapabilitiesTypes = new ArrayList<String>(CPkeys.size());
-
- //int iKeysSize = keys.size(); //for debug
-
- for (int i = 0; i < CPkeys.size(); i++) {
-
- Capability cCp = lCapabilitys.get(CPkeys.get(i));
- CapabilityTypeDef CpDef = cCp.getDefinition();
- CapabilitiesTypes.add(CpDef.getType());
-
- //LinkedHashMap<String,Object> lProperties = cCp.getDefinition().getProperties();
- LinkedHashMap<String, Property> lPropertiesR = cCp.getProperties();
-
- List<String> CP_Propkeys = new ArrayList<>(lPropertiesR.keySet());
-
- for (int j = 0; j < CP_Propkeys.size(); j++) {
-
- Property p = lPropertiesR.get(CP_Propkeys.get(j));
-
- if(p != null){
- String sPType = p.getType();
- Boolean bPRequired = p.isRequired();
-
- System.out.println(sPType + " " + bPRequired);
-
- }
-
- }
-
- }
-
- for (int i = 0; i < CPkeys.size(); i++) {
-
- }
-
- assertEquals(fdntCsarHelper_Data.get("FDNT").get("capabilitiesTypes").size(), CapabilitiesTypes.size()); // Compare capabilities qty expected vs actual
- }
+// public void testCapabilitiesofVFTypes_Properties() throws SdcToscaParserException {
+// List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
+// String sName = serviceVfList.get(0).getName();
+// assertEquals(sName,fdntCsarHelper_Data.get("FDNT").get("VF Name").get(0));
+// Map<String, CapabilityAssignment> lCapabilitys = serviceVfList.get(0).getCapabilities().getAll();
+//
+// List<String> CPkeys = new ArrayList<>(lCapabilitys.keySet());
+// List<String> CPPropkeys = new ArrayList<>(lCapabilitys.keySet());
+// List<String> CapabilitiesTypes = new ArrayList<String>(CPkeys.size());
+//
+// //int iKeysSize = keys.size(); //for debug
+//
+// for (int i = 0; i < CPkeys.size(); i++) {
+//
+// CapabilityAssignment cCp = lCapabilitys.get(CPkeys.get(i));
+// CapabilityTypeDef CpDef = cCp.getDefinition();
+// CapabilitiesTypes.add(CpDef.getType());
+//
+// //LinkedHashMap<String,Object> lProperties = cCp.getDefinition().getProperties();
+// LinkedHashMap<String, Property> lPropertiesR = cCp.getProperties();
+//
+// List<String> CP_Propkeys = new ArrayList<>(lPropertiesR.keySet());
+//
+// for (int j = 0; j < CP_Propkeys.size(); j++) {
+//
+// Property p = lPropertiesR.get(CP_Propkeys.get(j));
+//
+// if(p != null){
+// String sPType = p.getType();
+// Boolean bPRequired = p.isRequired();
+//
+// System.out.println(sPType + " " + bPRequired);
+//
+// }
+//
+// }
+//
+// }
+//
+// for (int i = 0; i < CPkeys.size(); i++) {
+//
+// }
+//
+// assertEquals(fdntCsarHelper_Data.get("FDNT").get("capabilitiesTypes").size(), CapabilitiesTypes.size()); // Compare capabilities qty expected vs actual
+// }
//@Test // - BUG 283387
public void testRequirmentsofVF() throws SdcToscaParserException {
@@ -122,7 +120,7 @@ public class ToscaParserSubsMappingsTest extends SdcToscaParserBasicTest {
List<String> ActualReqsValues = new ArrayList<>(Arrays.asList( ));
- ArrayList<Object> lRequirements = serviceVfList.get(0).getRequirements();
+ List<RequirementAssignment> lRequirements = serviceVfList.get(0).getRequirements().getAll();
assertEquals(fdntCsarHelper_Data.get("FDNT").get("requirements").size(),lRequirements.size()); //