From 9f25403b73e8c66d0c0d9f3e8b05d8b5069bb783 Mon Sep 17 00:00:00 2001 From: MichaelMorris Date: Thu, 5 May 2022 23:18:00 +0100 Subject: Fix property validation for data type in model Signed-off-by: MichaelMorris Issue-ID: SDC-3990 Change-Id: I702960519cd9ef6ff7a905d837de7ca5b8f29599 --- .../org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java | 2 +- .../openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java | 8 ++++---- .../sdc/be/components/impl/ResourceBusinessLogicTest.java | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'catalog-be') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java index 8a003623c4..4268d91dc9 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java @@ -423,7 +423,7 @@ public abstract class BaseBusinessLogic { Either validatePropertyDefaultValue(IComplexDefaultValue property, Map dataTypes) { String type; String innerType = null; - if (!propertyOperation.isPropertyTypeValid(property, null)) { + if (!propertyOperation.isPropertyTypeValid(property, dataTypes)) { log.info("Invalid type for property '{}' type '{}'", property.getName(), property.getType()); ResponseFormat responseFormat = componentsUtils .getResponseFormat(ActionStatus.INVALID_PROPERTY_TYPE, property.getType(), property.getName()); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java index bd3e9ae633..fd057607a1 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java @@ -468,7 +468,7 @@ public class InputsBusinessLogicTest { // for BaseOperation.getAllDataTypes: when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>())); // don't use Collections.emptyMap // for BaseOperation.validatePropertyDefaultValue: - when(propertyOperation.isPropertyTypeValid(any(), any())).thenReturn(true); + when(propertyOperation.isPropertyTypeValid(any(), anyMap())).thenReturn(true); when(propertyOperation.isPropertyInnerTypeValid(any(),any())).thenReturn(new ImmutablePair<>(listInput.getSchemaType(), true)); when(propertyOperation.isPropertyDefaultValueValid(any(), any())).thenReturn(true); // for createListInputsInGraph: @@ -566,12 +566,12 @@ public class InputsBusinessLogicTest { when(propertyDeclarationOrchestrator.getPropOwnerId(componentInstInputsMap)).thenReturn(COMPONENT_INSTANCE_ID); when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>())); // don't use Collections.emptyMap // for BaseOperation.validatePropertyDefaultValue: - when(propertyOperation.isPropertyTypeValid(any(), any())).thenReturn(false); + when(propertyOperation.isPropertyTypeValid(any(), anyMap())).thenReturn(false); Either, ResponseFormat> result = testInstance.createListInput(USER_ID, COMPONENT_ID, ComponentTypeEnum.SERVICE, createListInputParams, true, false); assertThat(result.isRight()).isTrue(); - verify(propertyOperation, times(1)).isPropertyTypeValid(any(), any()); + verify(propertyOperation, times(1)).isPropertyTypeValid(any(), anyMap()); } @Test @@ -586,7 +586,7 @@ public class InputsBusinessLogicTest { when(propertyDeclarationOrchestrator.getPropOwnerId(componentInstInputsMap)).thenReturn(COMPONENT_INSTANCE_ID); when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>())); // don't use Collections.emptyMap // for BaseOperation.validatePropertyDefaultValue: - when(propertyOperation.isPropertyTypeValid(any(), any())).thenReturn(true); + when(propertyOperation.isPropertyTypeValid(any(), anyMap())).thenReturn(true); when(propertyOperation.isPropertyInnerTypeValid(any(),any())).thenReturn(new ImmutablePair<>(listInput.getSchemaType(), true)); when(propertyOperation.isPropertyDefaultValueValid(any(), any())).thenReturn(true); when(toscaOperationFacadeMock.addInputsToComponent(anyMap(), eq(COMPONENT_ID))).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND)); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java index 20e2114815..d133e081a2 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java @@ -1945,7 +1945,7 @@ public class ResourceBusinessLogicTest { List properties = new ArrayList<>(); properties.add(property); basic.setProperties(properties); - when(propertyOperation.isPropertyTypeValid(property, null)).thenReturn(true); + when(propertyOperation.isPropertyTypeValid(property, (String)null)).thenReturn(true); when(propertyOperation.isPropertyDefaultValueValid(property, emptyDataTypes)).thenReturn(true); Boolean validatePropertiesDefaultValues = bl.validatePropertiesDefaultValues(basic); assertTrue(validatePropertiesDefaultValues); -- cgit 1.2.3-korg