diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java | 12 | ||||
-rw-r--r-- | src/test/java/org/onap/sdc/impl/ToscaParserInterfaceTest.java | 59 | ||||
-rw-r--r-- | src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java | 133 | ||||
-rw-r--r-- | src/test/resources/csars/resource-Policy-csar.csar | bin | 27747 -> 27745 bytes | |||
-rw-r--r-- | src/test/resources/csars/resource-Vdbe-csar.csar | bin | 0 -> 68955 bytes | |||
-rw-r--r-- | src/test/resources/csars/service-AlService-csar.csar | bin | 37565 -> 37564 bytes | |||
-rw-r--r-- | src/test/resources/csars/service-CxSvc-csar.csar | bin | 0 -> 80873 bytes | |||
-rw-r--r-- | src/test/resources/csars/service-Groupstest-csar.csar | bin | 0 -> 177826 bytes | |||
-rw-r--r-- | src/test/resources/csars/service-VdbePx-csar.csar | bin | 0 -> 39145 bytes | |||
-rw-r--r-- | src/test/resources/csars/service-VdbeSrv-csar.csar | bin | 0 -> 75330 bytes | |||
-rw-r--r-- | src/test/resources/csars/service-VlanD2dSrv-csar.csar | bin | 0 -> 75442 bytes |
11 files changed, 195 insertions, 9 deletions
diff --git a/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java b/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java index e1ea39f..08f5bf1 100644 --- a/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java +++ b/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java @@ -37,6 +37,12 @@ public abstract class SdcToscaParserBasicTest { static ISdcCsarHelper csarHelperServiceWithCrs; static ISdcCsarHelper csarHelperServicePolicy; static ISdcCsarHelper csarHelperVfPolicy; + static ISdcCsarHelper csarHelperServiceGroups; + static ISdcCsarHelper csarHelperServiceGroupsInputs; + static ISdcCsarHelper csarHelperServiceGroupsCapabilities; + static ISdcCsarHelper csarHelperVfGroupsPolicies; + static ISdcCsarHelper csarHelperServiceGroupsPolicies; + static ISdcCsarHelper csarHelperVfInterfaces; static Map<String, HashMap<String, List<String>>> fdntCsarHelper_Data; @@ -61,6 +67,12 @@ public abstract class SdcToscaParserBasicTest { csarHelperServiceWithCrs = getCsarHelper("csars/service-CrTestService-csar.csar"); csarHelperVfPolicy = getCsarHelper("csars/resource-Policy-csar.csar"); csarHelperServicePolicy = getCsarHelper("csars/service-AlService-csar.csar"); + csarHelperServiceGroups = getCsarHelper("csars/service-Groupstest-csar.csar"); + csarHelperServiceGroupsInputs = getCsarHelper("csars/service-VdbeSrv-csar.csar"); + csarHelperServiceGroupsCapabilities = getCsarHelper("csars/service-VdbePx-csar.csar"); + csarHelperVfGroupsPolicies = getCsarHelper("csars/resource-Vdbe-csar.csar"); + csarHelperServiceGroupsPolicies = getCsarHelper("csars/service-VlanD2dSrv-csar.csar"); + csarHelperVfInterfaces = getCsarHelper("csars/service-CxSvc-csar.csar"); fdntCsarHelper_Data = new HashMap<String, HashMap<String, List<String>>>(){ { diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserInterfaceTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserInterfaceTest.java new file mode 100644 index 0000000..e6755e1 --- /dev/null +++ b/src/test/java/org/onap/sdc/impl/ToscaParserInterfaceTest.java @@ -0,0 +1,59 @@ +package org.onap.sdc.impl; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import java.util.List; +import java.util.Map; +import org.mockito.internal.util.collections.Sets; +import org.onap.sdc.toscaparser.api.NodeTemplate; +import org.onap.sdc.toscaparser.api.elements.InterfacesDef; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class ToscaParserInterfaceTest extends SdcToscaParserBasicTest { + + List<NodeTemplate> vfs; + + @BeforeClass + public void setup(){ + vfs = csarHelperVfInterfaces.getServiceVfList(); + } + + @Test + public void testGetInterfaceOf() { + Map<String, List<InterfacesDef>> interfaceDetails = csarHelperVfInterfaces.getInterfacesOf(vfs.get(0)); + assertNotNull(interfaceDetails); + assertEquals(interfaceDetails.size(), 2); + } + + @Test + public void testGetInterfaces() { + List<String> interfaceNames = csarHelperVfInterfaces.getInterfaces(vfs.get(0)); + assertNotNull(interfaceNames); + assertEquals(interfaceNames, Sets.newSet("org.openecomp.interfaces.node.lifecycle.CxVnf1", "tosca.interfaces.node.lifecycle.Standard")); + } + + @Test + public void testGetInterfaceDetails() { + List<InterfacesDef> interfaceDetails = csarHelperVfInterfaces.getInterfaceDetails(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1"); + assertNotNull(interfaceDetails); + assertEquals(interfaceDetails.get(0).getOperationName(), "instantiate"); + assertEquals(interfaceDetails.get(1).getOperationName(), "upgrade"); + } + + @Test + public void testGetAllInterfaceOperations() { + List<String> operations = csarHelperVfInterfaces.getAllInterfaceOperations(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1"); + assertNotNull(operations); + assertEquals(operations, Sets.newSet("instantiate", "upgrade", "create", "configure", "start", "stop", "delete")); + } + + @Test + public void testGetInterfaceOperationDetails() { + InterfacesDef interfaceDef = csarHelperVfInterfaces.getInterfaceOperationDetails(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1", "instantiate"); + assertNotNull(interfaceDef); + assertEquals(interfaceDef.getOperationName(), "instantiate"); + } + +} diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java index 9cd56c4..0acfdf6 100644 --- a/src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java +++ b/src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java @@ -5,18 +5,21 @@ import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.util.*; +import java.util.stream.Collectors; + import com.google.common.collect.ImmutableMap; import org.apache.commons.lang3.tuple.Pair; import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException; import org.onap.sdc.tosca.parser.impl.FilterType; import org.onap.sdc.tosca.parser.impl.SdcTypes; +import org.onap.sdc.toscaparser.api.CapabilityAssignment; +import org.onap.sdc.toscaparser.api.CapabilityAssignments; import org.onap.sdc.toscaparser.api.Group; import org.onap.sdc.toscaparser.api.NodeTemplate; +import org.onap.sdc.toscaparser.api.Policy; import org.onap.sdc.toscaparser.api.Property; import org.testng.annotations.Test; -import fj.data.fingertrees.Node; - public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest { //region getServiceVfList @@ -334,6 +337,7 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest { //endregion //region getCpPropertiesFromVfc + @SuppressWarnings("unchecked") @Test public void testGetCpPropertiesFromVfc() { List<NodeTemplate> vfcs = ipAssignCsarHelper.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b"); @@ -759,6 +763,7 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest { //endregion //region resolve get_input + @SuppressWarnings("rawtypes") @Test public void testResolveGetInputForComplexTypeAndList() { //port_pd01_port_ip_requirements is of type list<org.openecomp.datatypes.network.IpRequirements> @@ -793,6 +798,7 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest { assertEquals("1", propertyAsObject); } + @SuppressWarnings("rawtypes") @Test public void testResolveGetInputForMap() { //This test covers "default" resolving of primitive - as Map @@ -835,6 +841,7 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest { // region Added by QA - Continue with testings of resolve get_input + @SuppressWarnings("rawtypes") @Test public void testResolveGetInputForComplexTypeAndListWithFalseValue() { @@ -926,6 +933,7 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest { // endregion Added by QA - Continue with testings of resolve get_input + @SuppressWarnings("rawtypes") @Test public void testResolveGetInputArrayStructure() { List<NodeTemplate> vfcs = resolveGetInputCsarQA.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b"); @@ -968,7 +976,7 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest { public void testGetPoliciesOfOriginOfNodeTemplate() { NodeTemplate nt0 = csarHelperServicePolicy.getNodeTemplateByName("al_vf 0"); NodeTemplate nt1 = csarHelperServicePolicy.getNodeTemplateByName("al_vf 1"); - List<Map<String, Object>> policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplate(nt0); + List<Policy> policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplate(nt0); assertNotNull(policies); assertEquals(policies.size(), 3); policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplate(nt1); @@ -980,7 +988,7 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest { public void testGetPoliciesOfOriginOfNodeTemplateByToscaPolicyType() { NodeTemplate nt0 = csarHelperServicePolicy.getNodeTemplateByName("al_vf 0"); NodeTemplate nt1 = csarHelperServicePolicy.getNodeTemplateByName("al_vf 1"); - List<Map<String, Object>> policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt0, "org.openecomp.policies.placement.Colocate"); + List<Policy> policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt0, "org.openecomp.policies.placement.Colocate"); assertNotNull(policies); assertEquals(policies.size(), 1); @@ -1007,7 +1015,7 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest { @Test public void testGetPolicyTargetNodeTemplatesFromOrigin() { - List<Map<String, Object>> nodeTemplates = csarHelperServicePolicy.getPolicyTargetsFromOrigin(csarHelperServicePolicy.getNodeTemplateByName("al_vf 1"),"policy..Colocate..0"); + List<NodeTemplate> nodeTemplates = csarHelperServicePolicy.getPolicyTargetsFromOrigin(csarHelperServicePolicy.getNodeTemplateByName("al_vf 1"),"policy..Colocate..0"); assertNotNull(nodeTemplates); assertEquals(nodeTemplates.size(), 2); } @@ -1015,7 +1023,7 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest { @Test public void testGetPoliciesOfNodeTemplate() { NodeTemplate nt0 = csarHelperVfPolicy.getNodeTemplateByName("al_vfc 1"); - List<Map<String, Map<String, Object>>> policies = csarHelperVfPolicy.getPoliciesOfTarget(nt0); + List<Policy> policies = csarHelperVfPolicy.getPoliciesOfTarget(nt0); assertNotNull(policies); assertEquals(policies.size(), 1); } @@ -1023,14 +1031,14 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest { @Test public void testGetPoliciesOfNodeTemplateByToscaPolicyType() { NodeTemplate nt0 = csarHelperVfPolicy.getNodeTemplateByName("al_vfc 1"); - List<Map<String, Map<String, Object>>> policies = csarHelperVfPolicy.getPoliciesOfTargetByToscaPolicyType(nt0, "org.openecomp.policies.placement.Colocate"); + List<Policy> policies = csarHelperVfPolicy.getPoliciesOfTargetByToscaPolicyType(nt0, "org.openecomp.policies.placement.Colocate"); assertNotNull(policies); assertEquals(policies.size(), 1); } @Test public void testGetPoliciesOfTopologyTemplate() { - List<Map<String, Map<String, Object>>> policies = csarHelperVfPolicy.getPoliciesOfTopologyTemplate(); + List<Policy> policies = csarHelperVfPolicy.getPoliciesOfTopologyTemplate(); assertNotNull(policies); assertEquals(policies.size(), 1); } @@ -1041,7 +1049,114 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest { assertNotNull(nodeTemplates); assertEquals(nodeTemplates.size(), 2); } - + + @Test + public void testGetGroups() { + NodeTemplate groupsVf = csarHelperServiceGroups.getNodeTemplateByName("GroupsVf 0"); + NodeTemplate vlanGroups = csarHelperServiceGroups.getNodeTemplateByName("VlanGroups 0"); + + ArrayList<Group> groups = csarHelperServiceGroups.getGroupsOfOriginOfNodeTemplate(groupsVf); + assertNotNull(groups); + assertEquals(groups.size(), 5); + + groups = csarHelperServiceGroups.getGroupsOfOriginOfNodeTemplate(vlanGroups); + assertNotNull(groups); + assertEquals(groups.size(), 4); + + groups = csarHelperServiceGroups.getGroupsOfOriginOfNodeTemplateByToscaGroupType(groupsVf, "org.openecomp.groups.VfcInstanceGroup"); + assertNotNull(groups); + assertEquals(groups.size(), 1); + + groups = csarHelperServiceGroups.getGroupsOfOriginOfNodeTemplateByToscaGroupType(vlanGroups, "org.openecomp.groups.VfcInstanceGroup"); + assertNotNull(groups); + assertEquals(groups.size(), 2); + + List<NodeTemplate> members = csarHelperServiceGroups.getGroupMembersOfOriginOfNodeTemplate(groupsVf, "x_group"); + + assertNotNull(members); + assertEquals(members.size(), 3); + Optional<NodeTemplate> memberOpt = (members.stream().filter(m -> m.getName().equals("lb_1"))).findFirst(); + assertTrue(memberOpt.isPresent()); + memberOpt = (members.stream().filter(m -> m.getName().equals("lb_2"))).findFirst(); + assertTrue(memberOpt.isPresent()); + memberOpt = (members.stream().filter(m -> m.getName().equals("mg_4"))).findFirst(); + assertTrue(memberOpt.isPresent()); + + members = csarHelperServiceGroups.getGroupMembersOfOriginOfNodeTemplate(vlanGroups, "oam_group"); + assertNotNull(members); + assertEquals(members.size(), 1); + memberOpt = (members.stream().filter(m -> m.getName().equals("abstract_vdbe_1"))).findFirst(); + assertTrue(memberOpt.isPresent()); + + members = csarHelperServiceGroups.getGroupMembersOfOriginOfNodeTemplate(vlanGroups, "untr_group"); + assertNotNull(members); + assertEquals(members.size(), 1); + memberOpt = (members.stream().filter(m -> m.getName().equals("abstract_vdbe"))).findFirst(); + assertTrue(memberOpt.isPresent()); + } + + @Test + public void testGetGroupsInputsProperties() { + NodeTemplate vdbe0 = csarHelperServiceGroupsInputs.getNodeTemplateByName("vDBE 0"); + ArrayList<Group> groups = csarHelperServiceGroupsInputs.getGroupsOfOriginOfNodeTemplate(vdbe0); + assertNotNull(groups); + assertEquals(groups.size(), 4); + + Optional<Group> groupOpt = (groups.stream().filter(g -> g.getName().equals("oam_group"))).findFirst(); + assertTrue(groupOpt.isPresent()); + Group group = groupOpt.get(); + validateInputsProperties(vdbe0, group); + + groupOpt = (groups.stream().filter(g -> g.getName().equals("untr_group"))).findFirst(); + assertTrue(groupOpt.isPresent()); + group = groupOpt.get(); + validateInputsProperties(vdbe0, group); + } + + @Test + public void testGetGroupsInputsCapabilities() { + NodeTemplate vdbe = csarHelperServiceGroupsCapabilities.getNodeTemplateByName("vdbe_srv_proxy 0"); + CapabilityAssignments capabilities = csarHelperServiceGroupsCapabilities.getCapabilitiesOf(vdbe); + CapabilityAssignment capability = capabilities.getCapabilityByName("vdbe0.oam_group.vlan_assignment"); + assertNotNull(capability); + } + + @SuppressWarnings("unchecked") + private void validateInputsProperties(NodeTemplate vdbe0, Group group) { + assertNotNull(group.getPropertiesObjects()); + ArrayList<Property> properties = group.getPropertiesObjects(); + + List<String> inputs = properties.stream() + .filter(p -> p.getValue() instanceof Map) + .map(p -> ((Map<String, String>)p.getValue()).get("get_input")) + .collect(Collectors.toList()); + + assertEquals(inputs.size(), 2); + + inputs.forEach(i -> assertTrue(vdbe0.getProperties().containsKey(i))); + + List<Object> list = vdbe0.getProperties().entrySet().stream() + .filter(e -> inputs.contains(e.getKey())) + .map(e -> e.getValue().getValue()) + .collect(Collectors.toList()); + assertEquals(list.size(), 2); + } + + @Test + public void testGetVfGroupsPolicies() { + List<Policy> policies = csarHelperVfGroupsPolicies.getPoliciesOfTopologyTemplate(); + assertNotNull(policies); + List<Group> groups = csarHelperVfGroupsPolicies.getGroupsOfTopologyTemplate(); + assertNotNull(groups); + } + @Test + public void testGetServiceGroupsPolicies() { + NodeTemplate nt = csarHelperServiceGroupsPolicies.getNodeTemplateByName("vDBE 0"); + List<Policy> policies = csarHelperServiceGroupsPolicies.getPoliciesOfOriginOfNodeTemplate(nt); + assertNotNull(policies); + List<Group> groups = csarHelperServiceGroupsPolicies.getGroupsOfOriginOfNodeTemplate(nt); + assertNotNull(groups); + } } diff --git a/src/test/resources/csars/resource-Policy-csar.csar b/src/test/resources/csars/resource-Policy-csar.csar Binary files differindex d6d7b42..67cc528 100644 --- a/src/test/resources/csars/resource-Policy-csar.csar +++ b/src/test/resources/csars/resource-Policy-csar.csar diff --git a/src/test/resources/csars/resource-Vdbe-csar.csar b/src/test/resources/csars/resource-Vdbe-csar.csar Binary files differnew file mode 100644 index 0000000..3bf878c --- /dev/null +++ b/src/test/resources/csars/resource-Vdbe-csar.csar diff --git a/src/test/resources/csars/service-AlService-csar.csar b/src/test/resources/csars/service-AlService-csar.csar Binary files differindex 2532683..c02097d 100644 --- a/src/test/resources/csars/service-AlService-csar.csar +++ b/src/test/resources/csars/service-AlService-csar.csar diff --git a/src/test/resources/csars/service-CxSvc-csar.csar b/src/test/resources/csars/service-CxSvc-csar.csar Binary files differnew file mode 100644 index 0000000..feb67c9 --- /dev/null +++ b/src/test/resources/csars/service-CxSvc-csar.csar diff --git a/src/test/resources/csars/service-Groupstest-csar.csar b/src/test/resources/csars/service-Groupstest-csar.csar Binary files differnew file mode 100644 index 0000000..2428c03 --- /dev/null +++ b/src/test/resources/csars/service-Groupstest-csar.csar diff --git a/src/test/resources/csars/service-VdbePx-csar.csar b/src/test/resources/csars/service-VdbePx-csar.csar Binary files differnew file mode 100644 index 0000000..3032768 --- /dev/null +++ b/src/test/resources/csars/service-VdbePx-csar.csar diff --git a/src/test/resources/csars/service-VdbeSrv-csar.csar b/src/test/resources/csars/service-VdbeSrv-csar.csar Binary files differnew file mode 100644 index 0000000..2958cfc --- /dev/null +++ b/src/test/resources/csars/service-VdbeSrv-csar.csar diff --git a/src/test/resources/csars/service-VlanD2dSrv-csar.csar b/src/test/resources/csars/service-VlanD2dSrv-csar.csar Binary files differnew file mode 100644 index 0000000..cbe355f --- /dev/null +++ b/src/test/resources/csars/service-VlanD2dSrv-csar.csar |