summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-tosca-lib/src/test
diff options
context:
space:
mode:
authorshiria <shiri.amichai@amdocs.com>2018-07-05 13:42:33 +0300
committershiria <shiri.amichai@amdocs.com>2018-07-05 13:42:33 +0300
commitd4cc2beaef58a4fc95bdc281efd879b1d1edf279 (patch)
tree11c9a118156d8b5c959b6ff009a39c9485d0d6bc /openecomp-be/lib/openecomp-tosca-lib/src/test
parent7161627bd81110f59f071595448b645b189899ea (diff)
Fix node filter get methods
Support normative properties and capabilities as regular get methods Issue-ID: SDC-1455 Change-Id: I1ab709a17a2e03f81a7ae789b8c8fb83a1d03e81 Signed-off-by: shiria <shiri.amichai@amdocs.com>
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.java52
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithServiceFilter.yaml21
2 files changed, 41 insertions, 32 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 3938d8f427..5412b55129 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
@@ -25,32 +25,9 @@ import java.util.Map;
import java.util.Optional;
import org.junit.Assert;
import org.junit.Test;
-import org.onap.sdc.tosca.datatypes.model.ArtifactType;
-import org.onap.sdc.tosca.datatypes.model.AttributeDefinition;
-import org.onap.sdc.tosca.datatypes.model.CapabilityAssignment;
-import org.onap.sdc.tosca.datatypes.model.CapabilityDefinition;
-import org.onap.sdc.tosca.datatypes.model.Constraint;
-import org.onap.sdc.tosca.datatypes.model.Directive;
-import org.onap.sdc.tosca.datatypes.model.Implementation;
-import org.onap.sdc.tosca.datatypes.model.Import;
-import org.onap.sdc.tosca.datatypes.model.InterfaceDefinition;
-import org.onap.sdc.tosca.datatypes.model.InterfaceDefinitionTemplate;
-import org.onap.sdc.tosca.datatypes.model.InterfaceDefinitionType;
-import org.onap.sdc.tosca.datatypes.model.InterfaceType;
-import org.onap.sdc.tosca.datatypes.model.NodeFilter;
-import org.onap.sdc.tosca.datatypes.model.NodeTemplate;
-import org.onap.sdc.tosca.datatypes.model.NodeType;
-import org.onap.sdc.tosca.datatypes.model.OperationDefinition;
-import org.onap.sdc.tosca.datatypes.model.OperationDefinitionTemplate;
-import org.onap.sdc.tosca.datatypes.model.OperationDefinitionType;
-import org.onap.sdc.tosca.datatypes.model.ParameterDefinition;
-import org.onap.sdc.tosca.datatypes.model.PropertyDefinition;
-import org.onap.sdc.tosca.datatypes.model.PropertyType;
+import org.onap.sdc.tosca.datatypes.model.*;
import org.onap.sdc.tosca.datatypes.model.RequirementAssignment;
-import org.onap.sdc.tosca.datatypes.model.RequirementDefinition;
-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.*;
import org.onap.sdc.tosca.datatypes.model.heatextend.ParameterDefinitionExt;
import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil;
import org.onap.sdc.tosca.services.YamlUtil;
@@ -63,6 +40,9 @@ public class ToscaModelTest {
public static final String FIRST_NODE_TEMPLATE = "firstNodeTemplate";
public static final String REQ1 = "req1";
public static final String REQ2 = "req2";
+ public static final String SERVICE_FILTER_TOSCA_ID = "{get_input=inParam1}";
+ public static final String VMD_NAME = "vmdName";
+ public static final String DIRECTOR = "director";
private YamlUtil yamlUtil = new YamlUtil();
private ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
private static final String INTERFACE_ID = "inter_1";
@@ -436,10 +416,32 @@ public class ToscaModelTest {
Object req1 = nodeTemplateRequirements.get(REQ1);
Assert.assertEquals(true, req1 instanceof org.onap.sdc.tosca.datatypes.model.extension.RequirementAssignment);
Assert.assertNotNull(((org.onap.sdc.tosca.datatypes.model.extension.RequirementAssignment)req1).getService_filter());
+ List<Map<String, List<Constraint>>> properties =
+ ((org.onap.sdc.tosca.datatypes.model.extension.RequirementAssignment) req1).getService_filter()
+ .getProperties();
+ Assert.assertNotNull(properties);
+ List<Constraint> vmdNameConstrain = properties.get(0).get(VMD_NAME);
+ Assert.assertNotNull(vmdNameConstrain);
+ Assert.assertNotNull(vmdNameConstrain.get(0).getEqual());
+
+ List<Map<String, CapabilityFilter>> capabilities =
+ ((org.onap.sdc.tosca.datatypes.model.extension.RequirementAssignment) req1).getService_filter()
+ .getCapabilities();
+ Assert.assertNotNull(capabilities);
+ CapabilityFilter capabilityFilter = capabilities.get(0).get(DIRECTOR);
+ Assert.assertNotNull(capabilityFilter);
+ Assert.assertNotNull(capabilityFilter.getProperties());
+
Object req2 = nodeTemplateRequirements.get(REQ2);
Assert.assertEquals(true, req2 instanceof org.onap.sdc.tosca.datatypes.model.extension.RequirementAssignment);
Assert.assertNotNull(((org.onap.sdc.tosca.datatypes.model.extension.RequirementAssignment)req2).getService_filter());
+ Object tosca_id =
+ ((org.onap.sdc.tosca.datatypes.model.extension.RequirementAssignment) req2).getService_filter()
+ .getTosca_id();
+ Assert.assertNotNull(tosca_id);
+ Assert.assertEquals(SERVICE_FILTER_TOSCA_ID, tosca_id.toString());
+
String serviceTemplateYaml = toscaExtensionYamlUtil.objectToYaml(serviceTemplateWithServiceFilter);
Assert.assertNotNull(serviceTemplateYaml);
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithServiceFilter.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithServiceFilter.yaml
index e1a49a46c0..87a8fcd6b6 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithServiceFilter.yaml
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithServiceFilter.yaml
@@ -80,13 +80,20 @@ topology_template:
att2: '{ get_input: my_mysql_rootpw }'
att1: att1Val
requirements:
- - req1:
- service_filter:
- properties:
- - name : [{get_input : inParam1}]
- - req2:
- service_filter:
- tosca_id: {get_input : inParam1}
+ - req1:
+# capability: director
+ service_filter:
+ properties:
+ - vmdName: [{ equal : myName }]
+ - controllers: [{ equal : { get_input: controllers } }]
+ capabilities:
+ - director:
+ properties:
+ - url_path :
+ - { equal : { get_input: directorUrl } }
+ - req2:
+ service_filter:
+ tosca_id: {get_input : inParam1}
substitution_mappings:
node_type: myNodeType.node
capabilities: