summaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2023-02-17 13:05:37 +0000
committerJEFF VAN DAM <jeff.van.dam@est.tech>2023-02-22 13:33:18 +0000
commit3a7add7ec56db4a7c0d62e2c86150f9a216ad041 (patch)
tree0f1153e4ee940547e07be92f77c241b39a78efe6 /catalog-be/src
parent7b00f9af119e560d7974aab8aa405a6decbaa398 (diff)
Fix incorrect behaviour for list valid_values
Signed-off-by: MichaelMorris <michael.morris@est.tech> Issue-ID: SDC-4398 Change-Id: Ic8c8a6565089000d1517110283e4bb7c6f989c27
Diffstat (limited to 'catalog-be/src')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java10
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java4
2 files changed, 7 insertions, 7 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java
index b773f1fbbc..fff9f0bf1c 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java
@@ -271,13 +271,13 @@ public final class ImportUtils {
}
private static void setPropertyConstraints(Map<String, Object> propertyValue, PropertyDefinition property) {
- List<PropertyConstraint> constraints = getPropertyConstraints(propertyValue, property.getType());
+ List<PropertyConstraint> constraints = getPropertyConstraints(propertyValue, property.getType(), property.getSchema());
if (CollectionUtils.isNotEmpty(constraints)) {
property.setConstraints(constraints);
}
}
- private static List<PropertyConstraint> getPropertyConstraints(final Map<String, Object> propertyValue, final String propertyType) {
+ private static List<PropertyConstraint> getPropertyConstraints(final Map<String, Object> propertyValue, final String propertyType, final SchemaDefinition schema) {
final List<Object> propertyFieldConstraints = findCurrentLevelConstraintsElement(propertyValue);
if (CollectionUtils.isEmpty(propertyFieldConstraints)) {
return Collections.emptyList();
@@ -287,7 +287,7 @@ public final class ImportUtils {
}.getType();
final Gson gson = new GsonBuilder().registerTypeAdapter(constraintType, new PropertyConstraintDeserialiser()).create();
for (final Object constraintJson : propertyFieldConstraints) {
- final PropertyConstraint propertyConstraint = validateAndGetPropertyConstraint(propertyType, constraintType, gson, constraintJson);
+ final PropertyConstraint propertyConstraint = validateAndGetPropertyConstraint(propertyType, constraintType, gson, constraintJson, schema);
if (propertyConstraint != null) {
constraintList.add(propertyConstraint);
}
@@ -308,7 +308,7 @@ public final class ImportUtils {
return constraints;
}
- private static PropertyConstraint validateAndGetPropertyConstraint(String propertyType, Type constraintType, Gson gson, Object constraintJson) {
+ private static PropertyConstraint validateAndGetPropertyConstraint(String propertyType, Type constraintType, Gson gson, Object constraintJson, SchemaDefinition schema) {
PropertyConstraint propertyConstraint;
try {
propertyConstraint = gson.fromJson(gson.toJson(constraintJson), constraintType);
@@ -317,7 +317,7 @@ public final class ImportUtils {
}
if (propertyConstraint instanceof ValidValuesConstraint) {
try {
- ((ValidValuesConstraint) propertyConstraint).validateType(propertyType);
+ ((ValidValuesConstraint) propertyConstraint).validateType(propertyType, schema);
boolean valid = ((ValidValuesConstraint) propertyConstraint).validateValueType(propertyType);
if (!valid) {
((ValidValuesConstraint) propertyConstraint).changeConstraintValueTypeTo(propertyType);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java
index 6c820a1af2..966f13c952 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java
@@ -140,8 +140,8 @@ public class PropertyValueConstraintValidationUtil {
if (isPropertyNotMappedAsInput(propertyDefinition) && CollectionUtils.isNotEmpty(propertyDefinition.getConstraints())) {
for (PropertyConstraint propertyConstraint : propertyDefinition.getConstraints()) {
try {
- propertyConstraint.initialize(toscaType);
- propertyConstraint.validate(toscaType, propertyDefinition.getValue());
+ propertyConstraint.initialize(toscaType, propertyDefinition.getSchema());
+ propertyConstraint.validate(toscaType, propertyDefinition.getSchema(), propertyDefinition.getValue());
} catch (ConstraintValueDoNotMatchPropertyTypeException | ConstraintViolationException exception) {
errorMessages.add(propertyConstraint.getErrorMessage(toscaType, exception, getCompletePropertyName(propertyDefinition)));
} catch (IllegalArgumentException ie) {