diff options
author | Rokhvarg David <dr2032@att.com> | 2018-03-11 16:40:55 +0200 |
---|---|---|
committer | Rokhvarg David <dr2032@att.com> | 2018-03-11 16:40:55 +0200 |
commit | 45497ffff524a82e4e5d41c2272409c5b7fca2df (patch) | |
tree | b125aa0b584c22d031fc1422f29b1f0fef83ea13 /src/test/java | |
parent | 4cea23f8111aa3d3532ec8d74351eccbf0ac44a5 (diff) |
extend policy and group api
Change-Id: I6ffdcdc1057ea53d7211008abd6c1ae0e2a9f54d
Issue-ID: SDC-1056
Signed-off-by: Rokhvarg David <dr2032@att.com>
Diffstat (limited to 'src/test/java')
3 files changed, 86 insertions, 8 deletions
diff --git a/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java b/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java index 39f5190..e1ea39f 100644 --- a/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java +++ b/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java @@ -35,7 +35,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; @@ -58,8 +59,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/onap/sdc/impl/ToscaParserMetadataTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserMetadataTest.java index 8487dec..db28e79 100644 --- a/src/test/java/org/onap/sdc/impl/ToscaParserMetadataTest.java +++ b/src/test/java/org/onap/sdc/impl/ToscaParserMetadataTest.java @@ -210,7 +210,7 @@ public class ToscaParserMetadataTest extends SdcToscaParserBasicTest { ConfigurationManager configurationManager = ConfigurationManager.getInstance(); try { configurationManager.setErrorConfiguration("error-configuration-test.yaml"); - factory.setConfigurationManager(configurationManager); + SdcToscaParserFactory.setConfigurationManager(configurationManager); ISdcCsarHelper missingCSARMetaCsarCustomConfig = getCsarHelper ("csars/service-missing-csar-meta-file.csar"); String conformanceLevel = missingCSARMetaCsarCustomConfig.getConformanceLevel(); @@ -220,7 +220,7 @@ public class ToscaParserMetadataTest extends SdcToscaParserBasicTest { } finally { configurationManager.setErrorConfiguration("error-configuration.yaml"); - factory.setConfigurationManager(configurationManager); + SdcToscaParserFactory.setConfigurationManager(configurationManager); } } diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java index 0692ebe..9cd56c4 100644 --- a/src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java +++ b/src/test/java/org/onap/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.onap.sdc.tosca.parser.exceptions.SdcToscaParserException; @@ -965,7 +963,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); + } } |