diff options
author | JvD_Ericsson <jeff.van.dam@est.tech> | 2023-08-01 09:28:12 +0100 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2023-09-22 07:43:25 +0000 |
commit | 035d670c792c9408493b3d729a3ac91124c2d4df (patch) | |
tree | 0437db7e9b647546799236c39b026d538e5e1c60 /catalog-be/src/test/java | |
parent | 27633293d6d45521ea985019ea7b99c2009b62c7 (diff) |
Backend support for operation milestone filters
Issue-ID: SDC-4590
Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech>
Change-Id: If291bd79871eee590c8826800127f543a6ba4b0c
Diffstat (limited to 'catalog-be/src/test/java')
-rw-r--r-- | catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverterTest.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverterTest.java index 974d321c62..7e4b4c28e2 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverterTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverterTest.java @@ -44,6 +44,7 @@ import org.junit.jupiter.api.Test; import org.openecomp.sdc.be.DummyConfigurationManager; import org.openecomp.sdc.be.datatypes.elements.ActivityDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.FilterDataDefinition; import org.openecomp.sdc.be.datatypes.elements.InputDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition; import org.openecomp.sdc.be.datatypes.elements.MilestoneDataDefinition; @@ -53,9 +54,13 @@ import org.openecomp.sdc.be.datatypes.elements.OperationOutputDefinition; import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition; import org.openecomp.sdc.be.datatypes.elements.ToscaFunctionType; +import org.openecomp.sdc.be.datatypes.elements.ToscaGetFunctionDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ActivityTypeEnum; +import org.openecomp.sdc.be.datatypes.enums.ConstraintType; import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; import org.openecomp.sdc.be.datatypes.enums.MilestoneTypeEnum; +import org.openecomp.sdc.be.datatypes.enums.PropertySource; +import org.openecomp.sdc.be.datatypes.tosca.ToscaGetFunctionType; import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.DataTypeDefinition; import org.openecomp.sdc.be.model.InputDefinition; @@ -443,6 +448,25 @@ class InterfacesOperationsConverterTest { activities.add(activity); MilestoneDataDefinition milestone = new MilestoneDataDefinition(); milestone.setActivities(activities); + FilterDataDefinition filter1 = new FilterDataDefinition(); + filter1.setName("my_attribute"); + filter1.setConstraint("equal"); + filter1.setFilterValue("my_value"); + FilterDataDefinition filter2 = new FilterDataDefinition(); + ToscaGetFunctionDataDefinition toscaFunction = new ToscaGetFunctionDataDefinition(); + toscaFunction.setFunctionType(ToscaGetFunctionType.GET_ATTRIBUTE); + toscaFunction.setPropertyName("role"); + toscaFunction.setPropertySource(PropertySource.SELF); + toscaFunction.setSourceName("myVfc"); + toscaFunction.setPropertyPathFromSource(Arrays.asList("role")); + filter2.setToscaFunction(toscaFunction); + filter2.setName("my_other_attribute"); + filter2.setConstraint("equal"); + filter2.setFilterValue("{'get_attribute':['SELF','role']}"); + ListDataDefinition<FilterDataDefinition> filters = new ListDataDefinition<>(); + filters.add(filter1); + filters.add(filter2); + milestone.setFilters(filters); toscaMilestones.put(MilestoneTypeEnum.ON_ENTRY.getValue(), milestone); return toscaMilestones; } @@ -672,6 +696,25 @@ class InterfacesOperationsConverterTest { assertTrue(complexInputStringProp.containsKey("propertySource")); assertEquals("SELF", complexInputStringProp.get("propertySource")); + assertTrue(milestone.containsKey("filters")); + List<Map<String, Object>> filters = (List<Map<String, Object>>) milestone.get("filters"); + assertEquals(2, filters.size()); + Map<String, Object> filter1 = filters.get(0); + assertTrue(filter1.containsKey("my_attribute")); + Map<String, Object> filter1Constraint = (Map<String, Object>) filter1.get("my_attribute"); + assertTrue(filter1Constraint.containsKey(ConstraintType.EQUAL.getType())); + String filter1Value = (String) filter1Constraint.get(ConstraintType.EQUAL.getType()); + assertEquals("my_value", filter1Value); + Map<String, Object> filter2 = filters.get(1); + assertTrue(filter2.containsKey("my_other_attribute")); + Map<String, Object> filter2Constraint = (Map<String, Object>) filter2.get("my_other_attribute"); + assertTrue(filter2Constraint.containsKey(ConstraintType.EQUAL.getType())); + Map<String, Object> filter2Value = (Map<String, Object>) filter2Constraint.get(ConstraintType.EQUAL.getType()); + assertTrue(filter2Value.containsKey(ToscaGetFunctionType.GET_ATTRIBUTE.getFunctionName())); + List<String> filter2ValueToscaFunction = (List<String>) filter2Value.get(ToscaGetFunctionType.GET_ATTRIBUTE.getFunctionName()); + assertEquals(2, filter2ValueToscaFunction.size()); + assertEquals("SELF", filter2ValueToscaFunction.get(0)); + assertEquals("role", filter2ValueToscaFunction.get(1)); } private void addComplexTypeToDataTypes() { |