summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java6
-rw-r--r--src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java72
-rw-r--r--src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java53
-rw-r--r--src/test/java/org/openecomp/sdc/impl/ToscaParserReqAndCapTest.java178
-rw-r--r--src/test/resources/csars/service-ServiceForToscaParserTests-csar.csarbin0 -> 78543 bytes
-rw-r--r--src/test/resources/csars/service-sunny-flow.csarbin45199 -> 45324 bytes
-rw-r--r--src/test/resources/csars/service-sunny-flow2.csarbin0 -> 45259 bytes
7 files changed, 303 insertions, 6 deletions
diff --git a/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java b/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java
index 4c1f84e..a73f121 100644
--- a/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java
+++ b/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java
@@ -28,9 +28,11 @@ public abstract class SdcToscaParserBasicTest {
static ISdcCsarHelper ipAssignCsarHelper;
static ISdcCsarHelper nestedVfcCsarHlper;
static ISdcCsarHelper nfodNEWCsarHlper;
+ static ISdcCsarHelper QAServiceForToscaParserTests;
static ISdcCsarHelper resolveGetInputCsar;
static ISdcCsarHelper resolveGetInputCsarFalse;
static ISdcCsarHelper resolveGetInputCsarQA;
+ static ISdcCsarHelper resolveReqsCapsCsarQA;
static Map<String, HashMap<String, List<String>>> fdntCsarHelper_Data;
@@ -49,7 +51,9 @@ public abstract class SdcToscaParserBasicTest {
resolveGetInputCsar = getCsarHelper("csars/service-resolve-get-input-csar.csar");
resolveGetInputCsarFalse = getCsarHelper("csars/service-resolve-get-input-csar.csar",false);
resolveGetInputCsarQA = getCsarHelper("csars/service-resolve-get-input-csar_QA.csar");
-
+ QAServiceForToscaParserTests = getCsarHelper("csars/service-ServiceForToscaParserTests-csar.csar");
+ resolveReqsCapsCsarQA = getCsarHelper("csars/service-sunny-flow2.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/ToscaParserMetadataTest.java b/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java
index 70bd9c9..4e5c9bc 100644
--- a/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java
+++ b/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java
@@ -116,4 +116,76 @@ public class ToscaParserMetadataTest extends SdcToscaParserBasicTest {
assertNull(metadata);
}
//endregion
+
+ //QA tests region for US 319197 -port mirroring
+
+ //getNodeTemplateMetadata (All Types)
+ @Test
+ public void GetServiceNodeTemplateMetadataTypeVF() {
+ NodeTemplate nodeTemplate = QAServiceForToscaParserTests.getServiceNodeTemplateByNodeName("VF_1_V_port_1 0");
+ Metadata nodeTemplateMetadata = QAServiceForToscaParserTests.getNodeTemplateMetadata(nodeTemplate);
+ assertNotNull(nodeTemplateMetadata);
+ assertEquals(nodeTemplateMetadata.getValue("resourceVendorRelease"), "12-12-12");
+ assertEquals(nodeTemplateMetadata.getValue("type"), "VF");
+ }
+
+ @Test
+ public void GetServiceNodeTemplateMetadataTypeVL() {
+ NodeTemplate nodeTemplate = QAServiceForToscaParserTests.getServiceNodeTemplateByNodeName("ExtVL 0");
+ Metadata nodeTemplateMetadata = QAServiceForToscaParserTests.getNodeTemplateMetadata(nodeTemplate);
+ assertNotNull(nodeTemplateMetadata);
+ assertEquals(nodeTemplateMetadata.getValue("resourceVendorRelease"), "1.0.0.wd03");
+ assertEquals(nodeTemplateMetadata.getValue("type"), "VL");
+ }
+
+ @Test
+ public void GetServiceNodeTemplateMetadataTypeCP() {
+ NodeTemplate nodeTemplate = QAServiceForToscaParserTests.getServiceNodeTemplateByNodeName("ExtCP 0");
+ Metadata nodeTemplateMetadata = QAServiceForToscaParserTests.getNodeTemplateMetadata(nodeTemplate);
+ assertNotNull(nodeTemplateMetadata);
+ assertEquals(nodeTemplateMetadata.getValue("UUID"), "7a883088-5cab-4bfb-8d55-307d3ffd0758");
+ assertEquals(nodeTemplateMetadata.getValue("type"), "CP");
+ }
+
+ @Test
+ public void GetServiceNodeTemplateMetadataTypePNF() {
+ NodeTemplate nodeTemplate = QAServiceForToscaParserTests.getServiceNodeTemplateByNodeName("PNF TEST 0");
+ Metadata nodeTemplateMetadata = QAServiceForToscaParserTests.getNodeTemplateMetadata(nodeTemplate);
+ assertNotNull(nodeTemplateMetadata);
+ assertEquals(nodeTemplateMetadata.getValue("resourceVendorModelNumber"), "");
+ assertEquals(nodeTemplateMetadata.getValue("type"), "PNF");
+ }
+
+ //QA end region for US 319197 -port mirroring
+
+ // Added by QA //region getServiceMetadataAllProperties
+
+ @Test
+ public void testGetAllMetadataProperties() {
+ Metadata serviceMetadata = fdntCsarHelper.getServiceMetadata();
+ assertNotNull(serviceMetadata);
+ Map<String, String> allProperties = serviceMetadata.getAllProperties();
+ assertNotNull(allProperties);
+ String invariantUUID = allProperties.get("invariantUUID");
+ String UUID = allProperties.get("UUID");
+ String name = allProperties.get("name");
+ String description = allProperties.get("description");
+ String type = allProperties.get("type");
+ String category = allProperties.get("category");
+ String ecompGeneratedNaming = allProperties.get("ecompGeneratedNaming");
+ String namingPolicy = allProperties.get("namingPolicy");
+ String serviceEcompNaming = allProperties.get("serviceEcompNaming");
+
+ assertEquals(invariantUUID, "78c72999-1003-4a35-8534-bbd7d96fcae3");
+ assertEquals(UUID, "edd0a9f7-d084-4423-8461-a2eff4cb3eb6");
+ assertEquals(name, "Service FDNT");
+ assertEquals(description, "Service FDNT");
+ assertEquals(type, "Service");
+ assertEquals(category, "Network L1-3");
+ assertEquals(ecompGeneratedNaming, "true");
+ assertEquals(namingPolicy, "test");
+ assertEquals(serviceEcompNaming, "true");
+ }
+ //endregion
+
}
diff --git a/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java b/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java
index dc0fa70..2c62ca2 100644
--- a/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java
+++ b/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java
@@ -4,10 +4,8 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
-
-
import java.util.*;
-
+import static org.hamcrest.CoreMatchers.is;
import org.apache.commons.lang3.tuple.Pair;
import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
import org.openecomp.sdc.tosca.parser.impl.FilterType;
@@ -748,7 +746,10 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
public void testGetServiceNodeTemplateByDummyNodeName() {
NodeTemplate nodeTemplate = fdntCsarHelper.getServiceNodeTemplateByNodeName("dummy");
assertNull(nodeTemplate);
- }
+ }
+
+
+
//endregion
//region resolve get_input
@Test
@@ -873,6 +874,50 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
assertEquals("107.239.36.5", propertyAsObject.toString());
}
+ //QA region getServiceNodeTemplateByNodeName tests
+
+ @Test
+ public void getServiceNodeTemplateByNodeNameTypeVF() {
+ NodeTemplate nodeTemplate = QAServiceForToscaParserTests.getServiceNodeTemplateByNodeName("VF_1_V_port_1 0");
+ assertNotNull(nodeTemplate);
+ assertEquals(nodeTemplate.getName(), "VF_1_V_port_1 0");
+ assertEquals(nodeTemplate.getMetaData().getValue("type"), "VF");
+ }
+
+ @Test
+ public void getServiceNodeTemplateByNodeNameTypeVL() {
+ NodeTemplate nodeTemplate = QAServiceForToscaParserTests.getServiceNodeTemplateByNodeName("ExtVL 0");
+ assertNotNull(nodeTemplate);
+ assertEquals(nodeTemplate.getName(), "ExtVL 0");
+ assertEquals(nodeTemplate.getMetaData().getValue("type"), "VL");
+ }
+
+ @Test
+ public void getServiceNodeTemplateByNodeNameTypeCP() {
+ NodeTemplate nodeTemplate = QAServiceForToscaParserTests.getServiceNodeTemplateByNodeName("ExtCP 0");
+ assertNotNull(nodeTemplate);
+ assertEquals(nodeTemplate.getName(), "ExtCP 0");
+ assertEquals(nodeTemplate.getMetaData().getValue("type"), "CP");
+ }
+
+ @Test
+ public void getServiceNodeTemplateByNodeNameTypePNF() {
+ NodeTemplate nodeTemplate = QAServiceForToscaParserTests.getServiceNodeTemplateByNodeName("PNF TEST 0");
+ assertNotNull(nodeTemplate);
+ assertEquals(nodeTemplate.getName(), "PNF TEST 0");
+ assertEquals(nodeTemplate.getMetaData().getValue("type"), "PNF");
+ }
+
+ //QA region getServiceNodeTemplateBySdcType tests
+
+ @Test
+ public void getServiceNodeTemplateBySdcType_VF() {
+ List<NodeTemplate> vfList = QAServiceForToscaParserTests.getServiceNodeTemplatesByType("org.openecomp.resource.vf.Vf1VPort1");
+ assertEquals(2, vfList.size());
+ assertEquals("VF_1_V_port_1", vfList.get(0).getMetaData().getValue("name"));
+ }
// endregion Added by QA - Continue with testings of resolve get_input
}
+
+
diff --git a/src/test/java/org/openecomp/sdc/impl/ToscaParserReqAndCapTest.java b/src/test/java/org/openecomp/sdc/impl/ToscaParserReqAndCapTest.java
index 797aa54..8d800e1 100644
--- a/src/test/java/org/openecomp/sdc/impl/ToscaParserReqAndCapTest.java
+++ b/src/test/java/org/openecomp/sdc/impl/ToscaParserReqAndCapTest.java
@@ -1,10 +1,11 @@
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.CapabilityAssignment;
import org.openecomp.sdc.toscaparser.api.NodeTemplate;
import org.openecomp.sdc.toscaparser.api.RequirementAssignments;
+import org.openecomp.sdc.toscaparser.api.elements.Metadata;
import org.testng.annotations.Test;
import java.util.List;
@@ -94,4 +95,179 @@ public class ToscaParserReqAndCapTest extends SdcToscaParserBasicTest {
assertNull(propValue);
}
//endregion
+
+ //QA tests region for US 319197 -port mirroring-
+
+ //get-CapabilitiesOf (All Types)
+ @Test
+ public void getServiceNodeTemplateCapabilitiesOfTypeVF() {
+ List<NodeTemplate> serviceVfList = QAServiceForToscaParserTests.getServiceNodeTemplateBySdcType(SdcTypes.VF);
+ CapabilityAssignments capabilitiesOfVF = QAServiceForToscaParserTests.getCapabilitiesOf(serviceVfList.get(0));
+ assertEquals(capabilitiesOfVF.getAll().size(),12);
+ assertNotNull(capabilitiesOfVF.getCapabilityByName("neutronport0.network.incoming.packets.rate"));
+ }
+
+ @Test
+ public void getServiceNodeTemplateCapabilitiesOfTypeExVL() {
+ List<NodeTemplate> serviceExtVlList = QAServiceForToscaParserTests.getServiceNodeTemplatesByType("org.openecomp.resource.vl.extVL");
+ CapabilityAssignments capabilitiesOfExtVL = QAServiceForToscaParserTests.getCapabilitiesOf(serviceExtVlList.get(0));
+ assertEquals(capabilitiesOfExtVL.getAll().size(),2);
+ assertNotNull(capabilitiesOfExtVL.getCapabilityByName("virtual_linkable").getProperties());
+ }
+
+ @Test
+ public void getServiceNodeTemplateCapabilitiesOfTypeVL() {
+ List<NodeTemplate> serviceVlList = QAServiceForToscaParserTests.getServiceNodeTemplatesByType("tosca.nodes.network.Network");
+ CapabilityAssignments capabilitiesOfVL = QAServiceForToscaParserTests.getCapabilitiesOf(serviceVlList.get(0));
+ assertEquals(capabilitiesOfVL.getAll().size(),2);
+ assertNotNull(capabilitiesOfVL.getCapabilityByName("link").getProperties());
+ }
+
+ @Test
+ public void getServiceNodeTemplateCapabilitiesOfTypeCP() {
+ List<NodeTemplate> serviceCpList = QAServiceForToscaParserTests.getServiceNodeTemplateBySdcType(SdcTypes.CP);
+ CapabilityAssignments capabilitiesOfCP = QAServiceForToscaParserTests.getCapabilitiesOf(serviceCpList.get(0));
+ assertEquals(capabilitiesOfCP.getAll().size(),2);
+ assertNotNull(capabilitiesOfCP.getCapabilityByName("internal_connectionPoint"));
+ }
+
+ @Test
+ public void getServiceNodeTemplateCapabilitiesOfTypePNF() {
+ List<NodeTemplate> servicePnfs = QAServiceForToscaParserTests.getServiceNodeTemplateBySdcType(SdcTypes.PNF);
+ CapabilityAssignments capabilitiesOfPnf = QAServiceForToscaParserTests.getCapabilitiesOf(servicePnfs.get(0));
+ assertEquals(capabilitiesOfPnf.getAll().size(),1);
+ assertNotNull(capabilitiesOfPnf.getCapabilityByName("feature"));
+ }
+
+ //get-RequirementsOf (All Types)-----------------------------
+
+ @Test
+ public void getServiceNodeTemplateRequirementsOfTypeVF() {
+ List<NodeTemplate> serviceVfList = QAServiceForToscaParserTests.getServiceNodeTemplateBySdcType(SdcTypes.VF);
+ RequirementAssignments requirementsOfVF = QAServiceForToscaParserTests.getRequirementsOf(serviceVfList.get(6));
+ assertEquals(requirementsOfVF.getAll().size(),3);
+// RequirementAssignments requirementsByName =
+ assertEquals(requirementsOfVF.getRequirementsByName("dependency").getAll().size(),2 );
+ //check that API return empty list if requirement property not exist.
+ assertEquals(requirementsOfVF.getRequirementsByName("blabla").getAll().size(),0);
+ }
+
+ @Test
+ public void getServiceNodeTemplateRequirementsOfTypeExVL() {
+ List<NodeTemplate> serviceExtVlList = QAServiceForToscaParserTests.getServiceNodeTemplatesByType("org.openecomp.resource.vl.extVL");
+ RequirementAssignments requirementsOfExtVL = QAServiceForToscaParserTests.getRequirementsOf(serviceExtVlList.get(0));
+ assertEquals(requirementsOfExtVL.getAll().size(),1);
+ }
+
+ @Test
+ public void getServiceNodeTemplateRequirementsOfTypeVL() {
+ List<NodeTemplate> serviceVlList = QAServiceForToscaParserTests.getServiceNodeTemplatesByType("tosca.nodes.network.Network");
+ RequirementAssignments requirementsOfVL = QAServiceForToscaParserTests.getRequirementsOf(serviceVlList.get(1));
+ assertEquals(requirementsOfVL.getAll().size(),2);
+ assertNotNull(requirementsOfVL.getRequirementsByName("dependency"));
+ }
+
+ @Test
+ public void getServiceNodeTemplateRequirementsOfTypeCP() {
+ List<NodeTemplate> serviceCpList = QAServiceForToscaParserTests.getServiceNodeTemplateBySdcType(SdcTypes.CP);
+ RequirementAssignments requirementsOfCP = QAServiceForToscaParserTests.getRequirementsOf(serviceCpList.get(0));
+ assertEquals(requirementsOfCP.getAll().size(),2);
+ assertEquals(requirementsOfCP.getRequirementsByName("virtualBinding").getAll().size(),1);
+ }
+
+ @Test
+ public void getServiceNodeTemplateRequirementsOfTypePNF() {
+ List<NodeTemplate> servicePnfs = QAServiceForToscaParserTests.getServiceNodeTemplateBySdcType(SdcTypes.PNF);
+ RequirementAssignments requirementsOfPnf = QAServiceForToscaParserTests.getRequirementsOf(servicePnfs.get(0));
+ assertEquals(requirementsOfPnf.getAll().size(),2);
+ assertNotNull(requirementsOfPnf.getRequirementsByName("feature"));
+ }
+
+ //QA end region for US 319197 -port mirroring
+
+ // Added by QA CapabilityAssignments
+ @Test
+ public void testGetCapabilitiesByType() {
+ List<NodeTemplate> vfs = resolveGetInputCsarQA.getServiceVfList();
+ CapabilityAssignments capabilityAssignments = resolveGetInputCsarQA.getCapabilitiesOf(vfs.get(0));
+ assertNotNull(capabilityAssignments);
+ CapabilityAssignments capabilitiesByType = capabilityAssignments.getCapabilitiesByType("tosca.capabilities.Scalable");
+ int capsQty = capabilitiesByType.getAll().size();
+ assertEquals(1, capsQty);
+ CapabilityAssignment capabilityByName = capabilitiesByType.getCapabilityByName("abstract_pd_server.scalable_pd_server");
+ assertNotNull(capabilityByName);
+ }
+
+ @Test
+ public void testGetCapabilityByName() {
+ List<NodeTemplate> vfs = resolveGetInputCsarQA.getServiceVfList();
+ CapabilityAssignments capabilityAssignments = resolveGetInputCsarQA.getCapabilitiesOf(vfs.get(0));
+ assertNotNull(capabilityAssignments);
+ CapabilityAssignment capabilityByName = capabilityAssignments.getCapabilityByName("abstract_pd_server.disk.iops_pd_server");
+ assertNotNull(capabilityByName);
+ String capName = capabilityByName.getName();
+ assertEquals(capName, "abstract_pd_server.disk.iops_pd_server");
+ }
+
+ @Test
+ public void testGetCapabilitiesGetAll() {
+ List<NodeTemplate> vfs = resolveGetInputCsarQA.getServiceVfList();
+ CapabilityAssignments capabilityAssignments = resolveGetInputCsarQA.getCapabilitiesOf(vfs.get(0));
+ assertNotNull(capabilityAssignments);
+ int capsAssignmentSize = capabilityAssignments.getAll().size();
+ assertEquals(65, capsAssignmentSize);
+ }
+
+ // Added by QA RequirementsAssignments
+ @Test
+ public void testGetRequirementsByName() {
+ List<NodeTemplate> vfs = resolveReqsCapsCsarQA.getServiceVfList();
+ List<NodeTemplate> cps = resolveReqsCapsCsarQA.getNodeTemplateBySdcType(vfs.get(0), SdcTypes.CP);
+ RequirementAssignments requirementAssignments = resolveReqsCapsCsarQA.getRequirementsOf(cps.get(0));
+ assertNotNull(requirementAssignments);
+ assertEquals(2, requirementAssignments.getAll().size());
+ assertEquals("DNT_FW_RHRG2", requirementAssignments.getRequirementsByName("binding").getAll().get(1).getNodeTemplateName());
+
+ }
+
+ @Test
+ public void testRequirementAssignmentGetNodeGetCapability() {
+ List<NodeTemplate> vfs = resolveReqsCapsCsarQA.getServiceVfList();
+ List<NodeTemplate> cps = resolveReqsCapsCsarQA.getNodeTemplateBySdcType(vfs.get(0), SdcTypes.CP);
+ RequirementAssignments requirementAssignments = resolveReqsCapsCsarQA.getRequirementsOf(cps.get(0));
+ assertNotNull(requirementAssignments);
+ String nodeTemplateName = requirementAssignments.getAll().get(0).getNodeTemplateName();
+ String capabilityName = requirementAssignments.getAll().get(0).getCapabilityName();
+ assertEquals(nodeTemplateName, "DNT_FW_RHRG");
+ assertNull(capabilityName);
+ }
+
+
+ @Test
+ public void testRequirementAssignmentGetCapability() {
+ List<NodeTemplate> cps = QAServiceForToscaParserTests.getServiceNodeTemplateBySdcType(SdcTypes.CP);
+ RequirementAssignments requirementAssignments = QAServiceForToscaParserTests.getRequirementsOf(cps.get(0));
+ assertNotNull(requirementAssignments);
+ String nodeTemplateName = requirementAssignments.getAll().get(0).getNodeTemplateName();
+ String capabilityName = requirementAssignments.getAll().get(0).getCapabilityName();
+ assertEquals(nodeTemplateName, "ExtVL 0");
+ assertEquals(capabilityName,"tosca.capabilities.network.Linkable");
+ }
+
+ @Test
+ public void testGetCapabilityProperties() {
+ List<NodeTemplate> vfs = fdntCsarHelper.getServiceVfList();
+ List<NodeTemplate> cps = fdntCsarHelper.getNodeTemplateBySdcType(vfs.get(0), SdcTypes.CP);
+ CapabilityAssignments capabilityAssignments = cps.get(0).getCapabilities();
+ assertNotNull(capabilityAssignments);
+ assertEquals(12, capabilityAssignments.getAll().size());
+ CapabilityAssignment xxxCapability = capabilityAssignments.getCapabilityByName("xxx");
+ //GetInput property - resolved in any case
+ String getInputProp = fdntCsarHelper.getCapabilityPropertyLeafValue(xxxCapability, "DeploymentFlavor");
+ assertEquals("{aaa=bbb}", getInputProp);
+ //Simple property
+ String simpleProp = fdntCsarHelper.getCapabilityPropertyLeafValue(xxxCapability, "distribution");
+ assertEquals("rhel", simpleProp);
+ }
+
}
diff --git a/src/test/resources/csars/service-ServiceForToscaParserTests-csar.csar b/src/test/resources/csars/service-ServiceForToscaParserTests-csar.csar
new file mode 100644
index 0000000..f6c7769
--- /dev/null
+++ b/src/test/resources/csars/service-ServiceForToscaParserTests-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/service-sunny-flow.csar b/src/test/resources/csars/service-sunny-flow.csar
index 48eb59b..92ae19d 100644
--- a/src/test/resources/csars/service-sunny-flow.csar
+++ b/src/test/resources/csars/service-sunny-flow.csar
Binary files differ
diff --git a/src/test/resources/csars/service-sunny-flow2.csar b/src/test/resources/csars/service-sunny-flow2.csar
new file mode 100644
index 0000000..0a8af02
--- /dev/null
+++ b/src/test/resources/csars/service-sunny-flow2.csar
Binary files differ