diff options
author | vasraz <vasyl.razinkov@est.tech> | 2023-02-01 17:56:35 +0000 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2023-02-02 12:05:26 +0000 |
commit | e61d26cb2a74813b526e10864af4d73f04df2650 (patch) | |
tree | 972a74ffc58c0b24da5af586bbbcec1f66150d97 /catalog-model/src/test/java | |
parent | 5da0b3c1454ac557e0b01eb678abaf882fb08243 (diff) |
Fix 'in_range constraints missing from TOSCA template'-bug
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Change-Id: Icec2183849a8852621ec98f3ca1d94ac7c4dae31
Issue-ID: SDC-4357
Diffstat (limited to 'catalog-model/src/test/java')
5 files changed, 584 insertions, 604 deletions
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()); |