From 035d670c792c9408493b3d729a3ac91124c2d4df Mon Sep 17 00:00:00 2001 From: JvD_Ericsson Date: Tue, 1 Aug 2023 09:28:12 +0100 Subject: Backend support for operation milestone filters Issue-ID: SDC-4590 Signed-off-by: JvD_Ericsson Change-Id: If291bd79871eee590c8826800127f543a6ba4b0c --- .../tosca/InterfacesOperationsConverterTest.java | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'catalog-be/src/test/java') 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 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> filters = (List>) milestone.get("filters"); + assertEquals(2, filters.size()); + Map filter1 = filters.get(0); + assertTrue(filter1.containsKey("my_attribute")); + Map filter1Constraint = (Map) filter1.get("my_attribute"); + assertTrue(filter1Constraint.containsKey(ConstraintType.EQUAL.getType())); + String filter1Value = (String) filter1Constraint.get(ConstraintType.EQUAL.getType()); + assertEquals("my_value", filter1Value); + Map filter2 = filters.get(1); + assertTrue(filter2.containsKey("my_other_attribute")); + Map filter2Constraint = (Map) filter2.get("my_other_attribute"); + assertTrue(filter2Constraint.containsKey(ConstraintType.EQUAL.getType())); + Map filter2Value = (Map) filter2Constraint.get(ConstraintType.EQUAL.getType()); + assertTrue(filter2Value.containsKey(ToscaGetFunctionType.GET_ATTRIBUTE.getFunctionName())); + List filter2ValueToscaFunction = (List) filter2Value.get(ToscaGetFunctionType.GET_ATTRIBUTE.getFunctionName()); + assertEquals(2, filter2ValueToscaFunction.size()); + assertEquals("SELF", filter2ValueToscaFunction.get(0)); + assertEquals("role", filter2ValueToscaFunction.get(1)); } private void addComplexTypeToDataTypes() { -- cgit 1.2.3-korg