summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/sdc/impl/GetEntityPortMirroringTest.java115
-rw-r--r--src/test/java/org/onap/sdc/impl/GetEntityTest.java30
-rw-r--r--src/test/java/org/onap/sdc/impl/ToscaParserPolicyTest.java55
-rw-r--r--src/test/java/org/onap/sdc/impl/ToscaParserSubsMappingsTest.java4
-rw-r--r--src/test/resources/csars/service-CgnatFwVnfNc-csar.csarbin0 -> 78522 bytes
-rw-r--r--src/test/resources/csars/service-JennnyVepdgPortMirroringTest-csar.csarbin0 -> 144308 bytes
6 files changed, 197 insertions, 7 deletions
diff --git a/src/test/java/org/onap/sdc/impl/GetEntityPortMirroringTest.java b/src/test/java/org/onap/sdc/impl/GetEntityPortMirroringTest.java
new file mode 100644
index 0000000..aa33910
--- /dev/null
+++ b/src/test/java/org/onap/sdc/impl/GetEntityPortMirroringTest.java
@@ -0,0 +1,115 @@
+package org.onap.sdc.impl;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
+import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
+import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
+import org.onap.sdc.tosca.parser.enums.SdcTypes;
+import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
+import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
+import org.onap.sdc.toscaparser.api.CapabilityAssignment;
+import org.onap.sdc.toscaparser.api.RequirementAssignment;
+
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class GetEntityPortMirroringTest {
+
+ private final static String cap0 = "vepdg5afn0.vlb_1.port_mirroring_vlb_gn_vepdg_fn_5_RVMI";
+ private final static String cap1 = "radcomfnvlbavf11_3_3vepdg0.abstract_vlbagentbase_eph_aff.port_mirroring_vlbagentbase_eph_aff_vlbagentbase_eph_aff_int_pktmirror_1_port";
+ private static ISdcCsarHelper helper = null;
+
+ @BeforeClass
+ public static void setUpClass() {
+ try {
+ URL resource = GetEntityPortMirroringTest.class.getClassLoader()
+ .getResource("csars/service-JennnyVepdgPortMirroringTest-csar.csar");
+ if (resource != null) {
+ helper = SdcToscaParserFactory.getInstance().getSdcCsarHelper(resource.getFile());
+ }
+
+ } catch (SdcToscaParserException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void getServiceConfigurations() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.CONFIGURATION)
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE)
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false);
+
+ assertEquals(1, entities.size());
+ assertEquals("54308d8b-21ca-40a1-bd3e-efde64791605", entities.get(0).getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ assertEquals("Port Mirroring Configuration", entities.get(0).getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ assertEquals(2, entities.get(0).getRequirements().size());
+ assertTrue(entities.get(0).getProperties().isEmpty());
+ assertEquals(1, entities.get(0).getCapabilities().size());
+ }
+
+ @Test
+ public void getServiceProxyOnService() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.SERVICE_PROXY)
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE)
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false);
+
+ assertEquals(2, entities.size());
+ assertTrue("vEPDG-5A-FN SVC Service Proxy".equals(entities.get(0).getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)) ||
+ "vEPDG-5A-FN SVC Service Proxy".equals(entities.get(1).getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ assertTrue("Radcom FN vLBA SVC 11_3_3 vEPDG Service Proxy".equals(entities.get(0).getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)) ||
+ "Radcom FN vLBA SVC 11_3_3 vEPDG Service Proxy".equals(entities.get(1).getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+
+ assertTrue(entities.get(0).getRequirements().isEmpty());
+ assertTrue(entities.get(0).getProperties().isEmpty());
+ assertEquals(940, entities.get(0).getCapabilities().size());
+ assertEquals(197, entities.get(1).getCapabilities().size());
+ }
+
+ @Test
+ public void getCapabilityForCOnfigurationRequirementOnService() {
+ EntityQuery entityQueryC = EntityQuery.newBuilder(SdcTypes.CONFIGURATION)
+ .build();
+
+ EntityQuery entityQueryS = EntityQuery.newBuilder(SdcTypes.SERVICE_PROXY)
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE)
+ .build();
+
+ List<IEntityDetails> configurationNodes = helper.getEntity(entityQueryC, topologyTemplateQuery, false);
+ List<IEntityDetails> proxyNodes = helper.getEntity(entityQueryS, topologyTemplateQuery, false);
+
+ assertEquals(2, proxyNodes.size());
+ assertEquals(1, configurationNodes.size());
+
+ Map<String, RequirementAssignment> reqMap = configurationNodes.get(0).getRequirements();
+ assertEquals(cap0, reqMap.get("source").getCapabilityName());
+ assertEquals(cap1, reqMap.get("collector").getCapabilityName());
+
+ assertTrue(isCapabilityFound(proxyNodes.get(0), cap0));
+ assertTrue(isCapabilityFound(proxyNodes.get(1), cap1));
+ }
+
+ private boolean isCapabilityFound(IEntityDetails nodeDetails, String capName) {
+ List<CapabilityAssignment> assignments = nodeDetails.getCapabilities()
+ .values()
+ .stream()
+ .filter(ca->capName.equals(ca.getDefinition()
+ .getName()))
+ .collect(Collectors.toList());
+ return assignments.size() == 1;
+ }
+}
diff --git a/src/test/java/org/onap/sdc/impl/GetEntityTest.java b/src/test/java/org/onap/sdc/impl/GetEntityTest.java
index 5c19072..cd332e4 100644
--- a/src/test/java/org/onap/sdc/impl/GetEntityTest.java
+++ b/src/test/java/org/onap/sdc/impl/GetEntityTest.java
@@ -39,7 +39,7 @@ public class GetEntityTest {
}
}
- @Test
+ @Test
public void getCpEntitiesFromCVFC() {
EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.CP)
.build();
@@ -183,6 +183,7 @@ public class GetEntityTest {
assertTrue(entities.get(0).getMemberNodes().get(0).getName().equals("abstract_rtp_msc") ||
entities.get(0).getMemberNodes().get(1).getName().equals("abstract_rtp_msc"));
assertEquals(4, entities.get(0).getProperties().size());
+ assertEquals(2, entities.get(0).getMembers().size());
assertTrue(entities.get(0).getRequirements().isEmpty());
}
@@ -198,7 +199,11 @@ public class GetEntityTest {
List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false);
assertEquals(1, entities.size());
+ assertEquals("org.openecomp.groups.VfModule", entities.get(0).getToscaType());
+ assertTrue(entities.get(0).getPath().isEmpty());
+ assertTrue(entities.get(0).getMembers().isEmpty());
assertNull(entities.get(0).getParent());
+ assertTrue(entities.get(0).getTargets().isEmpty());
}
@Test
@@ -211,7 +216,9 @@ public class GetEntityTest {
List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, true);
assertEquals(19, entities.size());
- assertTrue(entities.get(9).getTargetNodes().isEmpty());
+ assertTrue(entities.get(9).getTargetEntities().isEmpty());
+ assertEquals(1, entities.get(7).getMembers().size());
+ assertEquals("org.openecomp.groups.VfModule", entities.get(7).getToscaType());
assertEquals("rtp_msc_subint_avpn_vmi_0", entities.get(5).getMemberNodes().get(0).getName());
}
@@ -226,7 +233,9 @@ public class GetEntityTest {
assertEquals(1, entities.size());
assertEquals("jennyvtsbcvlanvnf..External..0", entities.get(0).getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- assertEquals(EntityTemplateType.GROUP, entities.get(0).getTargetNodes().get(0).getType());
+ assertEquals(EntityTemplateType.GROUP, entities.get(0).getTargetEntities().get(0).getEntityType());
+ assertEquals("org.openecomp.policies.External", entities.get(0).getToscaType());
+ assertTrue(entities.get(0).getMembers().isEmpty());
assertEquals("jenny vTSBC vlan VNF 0", entities.get(0).getPath());
}
@@ -252,7 +261,8 @@ public class GetEntityTest {
List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false);
assertEquals(1, entities.size());
- assertEquals(EntityTemplateType.GROUP, entities.get(0).getTargetNodes().get(0).getType());
+ assertEquals(EntityTemplateType.GROUP, entities.get(0).getTargetEntities().get(0).getEntityType());
+ assertTrue(entities.get(0).getMembers().isEmpty());
assertTrue(entities.get(0).getRequirements().isEmpty());
assertTrue(entities.get(0).getCapabilities().isEmpty());
assertEquals("jenny vTSBC vlan VNF 0", entities.get(0).getPath());
@@ -290,6 +300,8 @@ public class GetEntityTest {
List<IEntityDetails> entities = helper.getEntity(null, topologyTemplateQuery, false);
assertEquals(5, entities.size());
+ assertEquals("org.openecomp.resource.vf.JennyVtsbcVlanVnf", entities.get(4).getToscaType());
+ assertEquals("org.openecomp.groups.VfModule", entities.get(0).getToscaType());
}
@@ -310,7 +322,15 @@ public class GetEntityTest {
List<IEntityDetails> entities = helper.getEntity(null, topologyTemplateQuery, false);
assertEquals(2, entities.size());
- assertTrue("ssc_subint_mis_vmi_0".equals(entities.get(0).getName()) || "ssc_subint_mis_vmi_0".equals(entities.get(1).getName()));
+ assertTrue(entities.get(1).getMembers().isEmpty());
+ assertEquals("ssc_subint_mis_vmi_0", entities.get(0).getMembers().get(0));
+ assertTrue("ssc_subint_mis_vmi_0".equals(entities.get(1).getName()));
+ assertTrue("vlan_subinterface_ssc_mis_group".equals(entities.get(0).getName()));
+ assertEquals("org.openecomp.resource.cp.nodes.heat.network.v2.contrailV2.VLANSubInterface",
+ entities.get(1).getToscaType());
+ assertEquals("org.openecomp.groups.heat.HeatStack", entities.get(0).getToscaType());
+ assertTrue(entities.get(0).getTargetEntities().isEmpty());
+
}
@Test
diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserPolicyTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserPolicyTest.java
new file mode 100644
index 0000000..f77b070
--- /dev/null
+++ b/src/test/java/org/onap/sdc/impl/ToscaParserPolicyTest.java
@@ -0,0 +1,55 @@
+package org.onap.sdc.impl;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.Policy;
+
+import java.net.URL;
+import java.util.List;
+
+import static org.junit.Assert.assertTrue;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+public class ToscaParserPolicyTest {
+
+ private static ISdcCsarHelper helper = null;
+
+ @BeforeClass
+ public static void setUpClass() {
+ try {
+ URL resource = GetEntityPortMirroringTest.class.getClassLoader()
+ .getResource("csars/service-CgnatFwVnfNc-csar.csar");
+ if (resource != null) {
+ helper = SdcToscaParserFactory.getInstance().getSdcCsarHelper(resource.getFile());
+ }
+
+ } catch (SdcToscaParserException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void getPolicyOfTargetByNodeTemplate() {
+ List<NodeTemplate> vfList = helper.getServiceVfList();
+ assertEquals(1, vfList.size());
+ List<Policy> policies = helper.getPoliciesOfTarget(vfList.get(0));
+ assertNotNull(policies);
+ assertTrue(policies.isEmpty());
+ }
+
+ @Test
+ public void getPolicyTargetFromOrigin() {
+ List<NodeTemplate> vfList = helper.getServiceVfList();
+ assertEquals(1, vfList.size());
+ List<NodeTemplate> targets = helper.getPolicyTargetsFromOrigin(vfList.get(0), "cgnatfwvnf_nc..External..0");
+ assertNotNull(targets);
+ assertTrue(targets.isEmpty());
+ }
+
+
+}
diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserSubsMappingsTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserSubsMappingsTest.java
index cbd8e8a..afb5101 100644
--- a/src/test/java/org/onap/sdc/impl/ToscaParserSubsMappingsTest.java
+++ b/src/test/java/org/onap/sdc/impl/ToscaParserSubsMappingsTest.java
@@ -81,7 +81,7 @@ public class ToscaParserSubsMappingsTest extends SdcToscaParserBasicTest {
//
// CapabilityAssignment cCp = lCapabilitys.get(CPkeys.get(i));
// CapabilityTypeDef CpDef = cCp.getDefinition();
-// CapabilitiesTypes.add(CpDef.getType());
+// CapabilitiesTypes.add(CpDef.getEntityType());
//
// //LinkedHashMap<String,Object> lProperties = cCp.getDefinition().getProperties();
// LinkedHashMap<String, Property> lPropertiesR = cCp.getProperties();
@@ -93,7 +93,7 @@ public class ToscaParserSubsMappingsTest extends SdcToscaParserBasicTest {
// Property p = lPropertiesR.get(CP_Propkeys.get(j));
//
// if(p != null){
-// String sPType = p.getType();
+// String sPType = p.getEntityType();
// Boolean bPRequired = p.isRequired();
//
// System.out.println(sPType + " " + bPRequired);
diff --git a/src/test/resources/csars/service-CgnatFwVnfNc-csar.csar b/src/test/resources/csars/service-CgnatFwVnfNc-csar.csar
new file mode 100644
index 0000000..b4736cd
--- /dev/null
+++ b/src/test/resources/csars/service-CgnatFwVnfNc-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/service-JennnyVepdgPortMirroringTest-csar.csar b/src/test/resources/csars/service-JennnyVepdgPortMirroringTest-csar.csar
new file mode 100644
index 0000000..7e8ebb3
--- /dev/null
+++ b/src/test/resources/csars/service-JennnyVepdgPortMirroringTest-csar.csar
Binary files differ