aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-tosca-lib/src
diff options
context:
space:
mode:
authoraribeiro <anderson.ribeiro@est.tech>2020-06-24 08:34:22 +0100
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-07-09 09:34:30 +0000
commitbdeb28f273da2494d7eeabbb5329222dfd168e3b (patch)
tree2cf9e54e83db704ee7215b033a2abde9ab8adee7 /openecomp-be/lib/openecomp-tosca-lib/src
parent0132d3637a889f84897d6a08688b20ff6f606041 (diff)
Add support for substitution_filter business logic
Tosca simple YAML profile allows for substitution_filter to be specified for a topology template to provide processing instructions to the orchestrator. Issue-ID: SDC-3147 Signed-off-by: aribeiro <anderson.ribeiro@est.tech> Change-Id: Ia94b8c447d3157e614f9d1524ad4520b3980ba4d
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-lib/src')
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java27
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/substitutionMappingWithFilter.yaml (renamed from openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/substitutionMappingExt.yaml)0
2 files changed, 9 insertions, 18 deletions
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java
index 88e8461299..4ad4d2b53e 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java
@@ -52,8 +52,6 @@ import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
import org.onap.sdc.tosca.datatypes.model.SubstitutionMapping;
import org.onap.sdc.tosca.datatypes.model.TopologyTemplate;
import org.onap.sdc.tosca.datatypes.model.extension.RequirementAssignmentExt;
-import org.onap.sdc.tosca.datatypes.model.extension.SubstitutionFilter;
-import org.onap.sdc.tosca.datatypes.model.extension.SubstitutionMappingExt;
import org.onap.sdc.tosca.datatypes.model.heatextend.ParameterDefinitionExt;
import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil;
import org.onap.sdc.tosca.services.YamlUtil;
@@ -89,7 +87,7 @@ public class ToscaModelTest {
private static final String STRING_TYPE = "string";
private static final String ST_WITH_SERVICE_FILTER = "/serviceTemplateWithServiceFilter.yaml";
private static final String SUBSTITUTION_MAPPING = "/serviceTemplateWithSubstitutionMapping.yaml";
- private static final String SUBSTITUTION_MAPPING_EXT = "/substitutionMappingExt.yaml";
+ private static final String SUBSTITUTION_MAPPING_WITH_FILTER = "/substitutionMappingWithFilter.yaml";
@Test
public void testServiceTemplateJavaToYaml() {
@@ -460,40 +458,33 @@ public class ToscaModelTest {
@Test
public void testSubstitutionMapping() throws IOException {
- ServiceTemplate serviceTemplate = getServiceTemplateExt(BASE_DIR + SUBSTITUTION_MAPPING);
-
- SubstitutionMapping substitutionMappings = DataModelUtil.getSubstitutionMappings(serviceTemplate);
+ final ServiceTemplate serviceTemplate = getServiceTemplateExt(BASE_DIR + SUBSTITUTION_MAPPING);
+ final SubstitutionMapping substitutionMappings = DataModelUtil.getSubstitutionMappings(serviceTemplate);
Assert.assertEquals("myNodeType.node", substitutionMappings.getNode_type());
Assert.assertNotNull(substitutionMappings.getCapabilities());
Assert.assertEquals(1,substitutionMappings.getCapabilities().size());
Assert.assertNotNull(substitutionMappings.getRequirements());
Assert.assertEquals(1,substitutionMappings.getRequirements().size());
- Assert.assertEquals(true, substitutionMappings instanceof SubstitutionMappingExt);
- Assert.assertNull(((SubstitutionMappingExt)substitutionMappings).getSubstitution_filter());
-
+ Assert.assertNull(substitutionMappings.getSubstitution_filter());
}
@Test
- public void testSubstitutionMappingExt() throws IOException {
- ServiceTemplate serviceTemplate = getServiceTemplateExt(BASE_DIR + SUBSTITUTION_MAPPING_EXT);
+ public void testSubstitutionMappingWithFilter() throws IOException {
+ final ServiceTemplate serviceTemplate = getServiceTemplateExt(BASE_DIR + SUBSTITUTION_MAPPING_WITH_FILTER);
- SubstitutionMapping substitutionMappings = DataModelUtil.getSubstitutionMappings(serviceTemplate);
+ final SubstitutionMapping substitutionMappings = DataModelUtil.getSubstitutionMappings(serviceTemplate);
Assert.assertEquals("myNodeType.node", substitutionMappings.getNode_type());
Assert.assertNotNull(substitutionMappings.getCapabilities());
Assert.assertEquals(1,substitutionMappings.getCapabilities().size());
Assert.assertNotNull(substitutionMappings.getRequirements());
Assert.assertEquals(1,substitutionMappings.getRequirements().size());
- Assert.assertEquals(true, substitutionMappings instanceof SubstitutionMappingExt);
- SubstitutionFilter substitutionFilter = ((SubstitutionMappingExt) substitutionMappings).getSubstitution_filter();
+ final NodeFilter substitutionFilter = substitutionMappings.getSubstitution_filter();
Assert.assertNotNull(substitutionFilter);
Assert.assertNotNull(substitutionFilter.getProperties());
Assert.assertEquals(2,substitutionFilter.getProperties().size());
- List<Constraint> vendorFilter = substitutionFilter.getProperties().get(0).get("vendor");
+ final List<Constraint> vendorFilter = substitutionFilter.getProperties().get(0).get("vendor");
Assert.assertNotNull(vendorFilter);
Assert.assertNotNull(vendorFilter.get(0).getEqual());
-
-
-
}
private ServiceTemplate getServiceTemplate(String inputPath) throws IOException {
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/substitutionMappingExt.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/substitutionMappingWithFilter.yaml
index ae6a88ea77..ae6a88ea77 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/substitutionMappingExt.yaml
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/substitutionMappingWithFilter.yaml