From 55e8600f2f70f051f7bd897cd4926e258980ba07 Mon Sep 17 00:00:00 2001 From: siddharth0905 Date: Thu, 11 Apr 2019 15:38:15 +0530 Subject: Apply Valid Value Constraints validation Service consumption scenario fix Change-Id: I5ad7beb18b0490385d24ce30b750ca5c2ebb28a8 Issue-ID: SDC-2224 Signed-off-by: siddharth0905 --- .../be/components/impl/ServiceBusinessLogic.java | 33 ++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'catalog-be/src') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java index 364b007ce3..83d6730534 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java @@ -669,19 +669,30 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic { private Either validateOperationInputConstraint( OperationInputDefinition operationInputDefinition, String value, String type) { - ComponentInstanceProperty propertyDefinition = new ComponentInstanceProperty(); - propertyDefinition.setType(operationInputDefinition.getParentPropertyType()); - - InputDefinition inputDefinition = new InputDefinition(); - inputDefinition.setDefaultValue(value); - inputDefinition.setInputPath(operationInputDefinition.getSubPropertyInputPath()); - inputDefinition.setType(type); - if (Objects.nonNull(operationInputDefinition.getParentPropertyType())) { + + if (Objects.nonNull(operationInputDefinition.getParentPropertyType()) + && !operationInputDefinition.getParentPropertyType().equals(operationInputDefinition.getType())) { + InputDefinition inputDefinition = new InputDefinition(); + inputDefinition.setDefaultValue(value); + inputDefinition.setInputPath(operationInputDefinition.getSubPropertyInputPath()); + inputDefinition.setName(operationInputDefinition.getName()); + inputDefinition.setType(type); + + ComponentInstanceProperty propertyDefinition = new ComponentInstanceProperty(); + propertyDefinition.setType(operationInputDefinition.getParentPropertyType()); inputDefinition.setProperties(Collections.singletonList(propertyDefinition)); - } - return PropertyValueConstraintValidationUtil.getInstance() - .validatePropertyConstraints(Collections.singletonList(inputDefinition), applicationDataTypeCache); + return PropertyValueConstraintValidationUtil.getInstance() + .validatePropertyConstraints(Collections.singletonList(inputDefinition), applicationDataTypeCache); + } else { + PropertyDefinition propertyDefinition = new PropertyDefinition(); + propertyDefinition.setType(operationInputDefinition.getType()); + propertyDefinition.setValue(value); + propertyDefinition.setName(operationInputDefinition.getName()); + + return PropertyValueConstraintValidationUtil.getInstance() + .validatePropertyConstraints(Collections.singletonList(propertyDefinition), applicationDataTypeCache); + } } private void addStaticValueToInputOperation(String value, Operation operation, -- cgit 1.2.3-korg