summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-tosca-lib/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-lib/src/test')
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java40
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithSubstitutionMapping.yaml17
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/substitutionMappingExt.yaml23
3 files changed, 80 insertions, 0 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 5412b55129..2833cc456d 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
@@ -62,6 +62,8 @@ public class ToscaModelTest {
private static final String DEPENDENCY_NAME = "script1.sh";
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";
@Test
public void testServiceTemplateJavaToYaml() {
@@ -448,6 +450,44 @@ public class ToscaModelTest {
}
+ @Test
+ public void testSubstitutionMapping() throws IOException {
+ ServiceTemplate serviceTemplate = getServiceTemplateExt(BASE_DIR + SUBSTITUTION_MAPPING);
+
+ 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());
+
+ }
+
+ @Test
+ public void testSubstitutionMappingExt() throws IOException {
+ ServiceTemplate serviceTemplate = getServiceTemplateExt(BASE_DIR + SUBSTITUTION_MAPPING_EXT);
+
+ 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();
+ Assert.assertNotNull(substitutionFilter);
+ Assert.assertNotNull(substitutionFilter.getProperties());
+ Assert.assertEquals(2,substitutionFilter.getProperties().size());
+ 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 {
try (InputStream yamlFile = yamlUtil.loadYamlFileIs(inputPath)) {
return yamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithSubstitutionMapping.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithSubstitutionMapping.yaml
new file mode 100644
index 0000000000..b5e5480f82
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithSubstitutionMapping.yaml
@@ -0,0 +1,17 @@
+tosca_definitions_version: tosca_simple_yaml_1_0_0
+metadata:
+ template_name: Test
+ template_author: OPENECOMP
+ template_version: 1.0.0
+description: testing desc tosca service template
+
+topology_template:
+ description: topologi template descroption
+ substitution_mappings:
+ node_type: myNodeType.node
+ capabilities:
+ database_endpoint:
+ - database
+ - database_endpoint
+ requirements:
+ database_endpoint: [ app, database ]
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/substitutionMappingExt.yaml
new file mode 100644
index 0000000000..ae6a88ea77
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/substitutionMappingExt.yaml
@@ -0,0 +1,23 @@
+tosca_definitions_version: tosca_simple_yaml_1_0_0
+metadata:
+ template_name: Test
+ template_author: OPENECOMP
+ template_version: 1.0.0
+description: testing desc tosca service template
+
+topology_template:
+ description: topologi template descroption
+ substitution_mappings:
+ node_type: myNodeType.node
+ capabilities:
+ database_endpoint:
+ - database
+ - database_endpoint
+ requirements:
+ database_endpoint: [ app, database ]
+ substitution_filter:
+ properties:
+ - vendor: [{ equal : Simple }]
+ - bandwidth: [{ less_than: 100 GB }]
+
+