Fix 'in_range constraints missing from TOSCA template'-bug 62/133062/7
authorvasraz <vasyl.razinkov@est.tech>
Wed, 1 Feb 2023 17:56:35 +0000 (17:56 +0000)
committerMichael Morris <michael.morris@est.tech>
Thu, 2 Feb 2023 12:05:26 +0000 (12:05 +0000)
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Change-Id: Icec2183849a8852621ec98f3ca1d94ac7c4dae31
Issue-ID: SDC-4357

14 files changed:
catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentPropertyServlet.java
catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java
catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintInRange.java
catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java
catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java
catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaType.java
catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtil.java
catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraint.java
catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java
catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java
catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/RelationshipTypeOperationTest.java
catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/ToscaTypeTest.java
catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraintTest.java
catalog-ui/src/app/ng2/pages/properties-assignment/constraints/constraints.component.ts

index b6f031b..c58c43d 100644 (file)
@@ -50,7 +50,6 @@ import org.openecomp.sdc.be.dao.api.ActionStatus;
 import org.openecomp.sdc.be.datamodel.utils.PropertyValueConstraintValidationUtil;
 import org.openecomp.sdc.be.impl.ComponentsUtils;
 import org.openecomp.sdc.be.model.PropertyDefinition;
-import org.openecomp.sdc.be.model.User;
 import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
 import org.openecomp.sdc.be.resources.data.EntryData;
 import org.openecomp.sdc.common.api.Constants;
@@ -262,21 +261,19 @@ public class ComponentPropertyServlet extends BeGenericServlet {
         try {
             Either<Map<String, PropertyDefinition>, ActionStatus> propertyDefinition = getPropertyModel(componentId, data);
             if (propertyDefinition.isRight()) {
-                ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(propertyDefinition.right().value());
-                return buildErrorResponse(responseFormat);
+                return buildErrorResponse(getComponentsUtils().getResponseFormat(propertyDefinition.right().value()));
             }
             Map<String, PropertyDefinition> properties = propertyDefinition.left().value();
             if (properties == null || properties.size() != 1) {
                 log.info("Property content is invalid - {}", data);
-                ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
-                return buildErrorResponse(responseFormat);
+                return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT));
             }
             Map.Entry<String, PropertyDefinition> entry = properties.entrySet().iterator().next();
             PropertyDefinition newPropertyDefinition = entry.getValue();
             newPropertyDefinition.setParentUniqueId(componentId);
             newPropertyDefinition.setUserCreated(true);
-            Either<EntryData<String, PropertyDefinition>, ResponseFormat> addPropertyEither = propertyBusinessLogic
-                .addPropertyToComponent(componentId, newPropertyDefinition, userId);
+            Either<EntryData<String, PropertyDefinition>, ResponseFormat> addPropertyEither =
+                propertyBusinessLogic.addPropertyToComponent(componentId, newPropertyDefinition, userId);
             if (addPropertyEither.isRight()) {
                 return buildErrorResponse(addPropertyEither.right().value());
             }
@@ -285,8 +282,7 @@ public class ComponentPropertyServlet extends BeGenericServlet {
         } catch (Exception e) {
             BeEcompErrorManager.getInstance().logBeRestApiGeneralError(CREATE_PROPERTY);
             log.debug("create property failed with exception", e);
-            ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR);
-            return buildErrorResponse(responseFormat);
+            return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
         }
     }
 
@@ -294,23 +290,18 @@ public class ComponentPropertyServlet extends BeGenericServlet {
         String url = request.getMethod() + " " + request.getRequestURI();
         log.debug("Start handle request of {}", url);
         loggerSupportability.log(LoggerSupportabilityActions.UPDATE_PROPERTIES, StatusCode.STARTED, "UPDATE_PROPERTIES by user {} ", userId);
-        // get modifier id
-        User modifier = new User();
-        modifier.setUserId(userId);
         log.debug("modifier id is {}", userId);
-//
+
         try {
             // convert json to PropertyDefinition
             Either<Map<String, PropertyDefinition>, ActionStatus> propertiesListEither = getPropertiesListForUpdate(data);
             if (propertiesListEither.isRight()) {
-                ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(propertiesListEither.right().value());
-                return buildErrorResponse(responseFormat);
+                return buildErrorResponse(getComponentsUtils().getResponseFormat(propertiesListEither.right().value()));
             }
             Map<String, PropertyDefinition> properties = propertiesListEither.left().value();
             if (properties == null) {
                 log.info("Property content is invalid - {}", data);
-                ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
-                return buildErrorResponse(responseFormat);
+                return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT));
             }
             //Validate value and Constraint of property and Fetch all data types from cache
             Either<Boolean, ResponseFormat> constraintValidatorResponse = new PropertyValueConstraintValidationUtil()
@@ -328,18 +319,14 @@ public class ComponentPropertyServlet extends BeGenericServlet {
                     log.info("Failed to update Property. Reason - {}", status.right().value());
                     return buildErrorResponse(status.right().value());
                 }
-                EntryData<String, PropertyDefinition> property = status.left().value();
-                PropertyDefinition updatedPropertyDefinition = property.getValue();
-                log.debug("Property id {} updated successfully ", updatedPropertyDefinition.getUniqueId());
+                log.debug("Property id {} updated successfully ", status.left().value().getValue().getUniqueId());
             }
-            ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
             loggerSupportability.log(LoggerSupportabilityActions.UPDATE_PROPERTIES, StatusCode.COMPLETE, "UPDATE_PROPERTIES by user {} ", userId);
-            return buildOkResponse(responseFormat, properties);
+            return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), properties);
         } catch (Exception e) {
             BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Update Property");
             log.debug("update property failed with exception", e);
-            ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR);
-            return buildErrorResponse(responseFormat);
+            return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
         }
     }
 
@@ -356,8 +343,7 @@ public class ComponentPropertyServlet extends BeGenericServlet {
         } catch (Exception e) {
             BeEcompErrorManager.getInstance().logBeRestApiGeneralError(CREATE_PROPERTY);
             log.debug("get property failed with exception", e);
-            ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR);
-            return buildErrorResponse(responseFormat);
+            return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
         }
     }
 
@@ -373,8 +359,7 @@ public class ComponentPropertyServlet extends BeGenericServlet {
         } catch (Exception e) {
             BeEcompErrorManager.getInstance().logBeRestApiGeneralError(CREATE_PROPERTY);
             log.debug("get property failed with exception", e);
-            ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR);
-            return buildErrorResponse(responseFormat);
+            return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
         }
     }
 
@@ -390,16 +375,12 @@ public class ComponentPropertyServlet extends BeGenericServlet {
                 return buildErrorResponse(status.right().value());
             }
             Map.Entry<String, PropertyDefinition> property = status.left().value();
-            String name = property.getKey();
-            PropertyDefinition propertyDefinition = property.getValue();
-            log.debug("Property {} deleted successfully with id {}", name, propertyDefinition.getUniqueId());
-            ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.NO_CONTENT);
-            return buildOkResponse(responseFormat, propertyToJson(property));
+            log.debug("Property {} deleted successfully with id {}", property.getKey(), property.getValue().getUniqueId());
+            return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.NO_CONTENT), propertyToJson(property));
         } catch (Exception e) {
             BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Delete Property");
             log.debug("delete property failed with exception", e);
-            ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR);
-            return buildErrorResponse(responseFormat);
+            return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
         }
     }
 }
index cecb131..d603e79 100644 (file)
@@ -202,15 +202,12 @@ public class PropertyConvertor {
                     inRangeConstraint.changeConstraintValueTypeTo(propertyType);
                 }
 
-                List<Object> range = new ArrayList<>();
-                range.add(inRangeConstraint.getMin());
-                range.add(inRangeConstraint.getMax());
-                convertedConstraints.add(new ToscaPropertyConstraintInRange(range));
+                convertedConstraints.add(new ToscaPropertyConstraintInRange(inRangeConstraint.getInRange()));
             }
             if (constraint instanceof ValidValuesConstraint) {
                 ValidValuesConstraint validValues = ((ValidValuesConstraint) constraint);
 
-                if (propertyType.equals(ToscaType.INTEGER.toString()) || propertyType.equals(ToscaType.FLOAT.toString())) {
+                if (doesPropertyTypeNeedConverted(propertyType)) {
                     validValues.changeConstraintValueTypeTo(propertyType);
                 }
 
@@ -234,7 +231,7 @@ public class PropertyConvertor {
     }
 
     private boolean doesPropertyTypeNeedConverted(String propertyType) {
-        return propertyType.equals(ToscaType.INTEGER.getType()) || propertyType.equals(ToscaType.FLOAT.getType());
+        return ToscaType.INTEGER.getType().equals(propertyType) || ToscaType.FLOAT.getType().equals(propertyType);
     }
 
     public Object convertToToscaObject(PropertyDataDefinition property, String value, Map<String, DataTypeDefinition> dataTypes,
index 91e1f55..43cc0e3 100644 (file)
  */
 package org.openecomp.sdc.be.tosca.model;
 
+import java.util.LinkedList;
+import java.util.List;
 import lombok.AllArgsConstructor;
 import lombok.Getter;
 import lombok.Setter;
-import java.util.List;
 import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
 
 /**
index dae9ec8..0fb88a5 100644 (file)
@@ -777,8 +777,8 @@ class ComponentsUtilsTest {
         assertEquals(5, ((GreaterOrEqualConstraint) properties[1].getConstraints().iterator().next()).getGreaterOrEqual());
         assertEquals(7, ((LessThanConstraint) properties[2].getConstraints().iterator().next()).getLessThan());
         assertEquals(9, ((LessOrEqualConstraint) properties[3].getConstraints().iterator().next()).getLessOrEqual());
-        assertEquals("5", ((InRangeConstraint) properties[4].getConstraints().iterator().next()).getMin().toString());
-        assertEquals("10", ((InRangeConstraint) properties[4].getConstraints().iterator().next()).getMax().toString());
+        assertEquals("5", ((InRangeConstraint) properties[4].getConstraints().iterator().next()).getInRange().get(0).toString());
+        assertEquals("10", ((InRangeConstraint) properties[4].getConstraints().iterator().next()).getInRange().get(1).toString());
         assertEquals(3, ((ValidValuesConstraint) properties[5].getConstraints().iterator().next()).getValidValues().size());
         assertEquals(11, ((LengthConstraint) properties[6].getConstraints().iterator().next()).getLength());
         assertEquals(13, ((MinLengthConstraint) properties[7].getConstraints().iterator().next()).getMinLength());
index 3d2e701..fa6df00 100644 (file)
@@ -27,7 +27,6 @@ import com.fasterxml.jackson.databind.DeserializationContext;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.node.ArrayNode;
 import com.fasterxml.jackson.databind.node.JsonNodeType;
-import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.gson.JsonArray;
 import com.google.gson.JsonDeserializationContext;
@@ -45,6 +44,7 @@ import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -94,6 +94,8 @@ 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.ConstraintUtil;
 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;
@@ -2141,8 +2143,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.getMin())));
-                jsonArray.add(JsonParser.parseString(String.valueOf(rangeConstraint.getMax())));
+                jsonArray.add(JsonParser.parseString(String.valueOf(rangeConstraint.getInRange().get(0))));
+                jsonArray.add(JsonParser.parseString(String.valueOf(rangeConstraint.getInRange().get(1))));
                 result.add("inRange", jsonArray);
             } else if (src instanceof GreaterThanConstraint) {
                 GreaterThanConstraint greaterThanConstraint = (GreaterThanConstraint) src;
@@ -2195,12 +2197,15 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
                                         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(String.valueOf(minValue));
-                                        rangeConstraint.setMax(String.valueOf(maxValue));
-                                        propertyConstraint = rangeConstraint;
+                                        final Object minValue = rangeArray.get(0);
+                                        final Object maxValue = rangeArray.get(1);
+
+                                        final Comparable min = ConstraintUtil.convertToComparable(
+                                            ToscaType.getToscaType(minValue.getClass().getSimpleName().toLowerCase()), String.valueOf(minValue));
+                                        final Comparable max = ConstraintUtil.convertToComparable(
+                                            ToscaType.getToscaType(maxValue.getClass().getSimpleName().toLowerCase()), String.valueOf(maxValue));
+
+                                        propertyConstraint = new InRangeConstraint(Arrays.asList(min, max));
                                     }
                                 } else {
                                     log.warn("The value of InRangeConstraint is null");
@@ -2358,7 +2363,7 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
                                 propertyConstraint = deserializeConstraint(value, EqualConstraint.class);
                                 break;
                             case IN_RANGE:
-                                propertyConstraint = deserializeInRangeConstraintConstraint(value);
+                                propertyConstraint = deserializeInRangeConstraint(value);
                                 break;
                             case GREATER_THAN:
                                 propertyConstraint = deserializeConstraint(value, GreaterThanConstraint.class);
@@ -2448,18 +2453,20 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
             }
         }
 
-        private PropertyConstraint deserializeInRangeConstraintConstraint(JsonNode value) {
+        private PropertyConstraint deserializeInRangeConstraint(JsonNode value) {
             if (value instanceof ArrayNode) {
                 ArrayNode rangeArray = (ArrayNode) value;
                 if (rangeArray.size() != 2) {
                     log.error("The range constraint content is invalid. value = {}", value);
                 } else {
-                    String minValue = rangeArray.get(0).asText();
-                    String maxValue = rangeArray.get(1).asText();
-                    InRangeConstraint rangeConstraint = new InRangeConstraint(Lists.newArrayList(minValue, maxValue));
-                    rangeConstraint.setMin(minValue);
-                    rangeConstraint.setMax(maxValue);
-                    return rangeConstraint;
+                    final String minValue = rangeArray.get(0).asText();
+                    final String maxValue = rangeArray.get(1).asText();
+                    final Comparable min = ConstraintUtil.convertToComparable(
+                        ToscaType.getToscaType(minValue.getClass().getSimpleName().toLowerCase()), String.valueOf(minValue));
+                    final Comparable max = ConstraintUtil.convertToComparable(
+                        ToscaType.getToscaType(maxValue.getClass().getSimpleName().toLowerCase()), String.valueOf(maxValue));
+
+                    return new InRangeConstraint(Arrays.asList(min, max));
                 }
             }
             return null;
index 1f942a9..e4e229a 100644 (file)
@@ -47,7 +47,9 @@ public enum ToscaType {
     // @formatter:off
        STRING("string"),
        INTEGER("integer"),
+       LONG("long"),
        FLOAT("float"),
+       DOUBLE("double"),
        BOOLEAN("boolean"),
        TIMESTAMP("timestamp"),
        VERSION("version"),
@@ -87,7 +89,7 @@ public enum ToscaType {
             return null;
         }
         for (ToscaType type : ToscaType.values()) {
-            if (type.getType().equals(typeName)) {
+            if (type.getType().equalsIgnoreCase(typeName)) {
                 return type;
             }
         }
@@ -122,7 +124,9 @@ public enum ToscaType {
             case BOOLEAN:
                 return value.equals(true) || value.equals(false);
             case FLOAT:
+            case DOUBLE:
                 return value instanceof Float;
+            case LONG:
             case INTEGER:
             case RANGE:
                 return value instanceof Integer;
@@ -148,8 +152,10 @@ public enum ToscaType {
             case BOOLEAN:
                 return value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false");
             case FLOAT:
+            case DOUBLE:
                 return isFloat(value);
             case INTEGER:
+            case LONG:
                 return isInteger(value);
             case SCALAR_UNIT_SIZE:
                 return isScalarUnitSize(value);
@@ -242,10 +248,12 @@ public enum ToscaType {
             case BOOLEAN:
                 return Boolean.valueOf(value);
             case FLOAT:
+            case DOUBLE:
                 return Float.valueOf(value);
             case RANGE:
             case INTEGER:
-                return Long.valueOf(value);
+            case LONG:
+                return Integer.valueOf(value);
             case TIMESTAMP:
                 try {
                     return new SimpleDateFormat("MMM dd, yyyy hh:mm:ss a", Locale.US).parse(value);
index 61f069a..fee828c 100644 (file)
@@ -66,7 +66,9 @@ public final class ConstraintUtil {
         final ToscaType toscaType = ToscaType.getToscaType(propertyType.getType());
         switch (toscaType) {
             case FLOAT:
+            case DOUBLE:
             case INTEGER:
+            case LONG:
             case TIMESTAMP:
             case VERSION:
             case STRING:
index 4f362b9..9330c8c 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.openecomp.sdc.be.model.tosca.constraints;
 
-import com.fasterxml.jackson.annotation.JsonIgnore;
 import java.util.List;
 import lombok.EqualsAndHashCode;
 import lombok.Getter;
@@ -43,10 +42,6 @@ public class InRangeConstraint extends AbstractPropertyConstraint {
     @NonNull
     @EqualsAndHashCode.Include
     private List<Object> inRange;
-    @JsonIgnore
-    private Comparable min;
-    @JsonIgnore
-    private Comparable max;
 
     public InRangeConstraint(List<Object> inRange) {
         this.inRange = inRange;
@@ -69,8 +64,7 @@ public class InRangeConstraint extends AbstractPropertyConstraint {
             throw new ConstraintValueDoNotMatchPropertyTypeException(
                 "Invalid max value for in range constraint [" + maxRawText + "] as it does not follow the property type [" + propertyType + "]");
         }
-        min = ConstraintUtil.convertToComparable(propertyType, minRawText);
-        max = ConstraintUtil.convertToComparable(propertyType, maxRawText);
+        inRange.replaceAll(obj -> propertyType.convert(String.valueOf(obj)));
     }
 
     @Override
@@ -78,9 +72,22 @@ public class InRangeConstraint extends AbstractPropertyConstraint {
         if (propertyValue == null) {
             throw new ConstraintViolationException("Value to check is null");
         }
-        if (!(min.getClass().isAssignableFrom(propertyValue.getClass()))) {
+        if (!(inRange.get(0).getClass().isAssignableFrom(propertyValue.getClass()))) {
             throw new ConstraintViolationException(
-                "Value to check is not comparable to range type, value type [" + propertyValue.getClass() + "], range type [" + min.getClass() + "]");
+                "Value to check is not comparable to range type, value type [" + propertyValue.getClass() + "], range type [" + inRange.get(0)
+                    .getClass() + "]");
+        }
+        if (!(inRange.get(1).getClass().isAssignableFrom(propertyValue.getClass()))) {
+            throw new ConstraintViolationException(
+                "Value to check is not comparable to range type, value type [" + propertyValue.getClass() + "], range type [" + inRange.get(1)
+                    .getClass() + "]");
+        }
+        final ToscaType propertyType = ToscaType.getToscaType(propertyValue.getClass().getSimpleName().toLowerCase());
+        final Comparable min = ConstraintUtil.convertToComparable(propertyType, String.valueOf(inRange.get(0)));
+        final Comparable max = ConstraintUtil.convertToComparable(propertyType, String.valueOf(inRange.get(1)));
+
+        if (min.compareTo(max) > 0) {
+            throw new IllegalArgumentException("The MIN [" + min + "] should be less than MAX [" + max + "]");
         }
         if (min.compareTo(propertyValue) > 0 || max.compareTo(propertyValue) < 0) {
             throw new ConstraintViolationException("The value [" + propertyValue + "] is out of range " + inRange);
@@ -98,7 +105,9 @@ public class InRangeConstraint extends AbstractPropertyConstraint {
 
     @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),
+        Comparable min = ConstraintUtil.convertToComparable(toscaType, String.valueOf(inRange.get(0)));
+        Comparable max = ConstraintUtil.convertToComparable(toscaType, String.valueOf(inRange.get(1)));
+        return getErrorMessage(toscaType, e, propertyName, "'%s' value must be in a range of %s", String.valueOf(min),
             String.valueOf(max));
     }
 
@@ -124,8 +133,6 @@ public class InRangeConstraint extends AbstractPropertyConstraint {
         ToscaType toscaType = ToscaType.getToscaType(propertyType);
         try {
             inRange.replaceAll(obj -> toscaType.convert(String.valueOf(obj)));
-            min = ConstraintUtil.convertToComparable(toscaType, String.valueOf(inRange.get(0)));
-            max = ConstraintUtil.convertToComparable(toscaType, String.valueOf(inRange.get(1)));
         } catch (Exception e) {
             throw new ConstraintValueDoNotMatchPropertyTypeException(
                 "inRange constraint has invalid values <" + inRange + "> property type is <" + propertyType + ">");
index 39f9118..12e5431 100644 (file)
@@ -27,6 +27,7 @@ import static org.junit.Assert.assertTrue;
 
 import fj.data.Either;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -523,13 +524,9 @@ public class CapabilityTypeOperationTest extends ModelTestBase {
         property2.setDescription("Number of (actual or virtual) CPUs associated with the Compute node.");
         property2.setType(ToscaType.INTEGER.name().toLowerCase());
         List<PropertyConstraint> constraints3 = new ArrayList<>();
-        List<Object> range = new ArrayList<>();
-        range.add("1");
-        range.add("4");
 
-        InRangeConstraint propertyConstraint3 = new InRangeConstraint(range);
+        InRangeConstraint propertyConstraint3 = new InRangeConstraint(Arrays.asList("1", "4"));
         constraints3.add(propertyConstraint3);
-        // property2.setConstraints(constraints3);
         property2.setConstraints(constraints3);
         return property2;
     }
index 3f78ff0..a1f8630 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -168,11 +168,7 @@ public class PropertyOperationTest extends ModelTestBase {
     }
 
     private InRangeConstraint buildInRangeConstraint() {
-        List<Object> range = new ArrayList<>();
-        range.add("23");
-        range.add("67");
-        InRangeConstraint inRangeConstraint = new InRangeConstraint(range);
-        return inRangeConstraint;
+        return new InRangeConstraint(Arrays.asList("23", "67"));
     }
 
     private ValidValuesConstraint buildValidValuesConstraint() {
@@ -295,7 +291,7 @@ public class PropertyOperationTest extends ModelTestBase {
 
         List<PropertyRule> rules = new ArrayList<>();
         PropertyRule propertyRule = new PropertyRule();
-        String[] ruleArr = { "node1", ".+", "node3" };
+        String[] ruleArr = {"node1", ".+", "node3"};
         List<String> rule1 = new ArrayList<>(Arrays.asList(ruleArr));
         propertyRule.setRule(rule1);
         propertyRule.setValue("88");
@@ -338,13 +334,13 @@ public class PropertyOperationTest extends ModelTestBase {
 
         List<PropertyRule> rules = new ArrayList<>();
         PropertyRule propertyRule1 = new PropertyRule();
-        String[] ruleArr1 = { "node1", "node2", ".+" };
+        String[] ruleArr1 = {"node1", "node2", ".+"};
         List<String> rule1 = new ArrayList<>(Arrays.asList(ruleArr1));
         propertyRule1.setRule(rule1);
         propertyRule1.setValue("88");
 
         PropertyRule propertyRule2 = new PropertyRule();
-        String[] ruleArr2 = { "node1", "node2", "node3" };
+        String[] ruleArr2 = {"node1", "node2", "node3"};
         List<String> rule2 = new ArrayList<>(Arrays.asList(ruleArr2));
         propertyRule2.setRule(rule2);
         propertyRule2.setValue("99");
@@ -390,13 +386,13 @@ public class PropertyOperationTest extends ModelTestBase {
 
         List<PropertyRule> rules = new ArrayList<>();
         PropertyRule propertyRule1 = new PropertyRule();
-        String[] ruleArr1 = { "node1", "node2", ".+" };
+        String[] ruleArr1 = {"node1", "node2", ".+"};
         List<String> rule1 = new ArrayList<>(Arrays.asList(ruleArr1));
         propertyRule1.setRule(rule1);
         propertyRule1.setValue("88");
 
         PropertyRule propertyRule2 = new PropertyRule();
-        String[] ruleArr2 = { "node1", "node2", "node3" };
+        String[] ruleArr2 = {"node1", "node2", "node3"};
         List<String> rule2 = new ArrayList<>(Arrays.asList(ruleArr2));
         propertyRule2.setRule(rule2);
         propertyRule2.setValue("99");
@@ -413,7 +409,7 @@ public class PropertyOperationTest extends ModelTestBase {
 
         List<PropertyRule> rules3 = new ArrayList<>();
         PropertyRule propertyRule3 = new PropertyRule();
-        String[] ruleArr3 = { "node2", "node3" };
+        String[] ruleArr3 = {"node2", "node3"};
         List<String> rule3 = new ArrayList<>(Arrays.asList(ruleArr3));
         propertyRule3.setRule(rule3);
         propertyRule3.setValue("77");
@@ -452,13 +448,13 @@ public class PropertyOperationTest extends ModelTestBase {
 
         List<PropertyRule> rules = new ArrayList<>();
         PropertyRule propertyRule1 = new PropertyRule();
-        String[] ruleArr1 = { "node1", "node2", ".+" };
+        String[] ruleArr1 = {"node1", "node2", ".+"};
         List<String> rule1 = new ArrayList<>(Arrays.asList(ruleArr1));
         propertyRule1.setRule(rule1);
         propertyRule1.setValue("88");
 
         PropertyRule propertyRule2 = new PropertyRule();
-        String[] ruleArr2 = { "node1", "node2", "node3" };
+        String[] ruleArr2 = {"node1", "node2", "node3"};
         List<String> rule2 = new ArrayList<>(Arrays.asList(ruleArr2));
         propertyRule2.setRule(rule2);
         propertyRule2.setValue("99");
@@ -475,7 +471,7 @@ public class PropertyOperationTest extends ModelTestBase {
 
         List<PropertyRule> rules3 = new ArrayList<>();
         PropertyRule propertyRule3 = new PropertyRule();
-        String[] ruleArr3 = { "node2", "node333" };
+        String[] ruleArr3 = {"node2", "node333"};
         List<String> rule3 = new ArrayList<>(Arrays.asList(ruleArr3));
         propertyRule3.setRule(rule3);
         propertyRule3.setValue("77");
@@ -489,7 +485,7 @@ public class PropertyOperationTest extends ModelTestBase {
         assertEquals("check value", propertyRule2.getValue(), instanceProperty.getValue());
         assertEquals("check default value", "vv1", instanceProperty.getDefaultValue());
 
-       }
+    }
 
     private PropertyOperation createTestSubject() {
         final var propertyOperation = new PropertyOperation(new HealingJanusGraphGenericDao(new JanusGraphClient()), null);
@@ -497,577 +493,578 @@ public class PropertyOperationTest extends ModelTestBase {
         return propertyOperation;
     }
 
-       @Test
-       public void testConvertPropertyDataToPropertyDefinition() throws Exception {
-               PropertyOperation testSubject;
-               PropertyData propertyDataResult = new PropertyData();
-               String propertyName = "";
-               String resourceId = "";
-               PropertyDefinition result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.convertPropertyDataToPropertyDefinition(propertyDataResult, propertyName, resourceId);
-       }
-       
-       @Test
-       public void testAddProperty() throws Exception {
-               PropertyOperation testSubject;
-               String propertyName = "";
-               PropertyDefinition propertyDefinition = new PropertyDefinition();
-               String resourceId = "";
-               Either<PropertyData, StorageOperationStatus> result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.addProperty(propertyName, propertyDefinition, resourceId);
-       }
-
-       
-       @Test
-       public void testValidateAndUpdateProperty() throws Exception {
-               PropertyOperation testSubject;
-               IComplexDefaultValue propertyDefinition = new PropertyDefinition();
-               Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
-               dataTypes.put("", new DataTypeDefinition());
-               StorageOperationStatus result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.validateAndUpdateProperty(propertyDefinition, dataTypes);
-       }
-
-       
-       @Test
-       public void testAddPropertyToGraph() throws Exception {
-               PropertyOperation testSubject;
-               String propertyName = "";
-               PropertyDefinition propertyDefinition = new PropertyDefinition();
-               String resourceId = "";
-               Either<PropertyData, JanusGraphOperationStatus> result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.addPropertyToGraph(propertyName, propertyDefinition, resourceId);
-       }
-
-       
-       @Test
-       public void testAddPropertyToGraphByVertex() throws Exception {
-               PropertyOperation testSubject;
-               JanusGraphVertex metadataVertex = null;
-               String propertyName = "";
-               PropertyDefinition propertyDefinition = new PropertyDefinition();
-               String resourceId = "";
-               JanusGraphOperationStatus result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.addPropertyToGraphByVertex(metadataVertex, propertyName, propertyDefinition, resourceId);
-       }
-
-       
-       @Test
-       public void testGetJanusGraphGenericDao() throws Exception {
-               PropertyOperation testSubject;
-               JanusGraphGenericDao result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.getJanusGraphGenericDao();
-       }
-
-       @Test
-       public void testDeletePropertyFromGraph() throws Exception {
-               PropertyOperation testSubject;
-               String propertyId = "";
-               Either<PropertyData, JanusGraphOperationStatus> result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.deletePropertyFromGraph(propertyId);
-       }
-
-       
-       @Test
-       public void testUpdateProperty() throws Exception {
-               PropertyOperation testSubject;
-               String propertyId = "";
-               PropertyDefinition newPropertyDefinition = new PropertyDefinition();
-               Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
-               Either<PropertyData, StorageOperationStatus> result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.updateProperty(propertyId, newPropertyDefinition, dataTypes);
-       }
-
-       
-       @Test
-       public void testUpdatePropertyFromGraph() throws Exception {
-               PropertyOperation testSubject;
-               String propertyId = "";
-               PropertyDefinition propertyDefinition = null;
-               Either<PropertyData, JanusGraphOperationStatus> result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.updatePropertyFromGraph(propertyId, propertyDefinition);
-       }
-
-
-       @Test
-       public void testSetJanusGraphGenericDao()  {
-
-               PropertyOperation testSubject;
+    @Test
+    public void testConvertPropertyDataToPropertyDefinition() throws Exception {
+        PropertyOperation testSubject;
+        PropertyData propertyDataResult = new PropertyData();
+        String propertyName = "";
+        String resourceId = "";
+        PropertyDefinition result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.convertPropertyDataToPropertyDefinition(propertyDataResult, propertyName, resourceId);
+    }
+
+    @Test
+    public void testAddProperty() throws Exception {
+        PropertyOperation testSubject;
+        String propertyName = "";
+        PropertyDefinition propertyDefinition = new PropertyDefinition();
+        String resourceId = "";
+        Either<PropertyData, StorageOperationStatus> result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.addProperty(propertyName, propertyDefinition, resourceId);
+    }
+
+
+    @Test
+    public void testValidateAndUpdateProperty() throws Exception {
+        PropertyOperation testSubject;
+        IComplexDefaultValue propertyDefinition = new PropertyDefinition();
+        Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
+        dataTypes.put("", new DataTypeDefinition());
+        StorageOperationStatus result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.validateAndUpdateProperty(propertyDefinition, dataTypes);
+    }
+
+
+    @Test
+    public void testAddPropertyToGraph() throws Exception {
+        PropertyOperation testSubject;
+        String propertyName = "";
+        PropertyDefinition propertyDefinition = new PropertyDefinition();
+        String resourceId = "";
+        Either<PropertyData, JanusGraphOperationStatus> result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.addPropertyToGraph(propertyName, propertyDefinition, resourceId);
+    }
+
+
+    @Test
+    public void testAddPropertyToGraphByVertex() throws Exception {
+        PropertyOperation testSubject;
+        JanusGraphVertex metadataVertex = null;
+        String propertyName = "";
+        PropertyDefinition propertyDefinition = new PropertyDefinition();
+        String resourceId = "";
+        JanusGraphOperationStatus result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.addPropertyToGraphByVertex(metadataVertex, propertyName, propertyDefinition, resourceId);
+    }
+
+
+    @Test
+    public void testGetJanusGraphGenericDao() throws Exception {
+        PropertyOperation testSubject;
+        JanusGraphGenericDao result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.getJanusGraphGenericDao();
+    }
+
+    @Test
+    public void testDeletePropertyFromGraph() throws Exception {
+        PropertyOperation testSubject;
+        String propertyId = "";
+        Either<PropertyData, JanusGraphOperationStatus> result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.deletePropertyFromGraph(propertyId);
+    }
+
+
+    @Test
+    public void testUpdateProperty() throws Exception {
+        PropertyOperation testSubject;
+        String propertyId = "";
+        PropertyDefinition newPropertyDefinition = new PropertyDefinition();
+        Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
+        Either<PropertyData, StorageOperationStatus> result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.updateProperty(propertyId, newPropertyDefinition, dataTypes);
+    }
+
+
+    @Test
+    public void testUpdatePropertyFromGraph() throws Exception {
+        PropertyOperation testSubject;
+        String propertyId = "";
+        PropertyDefinition propertyDefinition = null;
+        Either<PropertyData, JanusGraphOperationStatus> result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.updatePropertyFromGraph(propertyId, propertyDefinition);
+    }
+
+
+    @Test
+    public void testSetJanusGraphGenericDao() {
+
+        PropertyOperation testSubject;
         HealingJanusGraphGenericDao janusGraphGenericDao = null;
 
-               // default test
-               testSubject = createTestSubject();
-               testSubject.setJanusGraphGenericDao(janusGraphGenericDao);
-       }
-
-       
-       @Test
-       public void testAddPropertyToNodeType()  {
-               PropertyOperation testSubject;
-               String propertyName = "";
-               PropertyDefinition propertyDefinition = new PropertyDefinition();
-               NodeTypeEnum nodeType = NodeTypeEnum.Attribute;
-               String uniqueId = "";
-               Either<PropertyData, JanusGraphOperationStatus> result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.addPropertyToNodeType(propertyName, propertyDefinition, nodeType, uniqueId);
-       }
-
-       
-       @Test
-       public void testFindPropertiesOfNode() throws Exception {
-               PropertyOperation testSubject;
-               NodeTypeEnum nodeType = null;
-               String uniqueId = "";
-               Either<Map<String, PropertyDefinition>, JanusGraphOperationStatus> result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.findPropertiesOfNode(nodeType, uniqueId);
-       }
-
-       
-       @Test
-       public void testDeletePropertiesAssociatedToNode() throws Exception {
-               PropertyOperation testSubject;
-               NodeTypeEnum nodeType = null;
-               String uniqueId = "";
-               Either<Map<String, PropertyDefinition>, StorageOperationStatus> result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.deletePropertiesAssociatedToNode(nodeType, uniqueId);
-       }
-
-       
-       @Test
-       public void testDeleteAllPropertiesAssociatedToNode() throws Exception {
-               PropertyOperation testSubject;
-               NodeTypeEnum nodeType = null;
-               String uniqueId = "";
-               Either<Map<String, PropertyDefinition>, StorageOperationStatus> result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.deleteAllPropertiesAssociatedToNode(nodeType, uniqueId);
-       }
-
-       
-       @Test
-       public void testIsPropertyExist() throws Exception {
-               PropertyOperation testSubject;
-               List<PropertyDefinition> properties = null;
-               String resourceUid = "";
-               String propertyName = "";
-               String propertyType = "";
-               boolean result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.isPropertyExist(properties, resourceUid, propertyName, propertyType);
-       }
-
-       
-       @Test
-       public void testValidateAndUpdateRules() throws Exception {
-               PropertyOperation testSubject;
-               String propertyType = "";
-               List<PropertyRule> rules = null;
-               String innerType = "";
-               Map<String, DataTypeDefinition> dataTypes = null;
-               boolean isValidate = false;
-               ImmutablePair<String, Boolean> result;
-
-               // test 1
-               testSubject = createTestSubject();
-               rules = null;
-               result = testSubject.validateAndUpdateRules(propertyType, rules, innerType, dataTypes, isValidate);
-       }
-
-       
-       @Test
-       public void testAddRulesToNewPropertyValue() throws Exception {
-               PropertyOperation testSubject;
-               PropertyValueData propertyValueData = new PropertyValueData();
-               ComponentInstanceProperty resourceInstanceProperty = new ComponentInstanceProperty();
-               String resourceInstanceId = "";
-
-               // default test
-               testSubject = createTestSubject();
-               testSubject.addRulesToNewPropertyValue(propertyValueData, resourceInstanceProperty, resourceInstanceId);
-       }
-
-       
-       @Test
-       public void testFindPropertyValue() throws Exception {
-               PropertyOperation testSubject;
-               String resourceInstanceId = "";
-               String propertyId = "";
-               ImmutablePair<JanusGraphOperationStatus, String> result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.findPropertyValue(resourceInstanceId, propertyId);
-       }
-
-       
-       @Test
-       public void testUpdateRulesInPropertyValue() throws Exception {
-               PropertyOperation testSubject;
-               PropertyValueData propertyValueData = new PropertyValueData();
-               ComponentInstanceProperty resourceInstanceProperty = new ComponentInstanceProperty();
-               String resourceInstanceId = "";
-
-               // default test
-               testSubject = createTestSubject();
-               testSubject.updateRulesInPropertyValue(propertyValueData, resourceInstanceProperty, resourceInstanceId);
-       }
-
-       
-       @Test
-       public void testGetAllPropertiesOfResourceInstanceOnlyPropertyDefId() throws Exception {
-               PropertyOperation testSubject;
-               String resourceInstanceUid = "";
-               Either<List<ComponentInstanceProperty>, JanusGraphOperationStatus> result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.getAllPropertiesOfResourceInstanceOnlyPropertyDefId(resourceInstanceUid);
-       }
-
-       
-       @Test
-       public void testRemovePropertyOfResourceInstance() throws Exception {
-               PropertyOperation testSubject;
-               String propertyValueUid = "";
-               String resourceInstanceId = "";
-               Either<PropertyValueData, JanusGraphOperationStatus> result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.removePropertyOfResourceInstance(propertyValueUid, resourceInstanceId);
-       }
-
-       
-       @Test
-       public void testRemovePropertyValueFromResourceInstance() throws Exception {
-               PropertyOperation testSubject;
-               String propertyValueUid = "";
-               String resourceInstanceId = "";
-               boolean inTransaction = false;
-               Either<ComponentInstanceProperty, StorageOperationStatus> result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.removePropertyValueFromResourceInstance(propertyValueUid, resourceInstanceId,
-                               inTransaction);
-       }
-
-       
-       @Test
-       public void testBuildResourceInstanceProperty() throws Exception {
-               PropertyOperation testSubject;
-               PropertyValueData propertyValueData = new PropertyValueData();
-               ComponentInstanceProperty resourceInstanceProperty = new ComponentInstanceProperty();
-               ComponentInstanceProperty result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.buildResourceInstanceProperty(propertyValueData, resourceInstanceProperty);
-       }
-
-       
-       @Test
-       public void testIsPropertyDefaultValueValid() throws Exception {
-               PropertyOperation testSubject;
-               IComplexDefaultValue propertyDefinition = null;
-               Map<String, DataTypeDefinition> dataTypes = null;
-               boolean result;
-
-               // test 1
-               testSubject = createTestSubject();
-               propertyDefinition = null;
-               result = testSubject.isPropertyDefaultValueValid(propertyDefinition, dataTypes);
-               Assert.assertEquals(false, result);
-       }
-
-       
-       @Test
-       public void testIsPropertyTypeValid() throws Exception {
-               PropertyOperation testSubject;
-               IComplexDefaultValue property = null;
-               boolean result;
-
-               // test 1
-               testSubject = createTestSubject();
-               property = null;
-               result = testSubject.isPropertyTypeValid(property, (String)null);
-               Assert.assertEquals(false, result);
-       }
-
-       
-       @Test
-       public void testIsPropertyInnerTypeValid() throws Exception {
-               PropertyOperation testSubject;
-               IComplexDefaultValue property = null;
-               Map<String, DataTypeDefinition> dataTypes = null;
-               ImmutablePair<String, Boolean> result;
-
-               // test 1
-               testSubject = createTestSubject();
-               property = null;
-               result = testSubject.isPropertyInnerTypeValid(property, dataTypes);
-       }
-
-       
-       @Test
-       public void testGetAllPropertiesOfResourceInstanceOnlyPropertyDefId_1() throws Exception {
-               PropertyOperation testSubject;
-               String resourceInstanceUid = "";
-               NodeTypeEnum instanceNodeType = null;
-               Either<List<ComponentInstanceProperty>, JanusGraphOperationStatus> result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.getAllPropertiesOfResourceInstanceOnlyPropertyDefId(resourceInstanceUid, instanceNodeType);
-       }
-
-       
-       @Test
-       public void testFindDefaultValueFromSecondPosition() throws Exception {
-               PropertyOperation testSubject;
-               List<String> pathOfComponentInstances = null;
-               String propertyUniqueId = "";
-               String defaultValue = "";
-               Either<String, JanusGraphOperationStatus> result;
-
-               // test 1
-               testSubject = createTestSubject();
-               pathOfComponentInstances = null;
-               result = testSubject.findDefaultValueFromSecondPosition(pathOfComponentInstances, propertyUniqueId,
-                               defaultValue);
-       }
-
-       
-       @Test
-       public void testUpdatePropertyByBestMatch() throws Exception {
-               PropertyOperation testSubject;
-               String propertyUniqueId = "";
-               ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
-               List<String> path = new ArrayList<>();
-               path.add("path");
-               instanceProperty.setPath(path);
-               Map<String, ComponentInstanceProperty> instanceIdToValue = new HashMap<>();
-               instanceIdToValue.put("123", instanceProperty);
-
-               // default test
-               testSubject = createTestSubject();
-               testSubject.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
-       }
-
-       
-       @Test
-       public void testGetDataTypeByUid() throws Exception {
-               PropertyOperation testSubject;
-               String uniqueId = "";
-               Either<DataTypeDefinition, JanusGraphOperationStatus> result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.getDataTypeByUid(uniqueId);
-       }
-
-       
-       @Test
-       public void testAddAndGetDataType() throws Exception {
-           final String dataTypeName = "myDataType";
-               DataTypeDefinition dataTypeDefinition = new DataTypeDefinition();
-               dataTypeDefinition.setName("myDataType");
-               Either<DataTypeDefinition, StorageOperationStatus> result;
-               
+        // default test
+        testSubject = createTestSubject();
+        testSubject.setJanusGraphGenericDao(janusGraphGenericDao);
+    }
+
+
+    @Test
+    public void testAddPropertyToNodeType() {
+        PropertyOperation testSubject;
+        String propertyName = "";
+        PropertyDefinition propertyDefinition = new PropertyDefinition();
+        NodeTypeEnum nodeType = NodeTypeEnum.Attribute;
+        String uniqueId = "";
+        Either<PropertyData, JanusGraphOperationStatus> result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.addPropertyToNodeType(propertyName, propertyDefinition, nodeType, uniqueId);
+    }
+
+
+    @Test
+    public void testFindPropertiesOfNode() throws Exception {
+        PropertyOperation testSubject;
+        NodeTypeEnum nodeType = null;
+        String uniqueId = "";
+        Either<Map<String, PropertyDefinition>, JanusGraphOperationStatus> result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.findPropertiesOfNode(nodeType, uniqueId);
+    }
+
+
+    @Test
+    public void testDeletePropertiesAssociatedToNode() throws Exception {
+        PropertyOperation testSubject;
+        NodeTypeEnum nodeType = null;
+        String uniqueId = "";
+        Either<Map<String, PropertyDefinition>, StorageOperationStatus> result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.deletePropertiesAssociatedToNode(nodeType, uniqueId);
+    }
+
+
+    @Test
+    public void testDeleteAllPropertiesAssociatedToNode() throws Exception {
+        PropertyOperation testSubject;
+        NodeTypeEnum nodeType = null;
+        String uniqueId = "";
+        Either<Map<String, PropertyDefinition>, StorageOperationStatus> result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.deleteAllPropertiesAssociatedToNode(nodeType, uniqueId);
+    }
+
+
+    @Test
+    public void testIsPropertyExist() throws Exception {
+        PropertyOperation testSubject;
+        List<PropertyDefinition> properties = null;
+        String resourceUid = "";
+        String propertyName = "";
+        String propertyType = "";
+        boolean result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.isPropertyExist(properties, resourceUid, propertyName, propertyType);
+    }
+
+
+    @Test
+    public void testValidateAndUpdateRules() throws Exception {
+        PropertyOperation testSubject;
+        String propertyType = "";
+        List<PropertyRule> rules = null;
+        String innerType = "";
+        Map<String, DataTypeDefinition> dataTypes = null;
+        boolean isValidate = false;
+        ImmutablePair<String, Boolean> result;
+
+        // test 1
+        testSubject = createTestSubject();
+        rules = null;
+        result = testSubject.validateAndUpdateRules(propertyType, rules, innerType, dataTypes, isValidate);
+    }
+
+
+    @Test
+    public void testAddRulesToNewPropertyValue() throws Exception {
+        PropertyOperation testSubject;
+        PropertyValueData propertyValueData = new PropertyValueData();
+        ComponentInstanceProperty resourceInstanceProperty = new ComponentInstanceProperty();
+        String resourceInstanceId = "";
+
+        // default test
+        testSubject = createTestSubject();
+        testSubject.addRulesToNewPropertyValue(propertyValueData, resourceInstanceProperty, resourceInstanceId);
+    }
+
+
+    @Test
+    public void testFindPropertyValue() throws Exception {
+        PropertyOperation testSubject;
+        String resourceInstanceId = "";
+        String propertyId = "";
+        ImmutablePair<JanusGraphOperationStatus, String> result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.findPropertyValue(resourceInstanceId, propertyId);
+    }
+
+
+    @Test
+    public void testUpdateRulesInPropertyValue() throws Exception {
+        PropertyOperation testSubject;
+        PropertyValueData propertyValueData = new PropertyValueData();
+        ComponentInstanceProperty resourceInstanceProperty = new ComponentInstanceProperty();
+        String resourceInstanceId = "";
+
+        // default test
+        testSubject = createTestSubject();
+        testSubject.updateRulesInPropertyValue(propertyValueData, resourceInstanceProperty, resourceInstanceId);
+    }
+
+
+    @Test
+    public void testGetAllPropertiesOfResourceInstanceOnlyPropertyDefId() throws Exception {
+        PropertyOperation testSubject;
+        String resourceInstanceUid = "";
+        Either<List<ComponentInstanceProperty>, JanusGraphOperationStatus> result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.getAllPropertiesOfResourceInstanceOnlyPropertyDefId(resourceInstanceUid);
+    }
+
+
+    @Test
+    public void testRemovePropertyOfResourceInstance() throws Exception {
+        PropertyOperation testSubject;
+        String propertyValueUid = "";
+        String resourceInstanceId = "";
+        Either<PropertyValueData, JanusGraphOperationStatus> result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.removePropertyOfResourceInstance(propertyValueUid, resourceInstanceId);
+    }
+
+
+    @Test
+    public void testRemovePropertyValueFromResourceInstance() throws Exception {
+        PropertyOperation testSubject;
+        String propertyValueUid = "";
+        String resourceInstanceId = "";
+        boolean inTransaction = false;
+        Either<ComponentInstanceProperty, StorageOperationStatus> result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.removePropertyValueFromResourceInstance(propertyValueUid, resourceInstanceId,
+            inTransaction);
+    }
+
+
+    @Test
+    public void testBuildResourceInstanceProperty() throws Exception {
+        PropertyOperation testSubject;
+        PropertyValueData propertyValueData = new PropertyValueData();
+        ComponentInstanceProperty resourceInstanceProperty = new ComponentInstanceProperty();
+        ComponentInstanceProperty result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.buildResourceInstanceProperty(propertyValueData, resourceInstanceProperty);
+    }
+
+
+    @Test
+    public void testIsPropertyDefaultValueValid() throws Exception {
+        PropertyOperation testSubject;
+        IComplexDefaultValue propertyDefinition = null;
+        Map<String, DataTypeDefinition> dataTypes = null;
+        boolean result;
+
+        // test 1
+        testSubject = createTestSubject();
+        propertyDefinition = null;
+        result = testSubject.isPropertyDefaultValueValid(propertyDefinition, dataTypes);
+        Assert.assertEquals(false, result);
+    }
+
+
+    @Test
+    public void testIsPropertyTypeValid() throws Exception {
+        PropertyOperation testSubject;
+        IComplexDefaultValue property = null;
+        boolean result;
+
+        // test 1
+        testSubject = createTestSubject();
+        property = null;
+        result = testSubject.isPropertyTypeValid(property, (String) null);
+        Assert.assertEquals(false, result);
+    }
+
+
+    @Test
+    public void testIsPropertyInnerTypeValid() throws Exception {
+        PropertyOperation testSubject;
+        IComplexDefaultValue property = null;
+        Map<String, DataTypeDefinition> dataTypes = null;
+        ImmutablePair<String, Boolean> result;
+
+        // test 1
+        testSubject = createTestSubject();
+        property = null;
+        result = testSubject.isPropertyInnerTypeValid(property, dataTypes);
+    }
+
+
+    @Test
+    public void testGetAllPropertiesOfResourceInstanceOnlyPropertyDefId_1() throws Exception {
+        PropertyOperation testSubject;
+        String resourceInstanceUid = "";
+        NodeTypeEnum instanceNodeType = null;
+        Either<List<ComponentInstanceProperty>, JanusGraphOperationStatus> result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.getAllPropertiesOfResourceInstanceOnlyPropertyDefId(resourceInstanceUid, instanceNodeType);
+    }
+
+
+    @Test
+    public void testFindDefaultValueFromSecondPosition() throws Exception {
+        PropertyOperation testSubject;
+        List<String> pathOfComponentInstances = null;
+        String propertyUniqueId = "";
+        String defaultValue = "";
+        Either<String, JanusGraphOperationStatus> result;
+
+        // test 1
+        testSubject = createTestSubject();
+        pathOfComponentInstances = null;
+        result = testSubject.findDefaultValueFromSecondPosition(pathOfComponentInstances, propertyUniqueId,
+            defaultValue);
+    }
+
+
+    @Test
+    public void testUpdatePropertyByBestMatch() throws Exception {
+        PropertyOperation testSubject;
+        String propertyUniqueId = "";
+        ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
+        List<String> path = new ArrayList<>();
+        path.add("path");
+        instanceProperty.setPath(path);
+        Map<String, ComponentInstanceProperty> instanceIdToValue = new HashMap<>();
+        instanceIdToValue.put("123", instanceProperty);
+
+        // default test
+        testSubject = createTestSubject();
+        testSubject.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
+    }
+
+
+    @Test
+    public void testGetDataTypeByUid() throws Exception {
+        PropertyOperation testSubject;
+        String uniqueId = "";
+        Either<DataTypeDefinition, JanusGraphOperationStatus> result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.getDataTypeByUid(uniqueId);
+    }
+
+
+    @Test
+    public void testAddAndGetDataType() throws Exception {
+        final String dataTypeName = "myDataType";
+        DataTypeDefinition dataTypeDefinition = new DataTypeDefinition();
+        dataTypeDefinition.setName("myDataType");
+        Either<DataTypeDefinition, StorageOperationStatus> result;
+
         Mockito.doReturn(Either.left(new DataTypeData(dataTypeDefinition))).when(janusGraphGenericDao)
             .createNode(Mockito.any(), Mockito.eq(DataTypeData.class));
-        
+
         Mockito.doReturn(Either.left(new DataTypeData(dataTypeDefinition))).when(janusGraphGenericDao)
             .getNode(GraphPropertiesDictionary.NAME.getProperty(), dataTypeName, DataTypeData.class, null);
-        
+
         Mockito.doReturn(Either.left(Collections.EMPTY_LIST)).when(janusGraphGenericDao)
-            .getChildrenNodes(Mockito.anyString(), Mockito.anyString(), Mockito.eq(GraphEdgeLabels.PROPERTY), Mockito.eq(NodeTypeEnum.Property), Mockito.eq(PropertyData.class));
+            .getChildrenNodes(Mockito.anyString(), Mockito.anyString(), Mockito.eq(GraphEdgeLabels.PROPERTY), Mockito.eq(NodeTypeEnum.Property),
+                Mockito.eq(PropertyData.class));
 
-               result = propertyOperation.addDataType(dataTypeDefinition);
+        result = propertyOperation.addDataType(dataTypeDefinition);
         assertTrue(result.isLeft());
-        
+
         Mockito.doReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)).when(janusGraphGenericDao)
-            .getChild(Mockito.anyString(), Mockito.anyString(), Mockito.eq(GraphEdgeLabels.DERIVED_FROM), Mockito.eq(NodeTypeEnum.DataType), Mockito.eq(DataTypeData.class));
-               
-           result = propertyOperation.getDataTypeByName(dataTypeName, null, false);
-           assertTrue(result.isLeft());
-           
-           result = propertyOperation.getDataTypeByName(dataTypeName, null);
-           assertTrue(result.isLeft());
-           
+            .getChild(Mockito.anyString(), Mockito.anyString(), Mockito.eq(GraphEdgeLabels.DERIVED_FROM), Mockito.eq(NodeTypeEnum.DataType),
+                Mockito.eq(DataTypeData.class));
+
+        result = propertyOperation.getDataTypeByName(dataTypeName, null, false);
+        assertTrue(result.isLeft());
+
+        result = propertyOperation.getDataTypeByName(dataTypeName, null);
+        assertTrue(result.isLeft());
+
         Mockito.doReturn(Either.left(new DataTypeData(dataTypeDefinition))).when(janusGraphGenericDao)
             .getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), dataTypeName + ".datatype", DataTypeData.class);
-           
-           Either<DataTypeDefinition, JanusGraphOperationStatus> resultGetByUid = propertyOperation.getDataTypeByUid("myDataType.datatype");
-           assertTrue(resultGetByUid.isLeft());
-           
-           Either<Boolean, JanusGraphOperationStatus> resultIsDefinedDataType = propertyOperation.isDefinedInDataTypes(dataTypeName, null);
+
+        Either<DataTypeDefinition, JanusGraphOperationStatus> resultGetByUid = propertyOperation.getDataTypeByUid("myDataType.datatype");
+        assertTrue(resultGetByUid.isLeft());
+
+        Either<Boolean, JanusGraphOperationStatus> resultIsDefinedDataType = propertyOperation.isDefinedInDataTypes(dataTypeName, null);
         assertTrue(resultIsDefinedDataType.isLeft());
-       }
-       
-          @Test
-           public void testAddDataTypeToModel() throws Exception {
-               DataTypeDefinition dataTypeDefinition = new DataTypeDefinition();
-               dataTypeDefinition.setName("testName");
-               dataTypeDefinition.setModel("testModel");
-               Either<DataTypeDefinition, StorageOperationStatus> result;
-
-               Mockito.doReturn(Either.left(new DataTypeData(dataTypeDefinition))).when(janusGraphGenericDao)
-                .createNode(Mockito.any(), Mockito.eq(DataTypeData.class));
-               
-               Mockito.doReturn(Either.left(new GraphRelation())).when(janusGraphGenericDao)
-                .createRelation(Mockito.any(), Mockito.any(), Mockito.eq(GraphEdgeLabels.MODEL_ELEMENT), Mockito.any());
-
-               result = propertyOperation.addDataType(dataTypeDefinition);
-               assertTrue(result.isLeft());
-               
-               Mockito.doReturn(Either.left(new DataTypeData(dataTypeDefinition))).when(janusGraphGenericDao)
-                   .getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), "testModel.testName.datatype", DataTypeData.class);
-               
-               Mockito.doReturn(Either.left(Collections.EMPTY_LIST)).when(janusGraphGenericDao)
-                   .getChildrenNodes(Mockito.anyString(), Mockito.anyString(), Mockito.eq(GraphEdgeLabels.PROPERTY), Mockito.eq(NodeTypeEnum.Property), Mockito.eq(PropertyData.class));
-               
-               Mockito.doReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)).when(janusGraphGenericDao)
-                   .getChild(Mockito.anyString(), Mockito.anyString(), Mockito.eq(GraphEdgeLabels.DERIVED_FROM), Mockito.eq(NodeTypeEnum.DataType), Mockito.eq(DataTypeData.class));
-               
-               Either<DataTypeDefinition, JanusGraphOperationStatus> resultGetByUid = propertyOperation.getDataTypeByUid("testModel.testName.datatype");
-               assertTrue(resultGetByUid.isLeft());
-           }
-
-       
-       @Test
-       public void testGetDataTypeByUidWithoutDerivedDataTypes() throws Exception {
-               PropertyOperation testSubject;
-               String uniqueId = "";
-               Either<DataTypeDefinition, JanusGraphOperationStatus> result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.getDataTypeByUidWithoutDerivedDataTypes(uniqueId);
-       }
-
-       
-       @Test
-       public void testGetAllDataTypes() throws Exception {
-               PropertyOperation testSubject;
-               Either<Map<String, Map<String, DataTypeDefinition>>, JanusGraphOperationStatus> result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.getAllDataTypes();
-       }
-
-       
-       @Test
-       public void testCheckInnerType() throws Exception {
-               PropertyOperation testSubject;
-               PropertyDataDefinition propDataDef = new PropertyDataDefinition();
-               Either<String, JanusGraphOperationStatus> result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.checkInnerType(propDataDef);
-       }
-
-       @Test
-       public void testValidateAndUpdatePropertyValue() throws Exception {
-               PropertyOperation testSubject;
-               String propertyType = "";
-               String value = "";
-               boolean isValidate = false;
-               String innerType = "";
-               Map<String, DataTypeDefinition> dataTypes = null;
-               Either<Object, Boolean> result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.validateAndUpdatePropertyValue(propertyType, value, isValidate, innerType, dataTypes);
-       }
-
-       
-       @Test
-       public void testValidateAndUpdatePropertyValue_1() throws Exception {
-               PropertyOperation testSubject;
-               String propertyType = "";
-               String value = "";
-               String innerType = "";
-               Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
-               dataTypes.put("", new DataTypeDefinition());
-               Either<Object, Boolean> result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.validateAndUpdatePropertyValue(propertyType, value, innerType, dataTypes);
-       }
-
-       
-
-
-       
-       @Test
-       public void testAddPropertiesToElementType() throws Exception {
-               PropertyOperation testSubject;
-               String uniqueId = "";
-               NodeTypeEnum elementType = null;
-               List<PropertyDefinition> properties = null;
-               Either<Map<String, PropertyData>, JanusGraphOperationStatus> result;
-
-               // test 1
-               testSubject = createTestSubject();
-               properties = null;
-               result = testSubject.addPropertiesToElementType(uniqueId, elementType, properties);
-       }
-
-       
-       @Test
-       public void testUpdateDataType() throws Exception {
-               PropertyOperation testSubject;
-               DataTypeDefinition newDataTypeDefinition = new DataTypeDefinition();
-               DataTypeDefinition oldDataTypeDefinition = new DataTypeDefinition();
-               Either<DataTypeDefinition, StorageOperationStatus> result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.updateDataType(newDataTypeDefinition, oldDataTypeDefinition);
-       }
+    }
+
+    @Test
+    public void testAddDataTypeToModel() throws Exception {
+        DataTypeDefinition dataTypeDefinition = new DataTypeDefinition();
+        dataTypeDefinition.setName("testName");
+        dataTypeDefinition.setModel("testModel");
+        Either<DataTypeDefinition, StorageOperationStatus> result;
+
+        Mockito.doReturn(Either.left(new DataTypeData(dataTypeDefinition))).when(janusGraphGenericDao)
+            .createNode(Mockito.any(), Mockito.eq(DataTypeData.class));
+
+        Mockito.doReturn(Either.left(new GraphRelation())).when(janusGraphGenericDao)
+            .createRelation(Mockito.any(), Mockito.any(), Mockito.eq(GraphEdgeLabels.MODEL_ELEMENT), Mockito.any());
+
+        result = propertyOperation.addDataType(dataTypeDefinition);
+        assertTrue(result.isLeft());
+
+        Mockito.doReturn(Either.left(new DataTypeData(dataTypeDefinition))).when(janusGraphGenericDao)
+            .getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), "testModel.testName.datatype", DataTypeData.class);
+
+        Mockito.doReturn(Either.left(Collections.EMPTY_LIST)).when(janusGraphGenericDao)
+            .getChildrenNodes(Mockito.anyString(), Mockito.anyString(), Mockito.eq(GraphEdgeLabels.PROPERTY), Mockito.eq(NodeTypeEnum.Property),
+                Mockito.eq(PropertyData.class));
+
+        Mockito.doReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)).when(janusGraphGenericDao)
+            .getChild(Mockito.anyString(), Mockito.anyString(), Mockito.eq(GraphEdgeLabels.DERIVED_FROM), Mockito.eq(NodeTypeEnum.DataType),
+                Mockito.eq(DataTypeData.class));
+
+        Either<DataTypeDefinition, JanusGraphOperationStatus> resultGetByUid = propertyOperation.getDataTypeByUid("testModel.testName.datatype");
+        assertTrue(resultGetByUid.isLeft());
+    }
+
+
+    @Test
+    public void testGetDataTypeByUidWithoutDerivedDataTypes() throws Exception {
+        PropertyOperation testSubject;
+        String uniqueId = "";
+        Either<DataTypeDefinition, JanusGraphOperationStatus> result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.getDataTypeByUidWithoutDerivedDataTypes(uniqueId);
+    }
+
+
+    @Test
+    public void testGetAllDataTypes() throws Exception {
+        PropertyOperation testSubject;
+        Either<Map<String, Map<String, DataTypeDefinition>>, JanusGraphOperationStatus> result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.getAllDataTypes();
+    }
+
+
+    @Test
+    public void testCheckInnerType() throws Exception {
+        PropertyOperation testSubject;
+        PropertyDataDefinition propDataDef = new PropertyDataDefinition();
+        Either<String, JanusGraphOperationStatus> result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.checkInnerType(propDataDef);
+    }
+
+    @Test
+    public void testValidateAndUpdatePropertyValue() throws Exception {
+        PropertyOperation testSubject;
+        String propertyType = "";
+        String value = "";
+        boolean isValidate = false;
+        String innerType = "";
+        Map<String, DataTypeDefinition> dataTypes = null;
+        Either<Object, Boolean> result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.validateAndUpdatePropertyValue(propertyType, value, isValidate, innerType, dataTypes);
+    }
+
+
+    @Test
+    public void testValidateAndUpdatePropertyValue_1() throws Exception {
+        PropertyOperation testSubject;
+        String propertyType = "";
+        String value = "";
+        String innerType = "";
+        Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
+        dataTypes.put("", new DataTypeDefinition());
+        Either<Object, Boolean> result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.validateAndUpdatePropertyValue(propertyType, value, innerType, dataTypes);
+    }
+
+
+    @Test
+    public void testAddPropertiesToElementType() throws Exception {
+        PropertyOperation testSubject;
+        String uniqueId = "";
+        NodeTypeEnum elementType = null;
+        List<PropertyDefinition> properties = null;
+        Either<Map<String, PropertyData>, JanusGraphOperationStatus> result;
+
+        // test 1
+        testSubject = createTestSubject();
+        properties = null;
+        result = testSubject.addPropertiesToElementType(uniqueId, elementType, properties);
+    }
+
+
+    @Test
+    public void testUpdateDataType() throws Exception {
+        PropertyOperation testSubject;
+        DataTypeDefinition newDataTypeDefinition = new DataTypeDefinition();
+        DataTypeDefinition oldDataTypeDefinition = new DataTypeDefinition();
+        Either<DataTypeDefinition, StorageOperationStatus> result;
+
+        // default test
+        testSubject = createTestSubject();
+        result = testSubject.updateDataType(newDataTypeDefinition, oldDataTypeDefinition);
+    }
 }
index 5f8bde8..079874c 100644 (file)
@@ -26,6 +26,7 @@ import static org.junit.Assert.assertTrue;
 
 import fj.data.Either;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -302,10 +303,7 @@ public class RelationshipTypeOperationTest extends ModelTestBase {
         property2.setDescription("Number of (actual or virtual) CPUs associated with the Compute node.");
         property2.setType(ToscaType.INTEGER.name().toLowerCase());
         List<PropertyConstraint> constraints3 = new ArrayList<>();
-        List<Object> range = new ArrayList<>();
-        range.add("4");
-        range.add("1");
-        InRangeConstraint propertyConstraint3 = new InRangeConstraint(range);
+        InRangeConstraint propertyConstraint3 = new InRangeConstraint(Arrays.asList("1", "4"));
         constraints3.add(propertyConstraint3);
         property2.setConstraints(constraints3);
         return property2;
@@ -593,10 +591,7 @@ public class RelationshipTypeOperationTest extends ModelTestBase {
         propertyDefinition.setDescription(PROP + "_" + value);
         propertyDefinition.setType(ToscaType.INTEGER.name().toLowerCase());
         List<PropertyConstraint> constraints = new ArrayList<>();
-        List<Object> range = new ArrayList<>();
-        range.add("1");
-        range.add("4");
-        InRangeConstraint propertyConstraint = new InRangeConstraint(range);
+        InRangeConstraint propertyConstraint = new InRangeConstraint(Arrays.asList("1", "4"));
         constraints.add(propertyConstraint);
         propertyDefinition.setConstraints(constraints);
         Map<String, PropertyDefinition> propertiesMap = new HashMap<>();
index 103b15b..2048206 100644 (file)
@@ -176,7 +176,7 @@ class ToscaTypeTest {
     @Test
     void testConvert() throws Exception {
         ToscaType typeInt = ToscaType.INTEGER;
-        assertEquals(123l, typeInt.convert("123"));
+        assertEquals(123, typeInt.convert("123"));
 
         ToscaType typeBool = ToscaType.BOOLEAN;
         assertEquals(true, typeBool.convert("true"));
index 1491e05..f7223e8 100644 (file)
@@ -25,7 +25,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import org.junit.jupiter.api.Test;
 import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintValueDoNotMatchPropertyTypeException;
@@ -33,17 +33,11 @@ import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintValueDoN
 class InRangeConstraintTest {
 
     private InRangeConstraint createStringTestSubject() {
-        List<Object> validValues = new ArrayList<>();
-        validValues.add("test1");
-        validValues.add("test10");
-        return new InRangeConstraint(validValues);
+        return new InRangeConstraint(Arrays.asList("test1", "test10"));
     }
 
     private InRangeConstraint createIntegerTestSubject() {
-        List<Object> validValues = new ArrayList<>();
-        validValues.add(1);
-        validValues.add(10);
-        return new InRangeConstraint(validValues);
+        return new InRangeConstraint(Arrays.asList(1, 10));
     }
 
     @Test
@@ -59,10 +53,7 @@ class InRangeConstraintTest {
     @Test
     void testSetInRange() {
         InRangeConstraint testSubject = createStringTestSubject();
-        List<Object> validValues = new ArrayList<>();
-        validValues.add("test21");
-        validValues.add("test30");
-        testSubject.setInRange(validValues);
+        testSubject.setInRange(Arrays.asList("test21", "test30"));
         List<Object> result = testSubject.getInRange();
 
         assertEquals(2, result.size());
index 1e0eb4f..525bf88 100644 (file)
@@ -52,7 +52,7 @@ export class ConstraintsComponent implements OnInit {
       }
     }
     this.constraints = new Array();
-    if(changes.propertyConstraints.currentValue) {
+    if (changes.propertyConstraints && changes.propertyConstraints.currentValue) {
       changes.propertyConstraints.currentValue.forEach((constraint: any) => {
         this.constraints.push(this.getConstraintFromPropertyBEModel(constraint));
       });
@@ -341,4 +341,4 @@ export const ConstraintTypesMapping = {
 export interface Constraint {
   type:ConstraintTypes,
   value:any
-}
\ No newline at end of file
+}