summaryrefslogtreecommitdiffstats
path: root/catalog-model/src
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2022-12-23 16:56:21 +0000
committerMichael Morris <michael.morris@est.tech>2023-01-03 14:19:17 +0000
commita81c40773b3c819f079bd741d472ee954572cb34 (patch)
tree24626c3affd27f8c03473275ddf89baa2ae3af60 /catalog-model/src
parent4871b522afd7dfee773dc891cb94d3f1eaafb040 (diff)
Fix 'NPE thrown in editing constraints'-bug
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Change-Id: Ibbd8a3baa2a2bfdbd6e2c235db5a1d59875f3e6e Issue-ID: SDC-4312
Diffstat (limited to 'catalog-model/src')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java77
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractComparablePropertyConstraint.java2
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/EqualConstraint.java43
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterOrEqualConstraint.java6
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterThanConstraint.java6
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraint.java45
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessOrEqualConstraint.java6
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessThanConstraint.java6
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraintTest.java54
9 files changed, 82 insertions, 163 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java
index 97f9874301..d68a7706b6 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java
@@ -19,12 +19,14 @@
*/
package org.openecomp.sdc.be.model.operations.impl;
+import static org.openecomp.sdc.be.model.tosca.constraints.ConstraintUtil.convertToComparable;
import static org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
@@ -91,6 +93,7 @@ import org.openecomp.sdc.be.model.operations.api.DerivedFromOperation;
import org.openecomp.sdc.be.model.operations.api.IPropertyOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
+import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.model.tosca.constraints.EqualConstraint;
import org.openecomp.sdc.be.model.tosca.constraints.GreaterOrEqualConstraint;
import org.openecomp.sdc.be.model.tosca.constraints.GreaterThanConstraint;
@@ -2139,8 +2142,8 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
JsonArray jsonArray = new JsonArray();
if (src instanceof InRangeConstraint) {
InRangeConstraint rangeConstraint = (InRangeConstraint) src;
- jsonArray.add(JsonParser.parseString(String.valueOf(rangeConstraint.getRangeMinValue())));
- jsonArray.add(JsonParser.parseString(String.valueOf(rangeConstraint.getRangeMaxValue())));
+ jsonArray.add(JsonParser.parseString(String.valueOf(rangeConstraint.getMin())));
+ jsonArray.add(JsonParser.parseString(String.valueOf(rangeConstraint.getMax())));
result.add("inRange", jsonArray);
} else if (src instanceof GreaterThanConstraint) {
GreaterThanConstraint greaterThanConstraint = (GreaterThanConstraint) src;
@@ -2163,8 +2166,6 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
public static class PropertyConstraintDeserialiser implements JsonDeserializer<PropertyConstraint> {
- private static final String THE_VALUE_OF_GREATER_THAN_CONSTRAINT_IS_NULL = "The value of GreaterThanConstraint is null";
-
@Override
public PropertyConstraint deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
PropertyConstraint propertyConstraint = null;
@@ -2184,45 +2185,40 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
if (typedValue != null) {
log.debug("Before adding value to EqualConstraint object. value = {}", typedValue);
propertyConstraint = new EqualConstraint(typedValue);
- break;
} else {
- log.warn("The value of equal constraint is null");
+ log.warn("The value of EqualConstraint is null");
}
break;
case IN_RANGE:
- if (typedValue != null) {
- if (typedValue instanceof ArrayList) {
- ArrayList rangeArray = (ArrayList) typedValue;
- if (rangeArray.size() != 2 || rangeArray.contains("")) {
- log.error("The range constraint content is invalid. value = {}", typedValue);
- throw new JsonSyntaxException("The range constraint content is invalid");
- } else {
- InRangeConstraint rangeConstraint = new InRangeConstraint();
- Object minValue = rangeArray.get(0);
- Object maxValue = rangeArray.get(1);
- rangeConstraint.setRangeMinValue(minValue);
- rangeConstraint.setRangeMaxValue(maxValue);
- propertyConstraint = rangeConstraint;
- }
+ if (typedValue instanceof ArrayList) {
+ List<Object> rangeArray = (ArrayList<Object>) typedValue;
+ if (rangeArray.size() != 2 || rangeArray.contains("")) {
+ log.error("The range constraint content is invalid. value = {}", typedValue);
+ throw new JsonSyntaxException("The range constraint content is invalid");
+ } else {
+ Object minValue = rangeArray.get(0);
+ Object maxValue = rangeArray.get(1);
+ InRangeConstraint rangeConstraint = new InRangeConstraint(Lists.newArrayList(minValue, maxValue));
+ rangeConstraint.setMin(convertToComparable(ToscaType.RANGE, String.valueOf(minValue)));
+ rangeConstraint.setMax(convertToComparable(ToscaType.RANGE, String.valueOf(maxValue)));
+ propertyConstraint = rangeConstraint;
}
} else {
- log.warn(THE_VALUE_OF_GREATER_THAN_CONSTRAINT_IS_NULL);
+ log.warn("The value of InRangeConstraint is null");
}
break;
case GREATER_THAN:
if (typedValue != null) {
log.debug("Before adding value to GreaterThanConstraint object. value = {}", typedValue);
propertyConstraint = new GreaterThanConstraint(typedValue);
- break;
} else {
- log.warn(THE_VALUE_OF_GREATER_THAN_CONSTRAINT_IS_NULL);
+ log.warn("The value of GreaterThanConstraint is null");
}
break;
case LESS_THAN:
if (typedValue != null) {
log.debug("Before adding value to LessThanConstraint object. value = {}", typedValue);
propertyConstraint = new LessThanConstraint(typedValue);
- break;
} else {
log.warn("The value of LessThanConstraint is null");
}
@@ -2231,7 +2227,6 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
if (typedValue != null) {
log.debug("Before adding value to GreaterThanConstraint object. value = {}", typedValue);
propertyConstraint = new GreaterOrEqualConstraint(typedValue);
- break;
} else {
log.warn("The value of GreaterOrEqualConstraint is null");
}
@@ -2241,12 +2236,12 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
log.debug("Before adding value to LessOrEqualConstraint object. value = {}", typedValue);
propertyConstraint = new LessOrEqualConstraint(typedValue);
} else {
- log.warn(THE_VALUE_OF_GREATER_THAN_CONSTRAINT_IS_NULL);
+ log.warn("The value of LessOrEqualConstraint is null");
}
break;
case VALID_VALUES:
- if (typedValue != null) {
- ArrayList validValuesArray = (ArrayList) typedValue;
+ if (typedValue instanceof ArrayList) {
+ List<Object> validValuesArray = (ArrayList<Object>) typedValue;
if (validValuesArray.size() == 0 || validValuesArray.contains("")) {
log.error("The valid values constraint content is invalid. value = {}", typedValue);
throw new JsonSyntaxException("The valid values constraint content is invalid");
@@ -2255,6 +2250,8 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
vvConstraint.setValidValues(validValuesArray);
propertyConstraint = vvConstraint;
}
+ } else {
+ log.warn("The value of ValidValuesConstraint is null");
}
break;
case LENGTH:
@@ -2262,9 +2259,8 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
int asInt = value.getAsInt();
log.debug("Before adding value to length constraint. value = {}", asInt);
propertyConstraint = new LengthConstraint(asInt);
- break;
} else {
- log.warn("The value of length constraint is null");
+ log.warn("The value of LengthConstraint is null");
}
break;
case MIN_LENGTH:
@@ -2272,7 +2268,6 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
int asInt = value.getAsInt();
log.debug("Before adding value to Min Length object. value = {}", asInt);
propertyConstraint = new MinLengthConstraint(asInt);
- break;
} else {
log.warn("The value of MinLengthConstraint is null");
}
@@ -2282,9 +2277,8 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
int asInt = value.getAsInt();
log.debug("Before adding value to max length constraint. value = {}", asInt);
propertyConstraint = new MaxLengthConstraint(asInt);
- break;
} else {
- log.warn("The value of max length constraint is null");
+ log.warn("The value of MaxLengthConstraint is null");
}
break;
case PATTERN:
@@ -2292,9 +2286,8 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
String asString = value.getAsString();
log.debug("Before adding value to PatternConstraint object. value = {}", asString);
propertyConstraint = new PatternConstraint(asString);
- break;
} else {
- log.warn("The value of pattern constraint is null");
+ log.warn("The value of PatternConstraint is null");
}
break;
default:
@@ -2448,17 +2441,11 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
if (rangeArray.size() != 2) {
log.error("The range constraint content is invalid. value = {}", value);
} else {
- InRangeConstraint rangeConstraint = new InRangeConstraint();
String minValue = rangeArray.get(0).asText();
- String maxValue;
- JsonNode maxElement = rangeArray.get(1);
- if (maxElement.isNull()) {
- maxValue = null;
- } else {
- maxValue = maxElement.asText();
- }
- rangeConstraint.setRangeMinValue(minValue);
- rangeConstraint.setRangeMaxValue(maxValue);
+ String maxValue = rangeArray.get(1).asText();
+ InRangeConstraint rangeConstraint = new InRangeConstraint(Lists.newArrayList(minValue, maxValue));
+ rangeConstraint.setMin(convertToComparable(ToscaType.RANGE, minValue));
+ rangeConstraint.setMax(convertToComparable(ToscaType.RANGE, maxValue));
return rangeConstraint;
}
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractComparablePropertyConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractComparablePropertyConstraint.java
index d7eb6e69c6..4a8c742de9 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractComparablePropertyConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractComparablePropertyConstraint.java
@@ -50,8 +50,6 @@ public abstract class AbstractComparablePropertyConstraint extends AbstractPrope
public abstract boolean validateValueType(String propertyType) throws ConstraintValueDoNotMatchPropertyTypeException;
- public abstract String getConstraintValueAsString();
-
public abstract void changeConstraintValueTypeTo(String propertyType) throws ConstraintValueDoNotMatchPropertyTypeException;
@Override
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 f5a9f847ff..e1c55ac829 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
@@ -19,10 +19,9 @@
*/
package org.openecomp.sdc.be.model.tosca.constraints;
-import java.io.Serializable;
import javax.validation.constraints.NotNull;
-import lombok.Setter;
import lombok.Getter;
+import lombok.Setter;
import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
import org.openecomp.sdc.be.model.PropertyConstraint;
import org.openecomp.sdc.be.model.tosca.ToscaType;
@@ -32,7 +31,7 @@ import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintViolatio
import org.openecomp.sdc.be.model.tosca.constraints.exception.PropertyConstraintException;
@SuppressWarnings("serial")
-public class EqualConstraint extends AbstractPropertyConstraint implements Serializable {
+public class EqualConstraint extends AbstractComparablePropertyConstraint {
@Getter
@Setter
@@ -49,6 +48,7 @@ public class EqualConstraint extends AbstractPropertyConstraint implements Seria
public void initialize(ToscaType propertyType) throws ConstraintValueDoNotMatchPropertyTypeException {
if (propertyType.isValidValue(String.valueOf(equal))) {
typed = propertyType.convert(String.valueOf(equal));
+ initialize(String.valueOf(equal), propertyType);
} else {
throw new ConstraintValueDoNotMatchPropertyTypeException(
"constraintValue constraint has invalid value <" + equal + "> property type is <" + propertyType.toString() + ">");
@@ -56,19 +56,6 @@ public class EqualConstraint extends AbstractPropertyConstraint implements Seria
}
@Override
- public void validate(Object propertyValue) throws ConstraintViolationException {
- if (propertyValue == null) {
- if (typed != null) {
- fail(null);
- }
- } else if (typed == null) {
- fail(propertyValue);
- } else if (!typed.equals(propertyValue)) {
- fail(propertyValue);
- }
- }
-
- @Override
public ConstraintType getConstraintType() {
return ConstraintType.EQUAL;
}
@@ -87,15 +74,33 @@ public class EqualConstraint extends AbstractPropertyConstraint implements Seria
return getErrorMessage(toscaType, e, propertyName, "%s property value must be %s", String.valueOf(equal));
}
+ @Override
+ protected void doValidate(Object propertyValue) throws ConstraintViolationException {
+ if (propertyValue == null) {
+ if (typed != null) {
+ fail(null);
+ }
+ } else if (typed == null) {
+ fail(propertyValue);
+ } else if (!typed.equals(propertyValue)) {
+ fail(propertyValue);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(equal);
+ }
+
public boolean validateValueType(String propertyType) throws ConstraintValueDoNotMatchPropertyTypeException {
ToscaType toscaType = ToscaType.getToscaType(propertyType);
if (toscaType == null) {
throw new ConstraintValueDoNotMatchPropertyTypeException(
- "equal constraint has invalid values <" + equal.toString() + "> property type is <" + propertyType + ">");
+ "equal constraint has invalid values <" + equal.toString() + "> property type is <" + propertyType + ">");
}
if (equal == null) {
throw new ConstraintValueDoNotMatchPropertyTypeException(
- "equal constraint has invalid value <> property type is <" + propertyType + ">");
+ "equal constraint has invalid value <> property type is <" + propertyType + ">");
}
return toscaType.isValueTypeValid(equal);
}
@@ -106,7 +111,7 @@ public class EqualConstraint extends AbstractPropertyConstraint implements Seria
equal = toscaType.convert(String.valueOf(equal));
} catch (Exception e) {
throw new ConstraintValueDoNotMatchPropertyTypeException(
- "equal constraint has invalid values <" + equal.toString() + "> property type is <" + propertyType + ">");
+ "equal constraint has invalid values <" + equal.toString() + "> property type is <" + propertyType + ">");
}
}
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterOrEqualConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterOrEqualConstraint.java
index b45cf9791e..e90f1c0bf2 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterOrEqualConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterOrEqualConstraint.java
@@ -70,17 +70,17 @@ public class GreaterOrEqualConstraint extends AbstractComparablePropertyConstrai
ToscaType toscaType = ToscaType.getToscaType(propertyType);
if (toscaType == null) {
throw new ConstraintValueDoNotMatchPropertyTypeException(
- "greaterOrEqual constraint has invalid values <" + greaterOrEqual.toString() + "> property type is <" + propertyType + ">");
+ "greaterOrEqual constraint has invalid values <" + greaterOrEqual.toString() + "> property type is <" + propertyType + ">");
}
if (greaterOrEqual == null) {
throw new ConstraintValueDoNotMatchPropertyTypeException(
- "greaterOrEqual constraint has invalid value <> property type is <" + propertyType + ">");
+ "greaterOrEqual constraint has invalid value <> property type is <" + propertyType + ">");
}
return toscaType.isValueTypeValid(greaterOrEqual);
}
@Override
- public String getConstraintValueAsString() {
+ public String toString() {
return String.valueOf(greaterOrEqual);
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterThanConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterThanConstraint.java
index 9d638cfb3f..e1293d1bb1 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterThanConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterThanConstraint.java
@@ -70,17 +70,17 @@ public class GreaterThanConstraint<T> extends AbstractComparablePropertyConstrai
ToscaType toscaType = ToscaType.getToscaType(propertyType);
if (toscaType == null) {
throw new ConstraintValueDoNotMatchPropertyTypeException(
- "greaterThan constraint has invalid values <" + greaterThan.toString() + "> property type is <" + propertyType + ">");
+ "greaterThan constraint has invalid values <" + greaterThan.toString() + "> property type is <" + propertyType + ">");
}
if (greaterThan == null) {
throw new ConstraintValueDoNotMatchPropertyTypeException(
- "greaterThan constraint has invalid value <> property type is <" + propertyType + ">");
+ "greaterThan constraint has invalid value <> property type is <" + propertyType + ">");
}
return toscaType.isValueTypeValid(greaterThan);
}
@Override
- public String getConstraintValueAsString() {
+ public String toString() {
return String.valueOf(greaterThan);
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraint.java
index 2567cec772..26d75bd134 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraint.java
@@ -19,9 +19,8 @@
*/
package org.openecomp.sdc.be.model.tosca.constraints;
-import com.google.common.collect.Lists;
+import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.List;
-import javax.validation.constraints.NotNull;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
@@ -41,7 +40,9 @@ public class InRangeConstraint extends AbstractPropertyConstraint {
@NonNull
private List<Object> inRange;
+ @JsonIgnore
private Comparable min;
+ @JsonIgnore
private Comparable max;
public InRangeConstraint(List<Object> inRange) {
@@ -50,9 +51,7 @@ public class InRangeConstraint extends AbstractPropertyConstraint {
@Override
public void initialize(ToscaType propertyType) throws ConstraintValueDoNotMatchPropertyTypeException {
- // Perform verification that the property type is supported for
-
- // comparison
+ // Perform verification that the property type is supported for comparison
ConstraintUtil.checkComparableType(propertyType);
if (inRange == null || inRange.size() != 2) {
throw new ConstraintValueDoNotMatchPropertyTypeException("In range constraint must have two elements.");
@@ -94,40 +93,6 @@ public class InRangeConstraint extends AbstractPropertyConstraint {
public void validateValueOnUpdate(PropertyConstraint newConstraint) throws PropertyConstraintException {
}
- @NotNull
- public Object getRangeMinValue() {
- if (inRange != null) {
- return inRange.get(0);
- } else {
- return null;
- }
- }
-
- public void setRangeMinValue(Object minValue) {
- if (inRange == null) {
- inRange = Lists.newArrayList(minValue, null);
- } else {
- inRange.set(0, minValue);
- }
- }
-
- @NotNull
- public Object getRangeMaxValue() {
- if (inRange != null) {
- return inRange.get(1);
- } else {
- return null;
- }
- }
-
- public void setRangeMaxValue(Object maxValue) {
- if (inRange == null) {
- inRange = Lists.newArrayList(null, maxValue);
- } else {
- inRange.set(1, maxValue);
- }
- }
-
@Override
public String getErrorMessage(ToscaType toscaType, ConstraintFunctionalException e, String propertyName) {
return getErrorMessage(toscaType, e, propertyName, "%s property value must be in a range of %s", String.valueOf(min),
@@ -158,7 +123,7 @@ public class InRangeConstraint extends AbstractPropertyConstraint {
inRange.replaceAll(obj -> toscaType.convert(String.valueOf(obj)));
} catch (Exception e) {
throw new ConstraintValueDoNotMatchPropertyTypeException(
- "inRange constraint has invalid values <" + inRange + "> property type is <" + propertyType + ">");
+ "inRange constraint has invalid values <" + inRange + "> property type is <" + propertyType + ">");
}
}
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessOrEqualConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessOrEqualConstraint.java
index 0f64a4f9f5..3830ddf811 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessOrEqualConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessOrEqualConstraint.java
@@ -70,17 +70,17 @@ public class LessOrEqualConstraint<T> extends AbstractComparablePropertyConstrai
ToscaType toscaType = ToscaType.getToscaType(propertyType);
if (toscaType == null) {
throw new ConstraintValueDoNotMatchPropertyTypeException(
- "lessOrEqual constraint has invalid values <" + lessOrEqual.toString() + "> property type is <" + propertyType + ">");
+ "lessOrEqual constraint has invalid values <" + lessOrEqual.toString() + "> property type is <" + propertyType + ">");
}
if (lessOrEqual == null) {
throw new ConstraintValueDoNotMatchPropertyTypeException(
- "lessOrEqual constraint has invalid value <> property type is <" + propertyType + ">");
+ "lessOrEqual constraint has invalid value <> property type is <" + propertyType + ">");
}
return toscaType.isValueTypeValid(lessOrEqual);
}
@Override
- public String getConstraintValueAsString() {
+ public String toString() {
return String.valueOf(lessOrEqual);
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessThanConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessThanConstraint.java
index 92ab9278b2..f3e283c98e 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessThanConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessThanConstraint.java
@@ -70,17 +70,17 @@ public class LessThanConstraint extends AbstractComparablePropertyConstraint {
ToscaType toscaType = ToscaType.getToscaType(propertyType);
if (toscaType == null) {
throw new ConstraintValueDoNotMatchPropertyTypeException(
- "lessThan constraint has invalid values <" + lessThan.toString() + "> property type is <" + propertyType + ">");
+ "lessThan constraint has invalid values <" + lessThan.toString() + "> property type is <" + propertyType + ">");
}
if (lessThan == null) {
throw new ConstraintValueDoNotMatchPropertyTypeException(
- "lessThan constraint has invalid value <> property type is <" + propertyType + ">");
+ "lessThan constraint has invalid value <> property type is <" + propertyType + ">");
}
return toscaType.isValueTypeValid(lessThan);
}
@Override
- public String getConstraintValueAsString() {
+ public String toString() {
return String.valueOf(lessThan);
}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraintTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraintTest.java
index 8eff6f7cdc..1491e0547d 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraintTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraintTest.java
@@ -30,7 +30,7 @@ import java.util.List;
import org.junit.jupiter.api.Test;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintValueDoNotMatchPropertyTypeException;
-public class InRangeConstraintTest {
+class InRangeConstraintTest {
private InRangeConstraint createStringTestSubject() {
List<Object> validValues = new ArrayList<>();
@@ -47,7 +47,7 @@ public class InRangeConstraintTest {
}
@Test
- public void testGetInRange() {
+ void testGetInRange() {
InRangeConstraint testSubject = createStringTestSubject();
List<Object> result = testSubject.getInRange();
@@ -57,7 +57,7 @@ public class InRangeConstraintTest {
}
@Test
- public void testSetInRange() {
+ void testSetInRange() {
InRangeConstraint testSubject = createStringTestSubject();
List<Object> validValues = new ArrayList<>();
validValues.add("test21");
@@ -71,43 +71,7 @@ public class InRangeConstraintTest {
}
@Test
- public void testGetRangeMinValue() throws Exception {
- InRangeConstraint testSubject = createIntegerTestSubject();
- Object result = testSubject.getRangeMinValue();
-
- assertEquals(1, result);
- }
-
- @Test
- public void testSetRangeMinValue() throws Exception {
- InRangeConstraint testSubject = createIntegerTestSubject();
- testSubject.setRangeMinValue(21);
-
- Object result = testSubject.getRangeMinValue();
-
- assertEquals(21, result);
- }
-
- @Test
- public void testGetRangeMaxValue() throws Exception {
- InRangeConstraint testSubject = createIntegerTestSubject();
- Object result = testSubject.getRangeMaxValue();
-
- assertEquals(10, result);
- }
-
- @Test
- public void testSetRangeMaxValue() throws Exception {
- InRangeConstraint testSubject = createIntegerTestSubject();
- testSubject.setRangeMaxValue(30);
-
- Object result = testSubject.getRangeMaxValue();
-
- assertEquals(30, result);
- }
-
- @Test
- public void testValidateValueTypeStringTrue() throws ConstraintValueDoNotMatchPropertyTypeException {
+ void testValidateValueTypeStringTrue() throws ConstraintValueDoNotMatchPropertyTypeException {
InRangeConstraint testSubject = createStringTestSubject();
Boolean validTypes = testSubject.validateValueType("string");
@@ -115,7 +79,7 @@ public class InRangeConstraintTest {
}
@Test
- public void testValidateValueTypeStringFalse() throws ConstraintValueDoNotMatchPropertyTypeException {
+ void testValidateValueTypeStringFalse() throws ConstraintValueDoNotMatchPropertyTypeException {
InRangeConstraint testSubject = createStringTestSubject();
Boolean validTypes = testSubject.validateValueType("integer");
@@ -123,7 +87,7 @@ public class InRangeConstraintTest {
}
@Test
- public void testValidateValueTypeIntegerTrue() throws ConstraintValueDoNotMatchPropertyTypeException {
+ void testValidateValueTypeIntegerTrue() throws ConstraintValueDoNotMatchPropertyTypeException {
InRangeConstraint testSubject = createIntegerTestSubject();
Boolean validTypes = testSubject.validateValueType("integer");
@@ -131,7 +95,7 @@ public class InRangeConstraintTest {
}
@Test
- public void testValidateValueTypeIntegerFalse() throws ConstraintValueDoNotMatchPropertyTypeException {
+ void testValidateValueTypeIntegerFalse() throws ConstraintValueDoNotMatchPropertyTypeException {
InRangeConstraint testSubject = createIntegerTestSubject();
Boolean validTypes = testSubject.validateValueType("string");
@@ -139,7 +103,7 @@ public class InRangeConstraintTest {
}
@Test
- public void testChangeStringConstraintValueTypeToIntegerThrow() {
+ void testChangeStringConstraintValueTypeToIntegerThrow() {
String propertyType = "integer";
InRangeConstraint testSubject = createStringTestSubject();
Exception exception = assertThrows(ConstraintValueDoNotMatchPropertyTypeException.class, () -> {
@@ -153,7 +117,7 @@ public class InRangeConstraintTest {
}
@Test
- public void testChangeIntegerConstraintValueTypeToString() throws ConstraintValueDoNotMatchPropertyTypeException {
+ void testChangeIntegerConstraintValueTypeToString() throws ConstraintValueDoNotMatchPropertyTypeException {
InRangeConstraint testSubject = createIntegerTestSubject();
testSubject.changeConstraintValueTypeTo("string");
List<Object> result = testSubject.getInRange();