From 6c9da5ab227fa535249e8bb56c7cef01a74c6fb1 Mon Sep 17 00:00:00 2001 From: franciscovila Date: Tue, 18 Apr 2023 15:08:07 +0100 Subject: VFC Property default value enforced forced to comply with restraints Issue-ID: SDC-4477 Signed-off-by: franciscovila Change-Id: Ib9115aae9019e2d36990147dc0ec9f4058352d88 --- .../sdc/be/model/tosca/constraints/AbstractPropertyConstraint.java | 2 +- .../org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtil.java | 2 +- .../org/openecomp/sdc/be/model/tosca/constraints/EqualConstraint.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'catalog-model/src') diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractPropertyConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractPropertyConstraint.java index 8e09648804..59510c4c89 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractPropertyConstraint.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractPropertyConstraint.java @@ -36,7 +36,7 @@ public abstract class AbstractPropertyConstraint implements PropertyConstraint { @Override public void validate(PropertyDefinition property) throws ConstraintViolationException { - validate(ToscaType.isValidType(property.getType()), property.getValue()); + validate(ToscaType.isValidType(property.getType()), property.getValue() != null ? property.getValue() : property.getDefaultValue()); } protected void validate(ToscaType toscaType, String propertyTextValue) throws ConstraintViolationException { diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtil.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtil.java index 83b3ab82d8..c356970d60 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtil.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtil.java @@ -81,7 +81,7 @@ public final class ConstraintUtil { * @throws ConstraintValueDoNotMatchPropertyTypeException if the property type cannot be compared */ public static void checkComparableType(final ToscaType propertyType) throws ConstraintValueDoNotMatchPropertyTypeException { - if (!isComparableType(propertyType)) { + if (!isComparableType(propertyType) && !ToscaType.BOOLEAN.equals(propertyType)) { throw new ConstraintValueDoNotMatchPropertyTypeException("Constraint is invalid for property type <" + propertyType.getType() + ">"); } } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/EqualConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/EqualConstraint.java index a565580d38..5e9e598475 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/EqualConstraint.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/EqualConstraint.java @@ -54,7 +54,7 @@ public class EqualConstraint extends AbstractComparablePropertyConstraint { public void initialize(ToscaType propertyType) throws ConstraintValueDoNotMatchPropertyTypeException { if (propertyType.isValidValue(String.valueOf(equal))) { typed = propertyType.convert(String.valueOf(equal)); - if (ConstraintUtil.isComparableType(propertyType)) { + if (ConstraintUtil.isComparableType(propertyType) || ToscaType.BOOLEAN.equals(propertyType)) { initialize(String.valueOf(equal), propertyType); } } else { -- cgit 1.2.3-korg