summaryrefslogtreecommitdiffstats
path: root/catalog-model/src
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-model/src')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java41
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaType.java12
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtil.java2
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraint.java31
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java7
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java1151
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/RelationshipTypeOperationTest.java11
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/ToscaTypeTest.java2
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraintTest.java17
9 files changed, 639 insertions, 635 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 3d2e701a34..fa6df00d5a 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
@@ -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;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaType.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaType.java
index 1f942a9352..e4e229a910 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaType.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaType.java
@@ -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);
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtil.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtil.java
index 61f069a45f..fee828c1be 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtil.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtil.java
@@ -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:
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 4f362b9dfb..9330c8c106 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,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 + ">");
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java
index 39f9118337..12e5431c28 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java
@@ -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;
}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java
index 3f78ff0b03..a1f863057e 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java
@@ -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);
+ }
}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/RelationshipTypeOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/RelationshipTypeOperationTest.java
index 5f8bde8090..079874c59c 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/RelationshipTypeOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/RelationshipTypeOperationTest.java
@@ -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<>();
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/ToscaTypeTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/ToscaTypeTest.java
index 103b15b79d..204820698b 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/ToscaTypeTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/ToscaTypeTest.java
@@ -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"));
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 1491e0547d..f7223e8949 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
@@ -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());