diff options
author | KrupaNagabhushan <krupa.nagabhushan@est.tech> | 2021-06-09 22:11:46 +0100 |
---|---|---|
committer | Christophe Closset <christophe.closset@intl.att.com> | 2021-07-05 09:19:53 +0000 |
commit | ffce2fdab1c5f6efff795107ef7756d2e9fdcf57 (patch) | |
tree | d795b99028569a927df824c7d97418d4c9d12628 /catalog-be/src/test | |
parent | 3453264c35275af52a2fdcde33f6e8347a65d15b (diff) |
Refactor Substitution filters structure
The refactor removes unnecessary component id from the substitution filters structure, as the substitution filters belongs to and only to the component.
This also avoid any copying issues during the new version creation, as there is not need to update the structure with a new component id.
Issue-ID: SDC-3619
Signed-off-by: KrupaNagabhushan <krupa.nagabhushan@est.tech>
Change-Id: Ibcfd9be0c8ceb95d5c1c3bd3f21c3dec26c398f7
Diffstat (limited to 'catalog-be/src/test')
-rw-r--r-- | catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/UiComponentDataConverterTest.java | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/UiComponentDataConverterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/UiComponentDataConverterTest.java index f163b51f66..9864cf456d 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/UiComponentDataConverterTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/UiComponentDataConverterTest.java @@ -19,7 +19,10 @@ package org.openecomp.sdc.be.datamodel; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; import static org.hibernate.validator.internal.util.CollectionHelper.asSet; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -43,6 +46,8 @@ import org.openecomp.sdc.be.components.utils.ServiceBuilder; import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter; import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition; import org.openecomp.sdc.be.datatypes.elements.GetPolicyValueDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.RequirementSubstitutionFilterPropertyDataDefinition; import org.openecomp.sdc.be.datatypes.elements.SubstitutionFilterDataDefinition; import org.openecomp.sdc.be.model.ComponentInstanceProperty; import org.openecomp.sdc.be.model.GroupDefinition; @@ -53,6 +58,7 @@ import org.openecomp.sdc.be.model.PolicyDefinition; import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; +import org.openecomp.sdc.be.ui.model.UIConstraint; import org.openecomp.sdc.be.ui.model.UiComponentDataTransfer; import org.openecomp.sdc.be.ui.model.UiComponentMetadata; import org.openecomp.sdc.be.ui.model.UiServiceDataTransfer; @@ -322,7 +328,7 @@ public class UiComponentDataConverterTest { UiComponentDataTransfer uiComponentDataTransfer = uiComponentDataConverter.getUiDataTransferFromResourceByParams(resource, Collections.singletonList("substitutionFilter")); - assertThat(uiComponentDataTransfer.getSubstitutionFilter()).isNull(); + assertThat(uiComponentDataTransfer.getSubstitutionFilters()).isNull(); } @Test @@ -330,13 +336,39 @@ public class UiComponentDataConverterTest { SubstitutionFilterDataDefinition substitutionFilter = new SubstitutionFilterDataDefinition(); substitutionFilter.setID(SUBSTITUTION_FILTER_UID); + final ListDataDefinition<RequirementSubstitutionFilterPropertyDataDefinition> expectedPropertyFilters = new ListDataDefinition<>(); + var filter1 = new RequirementSubstitutionFilterPropertyDataDefinition(); + filter1.setName("filter1"); + filter1.setConstraints(Collections.singletonList("constraint1: {equal: testvalue1}\n")); + expectedPropertyFilters.add(filter1); + + var filter2 = new RequirementSubstitutionFilterPropertyDataDefinition(); + filter2.setName("filter2"); + filter2.setConstraints(Collections.singletonList("constraint2: {equal: testvalue2}\n")); + expectedPropertyFilters.add(filter2); + + substitutionFilter.setProperties(expectedPropertyFilters); + Resource resource = new ResourceBuilder().build(); resource.setSubstitutionFilter(substitutionFilter); UiComponentDataTransfer uiComponentDataTransfer = uiComponentDataConverter.getUiDataTransferFromResourceByParams(resource, Collections.singletonList("substitutionFilter")); + assertThat(uiComponentDataTransfer.getSubstitutionFilters()).isNotNull(); + + List<UIConstraint> propertyFilters = uiComponentDataTransfer.getSubstitutionFilters().getProperties(); + assertFalse(propertyFilters.isEmpty()); + assertEquals(propertyFilters.size(), substitutionFilter.getProperties().getListToscaDataDefinition().size()); + + verifyPropertyFilters(propertyFilters.get(0), "constraint1", "testvalue1", "static", "equal"); + verifyPropertyFilters(propertyFilters.get(1), "constraint2", "testvalue2", "static", "equal"); + } - assertThat(uiComponentDataTransfer.getSubstitutionFilterForTopologyTemplate()).isNotEmpty(); + private void verifyPropertyFilters(UIConstraint uiConstraint, String propertyName, String value, String sourceType, String operator){ + assertEquals(propertyName, uiConstraint.getServicePropertyName()); + assertEquals(value, uiConstraint.getValue()); + assertEquals(sourceType, uiConstraint.getSourceType()); + assertEquals(operator, uiConstraint.getConstraintOperator()); } private Resource buildResourceWithGroups() { |