aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model/src/test/java/org
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2022-12-09 12:36:05 +0000
committerMichael Morris <michael.morris@est.tech>2022-12-20 16:54:20 +0000
commitf995db01ee95606b6cded82822a73435ebc190c8 (patch)
tree1279aee5baa9005ab86ca6f77eca32c554ae149d /catalog-model/src/test/java/org
parent7e08a2976d34066412af14fe633eecde3ce19fc7 (diff)
Add support comparable type constraints for scalar values
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Change-Id: I57234399f23721506d308dfb8351067845ebe892 Issue-ID: SDC-4305
Diffstat (limited to 'catalog-model/src/test/java/org')
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/ToscaTypeTest.java400
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtilTest.java66
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/ValidValuesConstraintTest.java31
3 files changed, 329 insertions, 168 deletions
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 d2bfc375a2..103b15b79d 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
@@ -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.
@@ -21,8 +21,10 @@
package org.openecomp.sdc.be.model.tosca;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Date;
import java.util.List;
@@ -30,123 +32,279 @@ import java.util.Map;
import org.junit.jupiter.api.Test;
import org.openecomp.sdc.be.model.tosca.version.Version;
+class ToscaTypeTest {
+
+ @Test
+ void testIsValidValueBoolean() throws Exception {
+ ToscaType toscaType = ToscaType.BOOLEAN;
+
+ assertFalse(toscaType.isValidValue(""));
+ assertTrue(toscaType.isValidValue("false"));
+ assertTrue(toscaType.isValidValue("FalSe"));
+ assertTrue(toscaType.isValidValue("true"));
+ assertTrue(toscaType.isValidValue("TrUe"));
+ }
+
+ @Test
+ void testIsValidValueFloat() throws Exception {
+ ToscaType toscaType = ToscaType.FLOAT;
+
+ assertFalse(toscaType.isValidValue("float"));
+ assertTrue(toscaType.isValidValue("1.2534"));
+ assertTrue(toscaType.isValidValue("1.2534f"));
+ }
+
+ @Test
+ void testIsValidValueString() throws Exception {
+ ToscaType toscaType = ToscaType.STRING;
+
+ assertTrue(toscaType.isValidValue("string"));
+ assertTrue(toscaType.isValidValue("1 string"));
+ assertTrue(toscaType.isValidValue("2 s_t_r_i_n_g"));
+ }
+
+ @Test
+ void testIsValidValueInteger() throws Exception {
+ ToscaType toscaType = ToscaType.INTEGER;
+
+ assertFalse(toscaType.isValidValue("integer"));
+ assertTrue(toscaType.isValidValue("1235"));
+ }
+
+ @Test
+ void testIsValidValueTimestamp() throws Exception {
+ ToscaType toscaType = ToscaType.TIMESTAMP;
+
+ assertFalse(toscaType.isValidValue("timestamp"));
+ assertTrue(toscaType.isValidValue("2001-12-14t21:59:43.10-05:00"));
+ assertFalse(toscaType.isValidValue("30 juin 2009 07:03:47"));
+ }
+
+ @Test
+ void testIsValidValueVersion() throws Exception {
+ ToscaType toscaType = ToscaType.VERSION;
+
+ assertFalse(toscaType.isValidValue("version"));
+ assertTrue(toscaType.isValidValue("1.2"));
+ assertTrue(toscaType.isValidValue("1.2.3"));
+ assertTrue(toscaType.isValidValue("1.2-3"));
+ }
+
+ @Test
+ void testIsValidValueList() throws Exception {
+ ToscaType toscaType = ToscaType.LIST;
+
+ assertFalse(toscaType.isValidValue("list"));
+ assertTrue(toscaType.isValidValue("[\"color\",\"type\"]"));
+ }
+
+ @Test
+ void testIsValidValueMap() throws Exception {
+ ToscaType toscaType = ToscaType.MAP;
+
+ assertFalse(toscaType.isValidValue("map"));
+ assertTrue(toscaType.isValidValue("{\"color\":\"yellow\",\"type\":\"renault\"}"));
+ }
+
+ @Test
+ void testNotValidValueScalarUnit() {
+ ToscaType testSubject = ToscaType.SCALAR_UNIT;
+
+ assertFalse(testSubject.isValidValue("5"));
+ }
+
+ @Test
+ void testIsValidValueScalarUnitSize() throws Exception {
+ ToscaType testSubject = ToscaType.SCALAR_UNIT_SIZE;
+
+ assertTrue(testSubject.isValidValue("5 TiB"));
+ assertFalse(testSubject.isValidValue("5"));
+ }
+
+ @Test
+ void testIsValidValueScalarUnitTime() throws Exception {
+ ToscaType testSubject = ToscaType.SCALAR_UNIT_TIME;
+
+ assertTrue(testSubject.isValidValue("5 d"));
+ assertFalse(testSubject.isValidValue("a5 sz"));
+ }
+
+ @Test
+ void testIsValidValueScalarUnitBitrate() throws Exception {
+ ToscaType testSubject = ToscaType.SCALAR_UNIT_BITRATE;
+
+ assertTrue(testSubject.isValidValue("5 TiBps"));
+ assertFalse(testSubject.isValidValue("5 bps5"));
+ }
+
+ @Test
+ void testIsValidValueScalarUnitFrequency() throws Exception {
+ ToscaType testSubject = ToscaType.SCALAR_UNIT_FREQUENCY;
+
+ assertTrue(testSubject.isValidValue("5 MHz"));
+ assertFalse(testSubject.isValidValue("5"));
+ }
+
+ @Test
+ void testGetToscaType() throws Exception {
+ ToscaType toscaType = ToscaType.MAP;
+
+ assertEquals(ToscaType.getToscaType("map"), toscaType);
+ assertNull(ToscaType.getToscaType(null));
+ assertNull(ToscaType.getToscaType("InvalidType"));
+ }
+
+ @Test
+ void testIsPrimitiveType() throws Exception {
+ assertFalse(ToscaType.isPrimitiveType(null));
+ assertFalse(ToscaType.isPrimitiveType("map"));
+ assertFalse(ToscaType.isPrimitiveType("list"));
+ assertFalse(ToscaType.isPrimitiveType("String"));
+ assertTrue(ToscaType.isPrimitiveType("string"));
+ assertTrue(ToscaType.isPrimitiveType("integer"));
+ }
+
+ @Test
+ void testIsCollectionType() throws Exception {
+ assertTrue(ToscaType.isCollectionType("map"));
+ assertTrue(ToscaType.isCollectionType("list"));
+ assertFalse(ToscaType.isCollectionType("Map"));
+ assertFalse(ToscaType.isCollectionType("string"));
+ assertFalse(ToscaType.isCollectionType("integer"));
+ }
+
+ @Test
+ void testConvert() throws Exception {
+ ToscaType typeInt = ToscaType.INTEGER;
+ assertEquals(123l, typeInt.convert("123"));
+
+ ToscaType typeBool = ToscaType.BOOLEAN;
+ assertEquals(true, typeBool.convert("true"));
+
+ ToscaType typeStr = ToscaType.STRING;
+ assertEquals("str", typeStr.convert("str"));
+
+ ToscaType typeFloat = ToscaType.FLOAT;
+ assertTrue(typeFloat.convert("1.2357f") instanceof Float);
+
+ ToscaType typeTimestamp = ToscaType.TIMESTAMP;
+ assertTrue(typeTimestamp.convert("Jun 30, 2009 7:03:47 AM") instanceof Date);
+ assertThrows(IllegalArgumentException.class, () -> typeTimestamp.convert(""));
+
+ ToscaType typeVersion = ToscaType.VERSION;
+ assertTrue(typeVersion.convert("1.2.3.5.6") instanceof Version);
+
+ ToscaType typeList = ToscaType.LIST;
+ assertTrue(typeList.convert("[\"str1\",\"str2\"]") instanceof List);
+ assertThrows(IllegalArgumentException.class, () -> typeList.convert(""));
+
+ ToscaType typeMap = ToscaType.MAP;
+ assertTrue(typeMap.convert("{\"color\":\"yellow\",\"type\":\"renault\"}") instanceof Map);
+ assertThrows(IllegalArgumentException.class, () -> typeMap.convert(""));
+
+ ToscaType typeScalarUnit = ToscaType.SCALAR_UNIT;
+ assertNull(typeScalarUnit.convert(""));
+
+ }
+
+ @Test
+ void testConvertScalarUnitTime() {
+ ToscaType testSubject = ToscaType.SCALAR_UNIT_TIME;
+ assertTrue(testSubject.convert("5d") instanceof Long);
+ assertTrue(testSubject.convert("4 h") instanceof Long);
+ assertTrue(testSubject.convert(" 3 m ") instanceof Long);
+ assertTrue(testSubject.convert("9.5s") instanceof Long);
+ assertTrue(testSubject.convert("90 ms") instanceof Long);
+ assertTrue(testSubject.convert("55.44 us") instanceof Long);
+ assertTrue(testSubject.convert("111ns") instanceof Long);
+
+ assertThrows(IllegalArgumentException.class, () -> testSubject.convert("5z.ms"));
+ assertThrows(IllegalArgumentException.class, () -> testSubject.convert("5"));
+ assertThrows(IllegalArgumentException.class, () -> testSubject.convert("a5 ms"));
+ assertThrows(IllegalArgumentException.class, () -> testSubject.convert("5 msZ"));
+ }
+
+ @Test
+ void testConvertScalarUnitSize() {
+ ToscaType testSubject = ToscaType.SCALAR_UNIT_SIZE;
+ assertTrue(testSubject.convert("5 TiB") instanceof Long);
+ assertTrue(testSubject.convert("4 TB") instanceof Long);
+ assertTrue(testSubject.convert("31 GiB") instanceof Long);
+ assertTrue(testSubject.convert("19.5 GB") instanceof Long);
+ assertTrue(testSubject.convert("90 MiB") instanceof Long);
+ assertTrue(testSubject.convert("55.44 MB") instanceof Long);
+ assertTrue(testSubject.convert("111 KiB") instanceof Long);
+ assertTrue(testSubject.convert("123. kB") instanceof Long);
+ assertTrue(testSubject.convert("0.9 B") instanceof Long);
+
+ assertThrows(IllegalArgumentException.class, () -> testSubject.convert("5z.MB"));
+ assertThrows(IllegalArgumentException.class, () -> testSubject.convert("5"));
+ assertThrows(IllegalArgumentException.class, () -> testSubject.convert("a5 TB"));
+ assertThrows(IllegalArgumentException.class, () -> testSubject.convert("5 TBz"));
+ }
+
+ @Test
+ void testConvertScalarUnitFrequency() {
+ ToscaType testSubject = ToscaType.SCALAR_UNIT_FREQUENCY;
+ assertTrue(testSubject.convert("5 GHz") instanceof Long);
+ assertTrue(testSubject.convert("41 MHz") instanceof Long);
+ assertTrue(testSubject.convert("319 kHz") instanceof Long);
+ assertTrue(testSubject.convert("19.5 Hz") instanceof Long);
+
+ assertThrows(IllegalArgumentException.class, () -> testSubject.convert("5z.GHz"));
+ assertThrows(IllegalArgumentException.class, () -> testSubject.convert("5"));
+ assertThrows(IllegalArgumentException.class, () -> testSubject.convert("a5 Hz"));
+ assertThrows(IllegalArgumentException.class, () -> testSubject.convert("5 Hza"));
+ }
+
+ @Test
+ void testConvertScalarUnitBitrate() {
+ ToscaType testSubject = ToscaType.SCALAR_UNIT_BITRATE;
+ assertTrue(testSubject.convert("5 TiBps") instanceof Long);
+ assertTrue(testSubject.convert("41 TBps") instanceof Long);
+ assertTrue(testSubject.convert("319 GiBps") instanceof Long);
+ assertTrue(testSubject.convert("19.5 GBps") instanceof Long);
+ assertTrue(testSubject.convert("90 MiBps") instanceof Long);
+ assertTrue(testSubject.convert("55.44 MBps") instanceof Long);
+ assertTrue(testSubject.convert("111 KiBps") instanceof Long);
+ assertTrue(testSubject.convert("123. KBps") instanceof Long);
+ assertTrue(testSubject.convert("0.9 Bps") instanceof Long);
+ assertTrue(testSubject.convert("0.9 Tibps") instanceof Long);
+ assertTrue(testSubject.convert("0.9 Tbps") instanceof Long);
+ assertTrue(testSubject.convert("0.9 Gibps") instanceof Long);
+ assertTrue(testSubject.convert("0.9 Gbps") instanceof Long);
+ assertTrue(testSubject.convert("0.9 Mibps") instanceof Long);
+ assertTrue(testSubject.convert("0.9 Mbps") instanceof Long);
+ assertTrue(testSubject.convert("0.9 Kibps") instanceof Long);
+ assertTrue(testSubject.convert("0.9 Kbps") instanceof Long);
+ assertTrue(testSubject.convert("0.9 bps") instanceof Long);
+
+ assertThrows(IllegalArgumentException.class, () -> testSubject.convert("5z.Mbps"));
+ assertThrows(IllegalArgumentException.class, () -> testSubject.convert("5"));
+ assertThrows(IllegalArgumentException.class, () -> testSubject.convert("a5 MBps"));
+ assertThrows(IllegalArgumentException.class, () -> testSubject.convert("5 bps5"));
+ }
+
+ @Test
+ void testIsValueTypeValid() {
+ ToscaType testSubject = ToscaType.SCALAR_UNIT_BITRATE;
+ assertTrue(testSubject.isValueTypeValid(""));
+
+ testSubject = ToscaType.LIST;
+ assertTrue(testSubject.isValueTypeValid(""));
+
+ testSubject = ToscaType.INTEGER;
+ assertTrue(testSubject.isValueTypeValid(1));
+
+ testSubject = ToscaType.FLOAT;
+ assertTrue(testSubject.isValueTypeValid(2.3f));
+
+ testSubject = ToscaType.BOOLEAN;
+ assertTrue(testSubject.isValueTypeValid(true));
+
+ testSubject = ToscaType.SCALAR_UNIT;
+ assertFalse(testSubject.isValueTypeValid(""));
+
+ }
-public class ToscaTypeTest {
-
- @Test
- public void testIsValidValueBoolean() throws Exception {
- ToscaType toscaType = ToscaType.BOOLEAN;;
-
- assertTrue(!toscaType.isValidValue(""));
- assertTrue(toscaType.isValidValue("false"));
- assertTrue(toscaType.isValidValue("FalSe"));
- assertTrue(toscaType.isValidValue("true"));
- assertTrue(toscaType.isValidValue("TrUe"));
- }
-
- @Test
- public void testIsValidValueFloat() throws Exception {
- ToscaType toscaType = ToscaType.FLOAT;;
-
- assertTrue(!toscaType.isValidValue("float"));
- assertTrue(toscaType.isValidValue("1.2534"));
- assertTrue(toscaType.isValidValue("1.2534f"));
- }
-
- @Test
- public void testIsValidValueInteger() throws Exception {
- ToscaType toscaType = ToscaType.INTEGER;;
-
- assertTrue(!toscaType.isValidValue("integer"));
- assertTrue(toscaType.isValidValue("1235"));
- }
-
- @Test
- public void testIsValidValueTimestamp() throws Exception {
- ToscaType toscaType = ToscaType.TIMESTAMP;;
-
- assertTrue(!toscaType.isValidValue("timestamp"));
- assertTrue(toscaType.isValidValue("2001-12-14t21:59:43.10-05:00"));
- assertTrue(!toscaType.isValidValue("30 juin 2009 07:03:47"));
- }
-
- @Test
- public void testIsValidValueVersion() throws Exception {
- ToscaType toscaType = ToscaType.VERSION;;
-
- assertTrue(!toscaType.isValidValue("version"));
- assertTrue(toscaType.isValidValue("1.2"));
- assertTrue(toscaType.isValidValue("1.2.3"));
- assertTrue(toscaType.isValidValue("1.2-3"));
- }
-
- @Test
- public void testIsValidValueList() throws Exception {
- ToscaType toscaType = ToscaType.LIST;;
-
- assertTrue(!toscaType.isValidValue("list"));
- assertTrue(toscaType.isValidValue("[\"color\",\"type\"]"));
- }
-
- @Test
- public void testIsValidValueMap() throws Exception {
- ToscaType toscaType = ToscaType.MAP;;
-
- assertTrue(!toscaType.isValidValue("map"));
- assertTrue(toscaType.isValidValue("{\"color\":\"yellow\",\"type\":\"renault\"}"));
- }
-
- @Test
- public void testGetToscaType() throws Exception {
- ToscaType toscaType = ToscaType.MAP;;
-
- assertEquals(ToscaType.getToscaType("map"), toscaType);
- assertNull(ToscaType.getToscaType(null));
- assertNull(ToscaType.getToscaType("InvalidType"));
- }
-
- @Test
- public void testIsPrimitiveType() throws Exception {
- assertTrue(!ToscaType.isPrimitiveType("map"));
- assertTrue(!ToscaType.isPrimitiveType("list"));
- assertTrue(!ToscaType.isPrimitiveType("String"));
- assertTrue(ToscaType.isPrimitiveType("string"));
- assertTrue(ToscaType.isPrimitiveType("integer"));
- }
-
- @Test
- public void testIsCollectionType() throws Exception {
- assertTrue(ToscaType.isCollectionType("map"));
- assertTrue(ToscaType.isCollectionType("list"));
- assertTrue(!ToscaType.isCollectionType("Map"));
- assertTrue(!ToscaType.isCollectionType("string"));
- assertTrue(!ToscaType.isCollectionType("integer"));
- }
-
- @Test
- public void testConvert() throws Exception {
- ToscaType typeStr = ToscaType.STRING;
- assertEquals(typeStr.convert("str"), "str");
-
- ToscaType typeFloat = ToscaType.FLOAT;
- assertTrue(typeFloat.convert("1.2357f") instanceof Float);
-
- ToscaType typeTimestamp = ToscaType.TIMESTAMP;
- assertTrue(typeTimestamp.convert("Jun 30, 2009 7:03:47 AM") instanceof Date);
-
- ToscaType typeVersion = ToscaType.VERSION;
- assertTrue(typeVersion.convert("1.2.3.5.6") instanceof Version);
-
- ToscaType typeList = ToscaType.LIST;
- assertTrue(typeList.convert("[\"str1\",\"str2\"]") instanceof List);
-
- ToscaType typeMap = ToscaType.MAP;
- assertTrue(typeMap.convert("{\"color\":\"yellow\",\"type\":\"renault\"}") instanceof Map);
- }
-
- @Test
- public void testToString() throws Exception {
- ToscaType testToscaType = ToscaType.SCALAR_UNIT;
- assertEquals(testToscaType.toString(), "scalar_unit");
- }
}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtilTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtilTest.java
index 7f7e6980e6..99987800d3 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtilTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtilTest.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.
@@ -20,39 +20,47 @@
package org.openecomp.sdc.be.model.tosca.constraints;
-import org.junit.Test;
-import org.openecomp.sdc.be.model.tosca.ToscaType;
-
-public class ConstraintUtilTest {
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
- @Test
- public void testCheckStringType() throws Exception {
- ToscaType propertyType = ToscaType.STRING;
+import com.fasterxml.jackson.core.type.TypeReference;
+import java.util.List;
+import org.junit.jupiter.api.Test;
+import org.openecomp.sdc.be.model.tosca.ToscaType;
+import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintValueDoNotMatchPropertyTypeException;
- // default test
- ConstraintUtil.checkStringType(propertyType);
- }
+class ConstraintUtilTest {
-
- @Test
- public void testCheckComparableType() throws Exception {
- ToscaType propertyType = ToscaType.INTEGER;
+ @Test
+ void testCheckStringType() throws Exception {
+ assertDoesNotThrow(() -> ConstraintUtil.checkStringType(ToscaType.STRING));
+ assertThrows(ConstraintValueDoNotMatchPropertyTypeException.class, () -> ConstraintUtil.checkStringType(ToscaType.SCALAR_UNIT));
+ }
- // default test
- ConstraintUtil.checkComparableType(propertyType);
- }
+ @Test
+ void testCheckComparableType() throws Exception {
+ assertDoesNotThrow(() -> ConstraintUtil.checkComparableType(ToscaType.INTEGER));
+ assertThrows(ConstraintValueDoNotMatchPropertyTypeException.class, () -> ConstraintUtil.checkComparableType(ToscaType.SCALAR_UNIT));
+ }
-
- @Test
- public void testConvertToComparable() throws Exception {
- ToscaType propertyType = ToscaType.BOOLEAN;
- String value = "";
- Comparable result;
+ @Test
+ void testConvertToComparable() throws Exception {
+ assertTrue(ConstraintUtil.convertToComparable(ToscaType.BOOLEAN, "true") instanceof Comparable);
+ assertThrows(IllegalArgumentException.class, () -> ConstraintUtil.convertToComparable(ToscaType.SCALAR_UNIT, "value"));
+ }
- // default test
- result = ConstraintUtil.convertToComparable(propertyType, value);
- }
+ @Test
+ void testParseToCollection() throws Exception {
+ List<Object> list = ConstraintUtil.parseToCollection("[\"color\",\"type\"]", new TypeReference<List<Object>>() {
+ });
+ assertTrue(list instanceof List);
+ assertEquals(2, list.size());
-
+ assertThrows(ConstraintValueDoNotMatchPropertyTypeException.class,
+ () -> ConstraintUtil.parseToCollection("", new TypeReference<List<Object>>() {
+ }));
+ }
}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/ValidValuesConstraintTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/ValidValuesConstraintTest.java
index 01450e2632..1e03513aa4 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/ValidValuesConstraintTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/ValidValuesConstraintTest.java
@@ -30,8 +30,7 @@ import java.util.List;
import org.junit.jupiter.api.Test;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintValueDoNotMatchPropertyTypeException;
-
-public class ValidValuesConstraintTest {
+class ValidValuesConstraintTest {
private ValidValuesConstraint createStringTestSubject() {
List<Object> validValues = new ArrayList<>();
@@ -52,7 +51,7 @@ public class ValidValuesConstraintTest {
}
@Test
- public void testGetValidValues() {
+ void testGetValidValues() {
ValidValuesConstraint testSubject = createStringTestSubject();
List<Object> result = testSubject.getValidValues();
@@ -62,7 +61,7 @@ public class ValidValuesConstraintTest {
}
@Test
- public void testSetValidValues() {
+ void testSetValidValues() {
ValidValuesConstraint testSubject = createStringTestSubject();
List<Object> validValues = new ArrayList<>();
validValues.add("test5");
@@ -79,35 +78,31 @@ public class ValidValuesConstraintTest {
}
@Test
- public void testValidateValueTypeStringTrue() throws ConstraintValueDoNotMatchPropertyTypeException {
+ void testValidateValueTypeStringTrue() throws ConstraintValueDoNotMatchPropertyTypeException {
ValidValuesConstraint testSubject = createStringTestSubject();
- Boolean validTypes = testSubject.validateValueType("string");
- assertTrue(validTypes);
+ assertTrue(testSubject.validateValueType("string"));
}
@Test
- public void testValidateValueTypeStringFalse() throws ConstraintValueDoNotMatchPropertyTypeException {
+ void testValidateValueTypeStringFalse() throws ConstraintValueDoNotMatchPropertyTypeException {
ValidValuesConstraint testSubject = createStringTestSubject();
- Boolean validTypes = testSubject.validateValueType("integer");
- assertFalse(validTypes);
+ assertFalse(testSubject.validateValueType("integer"));
}
@Test
- public void testValidateValueTypeIntegerTrue() throws ConstraintValueDoNotMatchPropertyTypeException {
+ void testValidateValueTypeIntegerTrue() throws ConstraintValueDoNotMatchPropertyTypeException {
ValidValuesConstraint testSubject = createIntegerTestSubject();
- Boolean validTypes = testSubject.validateValueType("integer");
- assertTrue(validTypes);
+ assertTrue(testSubject.validateValueType("integer"));
}
@Test
- public void testValidateValueTypeIntegerFalse() throws ConstraintValueDoNotMatchPropertyTypeException {
+ void testValidateValueTypeIntegerFalse() throws ConstraintValueDoNotMatchPropertyTypeException {
ValidValuesConstraint testSubject = createIntegerTestSubject();
- Boolean validTypes = testSubject.validateValueType("string");
- assertFalse(validTypes);
+ assertFalse(testSubject.validateValueType("string"));
}
@Test
- public void testChangeStringConstraintValueTypeToIntegerThrow() {
+ void testChangeStringConstraintValueTypeToIntegerThrow() {
String propertyType = "integer";
ValidValuesConstraint testSubject = createStringTestSubject();
Exception exception = assertThrows(ConstraintValueDoNotMatchPropertyTypeException.class, () -> {
@@ -122,7 +117,7 @@ public class ValidValuesConstraintTest {
}
@Test
- public void testChangeIntegerConstraintValueTypeToString() throws ConstraintValueDoNotMatchPropertyTypeException {
+ void testChangeIntegerConstraintValueTypeToString() throws ConstraintValueDoNotMatchPropertyTypeException {
ValidValuesConstraint testSubject = createIntegerTestSubject();
testSubject.changeConstraintValueTypeTo("string");