diff options
author | Sheshukov, Natalia (ns019t) <ns019t@intl.att.com> | 2018-04-09 15:03:06 +0300 |
---|---|---|
committer | Sheshukov, Natalia (ns019t) <ns019t@intl.att.com> | 2018-04-09 16:53:45 +0300 |
commit | a5a24ad0f22bdb06e3194f392df322b48b1b2316 (patch) | |
tree | 940d9aeb7f6c43616447d396280649406fe139af /src/test/java/org/onap | |
parent | b0ed12f587f7f87dedb0b838664800662bc4ca8e (diff) |
vLAN Tagging
Support Tosca Groups - TOSCA parser (refactoring)
Change-Id: I10c6b8e5356bea0e85e8b448c23d9f05ac3ab837
Issue-ID: SDC-1199
Signed-off-by: Sheshukov, Natalia (ns019t) <ns019t@intl.att.com>
Diffstat (limited to 'src/test/java/org/onap')
-rw-r--r-- | src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java | 10 | ||||
-rw-r--r-- | src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java | 133 |
2 files changed, 134 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..ff4f3db 100644 --- a/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java +++ b/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java @@ -37,6 +37,11 @@ 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 Map<String, HashMap<String, List<String>>> fdntCsarHelper_Data; @@ -61,6 +66,11 @@ 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"); fdntCsarHelper_Data = new HashMap<String, HashMap<String, List<String>>>(){ { 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); + } } |