diff options
author | Natalia Sheshukov <ns019t@intl.att.com> | 2018-02-22 16:50:05 +0200 |
---|---|---|
committer | Natalia Sheshukov <ns019t@intl.att.com> | 2018-02-22 16:50:05 +0200 |
commit | fe7a82b3a8f416fd87519caa07124261d9f117f3 (patch) | |
tree | b2d15b2dc323a06694f9640220aec44b204d6c90 /src/test | |
parent | 81fa60240af5ef6f3b60f55b62befd19ab430ef0 (diff) |
[367741] vLAN Tagging. Support Tosca Policies.
Change-Id: I4d47ee603883e4d6a2b54776d7d570ba074cc25a
Issue-ID: SDC-1056
Signed-off-by: Natalia Sheshukov <ns019t@intl.att.com>
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java | 9 | ||||
-rw-r--r-- | src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java | 5 | ||||
-rw-r--r-- | src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java | 84 | ||||
-rw-r--r-- | src/test/resources/csars/resource-Policy-csar.csar | bin | 0 -> 27747 bytes | |||
-rw-r--r-- | src/test/resources/csars/service-AlService-csar.csar | bin | 0 -> 37565 bytes |
5 files changed, 87 insertions, 11 deletions
diff --git a/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java b/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java index 1695671..b65d70b 100644 --- a/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java +++ b/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java @@ -36,7 +36,8 @@ public abstract class SdcToscaParserBasicTest { static ISdcCsarHelper resolveReqsCapsCsarQA; static ISdcCsarHelper portMirroring; static ISdcCsarHelper csarHelperServiceWithCrs; - + static ISdcCsarHelper csarHelperServicePolicy; + static ISdcCsarHelper csarHelperVfPolicy; static Map<String, HashMap<String, List<String>>> fdntCsarHelper_Data; @@ -59,8 +60,10 @@ public abstract class SdcToscaParserBasicTest { resolveReqsCapsCsarQA = getCsarHelper("csars/service-sunny-flow2.csar"); portMirroring = getCsarHelper("csars/service-PortMirroring.csar"); csarHelperServiceWithCrs = getCsarHelper("csars/service-CrTestService-csar.csar"); - - fdntCsarHelper_Data = new HashMap<String, HashMap<String, List<String>>>(){ + csarHelperVfPolicy = getCsarHelper("csars/resource-Policy-csar.csar"); + csarHelperServicePolicy = getCsarHelper("csars/service-AlService-csar.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 4a17b66..0725cb9 100644 --- a/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java +++ b/src/test/java/org/openecomp/sdc/impl/ToscaParserMetadataTest.java @@ -3,6 +3,7 @@ package org.openecomp.sdc.impl; import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper; import org.openecomp.sdc.tosca.parser.config.ConfigurationManager; import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException; +import org.openecomp.sdc.tosca.parser.impl.SdcToscaParserFactory; import org.openecomp.sdc.toscaparser.api.NodeTemplate; import org.openecomp.sdc.toscaparser.api.elements.Metadata; import org.testng.annotations.Test; @@ -207,7 +208,7 @@ public class ToscaParserMetadataTest extends SdcToscaParserBasicTest { SdcToscaParserException { ConfigurationManager configurationManager = ConfigurationManager.getInstance(); configurationManager.setErrorConfiguration("error-configuration-test.yaml"); - factory.setConfigurationManager(configurationManager); + SdcToscaParserFactory.setConfigurationManager(configurationManager); ISdcCsarHelper missingCSARMetaCsarCustomConfig = getCsarHelper ("csars/service-missing-csar-meta-file.csar"); @@ -217,7 +218,7 @@ public class ToscaParserMetadataTest extends SdcToscaParserBasicTest { .getMaxVersion()); configurationManager.setErrorConfiguration("error-configuration.yaml"); - factory.setConfigurationManager(configurationManager); + SdcToscaParserFactory.setConfigurationManager(configurationManager); } @Test(expectedExceptions = SdcToscaParserException.class) diff --git a/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java b/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java index 04675b4..32336af 100644 --- a/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java +++ b/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java @@ -5,8 +5,6 @@ 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 com.google.common.collect.ImmutableMap; import org.apache.commons.lang3.tuple.Pair; import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException; @@ -14,11 +12,8 @@ import org.openecomp.sdc.tosca.parser.impl.FilterType; import org.openecomp.sdc.tosca.parser.impl.SdcTypes; import org.openecomp.sdc.toscaparser.api.Group; import org.openecomp.sdc.toscaparser.api.NodeTemplate; -import org.openecomp.sdc.toscaparser.api.Property; import org.testng.annotations.Test; -import fj.data.fingertrees.Node; - public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest { //region getServiceVfList @@ -965,7 +960,84 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest { assertEquals(crTemplate.getPropertyValue("nf_naming").toString(), ImmutableMap.of("ecomp_generated_naming", "true").toString()); assertEquals(crTemplate.getPropertyValue("contrailport0_virtual_network"), "chaya"); } - + + @Test + 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); + assertNotNull(policies); + assertEquals(policies.size(), 3); + policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplate(nt1); + assertNotNull(policies); + assertEquals(policies.size(), 3); + } + + @Test + 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"); + assertNotNull(policies); + assertEquals(policies.size(), 1); + + policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt0, "org.openecomp.policies.placement.Antilocate"); + assertNotNull(policies); + assertEquals(policies.size(), 1); + + policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt0, "org.openecomp.policies.placement.valet.Diversity"); + assertNotNull(policies); + assertEquals(policies.size(), 1); + + policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt1, "org.openecomp.policies.placement.Colocate"); + assertNotNull(policies); + assertEquals(policies.size(), 1); + + policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt1, "org.openecomp.policies.placement.Antilocate"); + assertNotNull(policies); + assertEquals(policies.size(), 1); + + policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt1, "org.openecomp.policies.placement.valet.Diversity"); + assertNotNull(policies); + assertEquals(policies.size(), 1); + } + + @Test + public void testGetPolicyTargetNodeTemplatesFromOrigin() { + List<Map<String, Object>> nodeTemplates = csarHelperServicePolicy.getPolicyTargetsFromOrigin(csarHelperServicePolicy.getNodeTemplateByName("al_vf 1"),"policy..Colocate..0"); + assertNotNull(nodeTemplates); + assertEquals(nodeTemplates.size(), 2); + } + + @Test + public void testGetPoliciesOfNodeTemplate() { + NodeTemplate nt0 = csarHelperVfPolicy.getNodeTemplateByName("al_vfc 1"); + List<Map<String, Map<String, Object>>> policies = csarHelperVfPolicy.getPoliciesOfTarget(nt0); + assertNotNull(policies); + assertEquals(policies.size(), 1); + } + + @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"); + assertNotNull(policies); + assertEquals(policies.size(), 1); + } + + @Test + public void testGetPoliciesOfTopologyTemplate() { + List<Map<String, Map<String, Object>>> policies = csarHelperVfPolicy.getPoliciesOfTopologyTemplate(); + assertNotNull(policies); + assertEquals(policies.size(), 1); + } + + @Test + public void testGetPolicyTargetNodeTemplates() { + List<NodeTemplate> nodeTemplates = csarHelperVfPolicy.getPolicyTargetsFromTopologyTemplate("policy..Colocate..0"); + assertNotNull(nodeTemplates); + assertEquals(nodeTemplates.size(), 2); + } } diff --git a/src/test/resources/csars/resource-Policy-csar.csar b/src/test/resources/csars/resource-Policy-csar.csar Binary files differnew file mode 100644 index 0000000..d6d7b42 --- /dev/null +++ b/src/test/resources/csars/resource-Policy-csar.csar diff --git a/src/test/resources/csars/service-AlService-csar.csar b/src/test/resources/csars/service-AlService-csar.csar Binary files differnew file mode 100644 index 0000000..2532683 --- /dev/null +++ b/src/test/resources/csars/service-AlService-csar.csar |