aboutsummaryrefslogtreecommitdiffstats
path: root/model/utilities/src/test/java
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-09-10 17:05:36 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-09-10 17:07:47 +0100
commitd100854291559df1426ea1e64351872ae2d3867b (patch)
tree78baab90111307cd3d2460b2cca37e93a20ac9a3 /model/utilities/src/test/java
parent8f82d7adcb53b349e14d3b356bda03588a554f95 (diff)
Checkstyle changes for apex model
Fix checkstyle warnings in the apex mode and knock on changes. Issue-ID: POLICY-1034 Change-Id: I10537e4288e9cad5ef18165ed2cdc1d3ab3139c1 Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'model/utilities/src/test/java')
-rw-r--r--model/utilities/src/test/java/org/onap/policy/apex/model/utilities/AssertionsTest.java54
-rw-r--r--model/utilities/src/test/java/org/onap/policy/apex/model/utilities/CollectionUtilitiesTest.java12
-rw-r--r--model/utilities/src/test/java/org/onap/policy/apex/model/utilities/TextFileUtilsTest.java1
-rw-r--r--model/utilities/src/test/java/org/onap/policy/apex/model/utilities/TreeMapUtilsTest.java1
-rw-r--r--model/utilities/src/test/java/org/onap/policy/apex/model/utilities/json/JsonHandlerTest.java2
-rw-r--r--model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/ParserTest.java30
-rw-r--r--model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/TestKeyComparer.java1
-rw-r--r--model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/TestKeyedMapComparer.java16
8 files changed, 60 insertions, 57 deletions
diff --git a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/AssertionsTest.java b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/AssertionsTest.java
index db25147c3..d1040b64b 100644
--- a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/AssertionsTest.java
+++ b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/AssertionsTest.java
@@ -34,66 +34,60 @@ public class AssertionsTest {
@Test
public void testAssertions() {
Assertions.argumentNotFalse(true, "it is true");
-
+
try {
Assertions.argumentNotFalse(false, "it is false");
- }
- catch (IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
assertEquals("it is false", e.getMessage());
}
-
- Assertions.argumentNotFalse(true, ArithmeticException.class, "it is true");
-
+
+ Assertions.argumentOfClassNotFalse(true, ArithmeticException.class, "it is true");
+
try {
- Assertions.argumentNotFalse(false, ArithmeticException.class, "it is false");
- }
- catch (Exception e) {
+ Assertions.argumentOfClassNotFalse(false, ArithmeticException.class, "it is false");
+ } catch (Exception e) {
assertEquals("it is false", e.getMessage());
}
-
+
Assertions.argumentNotNull("Hello", "it is OK");
-
+
try {
Assertions.argumentNotNull(null, "it is null");
- }
- catch (IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
assertEquals("it is null", e.getMessage());
}
- Assertions.argumentNotNull(true, ArithmeticException.class, "it is OK");
-
+ Assertions.argumentOfClassNotNull(true, ArithmeticException.class, "it is OK");
+
try {
- Assertions.argumentNotNull(null, ArithmeticException.class, "it is null");
- }
- catch (Exception e) {
+ Assertions.argumentOfClassNotNull(null, ArithmeticException.class, "it is null");
+ } catch (Exception e) {
assertEquals("it is null", e.getMessage());
}
-
+
Assertions.assignableFrom(java.util.TreeMap.class, java.util.Map.class);
-
+
try {
Assertions.assignableFrom(java.util.Map.class, java.util.TreeMap.class);
- }
- catch (IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
assertEquals("java.util.Map is not an instance of java.util.TreeMap", e.getMessage());
}
-
+
Assertions.instanceOf("Hello", String.class);
-
+
try {
Assertions.instanceOf(100, String.class);
- }
- catch (IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
assertEquals("java.lang.Integer is not an instance of java.lang.String", e.getMessage());
}
-
+
Assertions.validateStringParameter("name", "MyName", "^M.*e$");
try {
Assertions.validateStringParameter("name", "MyName", "^M.*f$");
- }
- catch (IllegalArgumentException e) {
- assertEquals("parameter \"name\": value \"MyName\", does not match regular expression \"^M.*f$\"", e.getMessage());
+ } catch (IllegalArgumentException e) {
+ assertEquals("parameter \"name\": value \"MyName\", does not match regular expression \"^M.*f$\"",
+ e.getMessage());
}
}
}
diff --git a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/CollectionUtilitiesTest.java b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/CollectionUtilitiesTest.java
index e9ddc11bc..22c630bbf 100644
--- a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/CollectionUtilitiesTest.java
+++ b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/CollectionUtilitiesTest.java
@@ -20,7 +20,7 @@
package org.onap.policy.apex.model.utilities;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List;
@@ -33,17 +33,17 @@ public class CollectionUtilitiesTest {
@Test
public void testNullLists() {
int result = 0;
-
+
result = CollectionUtils.compareLists(null, null);
assertEquals(0, result);
- List<String> leftList = new ArrayList<String>();
+ List<String> leftList = new ArrayList<String>();
result = CollectionUtils.compareLists(leftList, null);
assertEquals(-1, result);
List<String> rightList = new ArrayList<String>();
-
+
result = CollectionUtils.compareLists(null, rightList);
assertEquals(1, result);
@@ -70,7 +70,7 @@ public class CollectionUtilitiesTest {
rightList.add("CCB");
result = CollectionUtils.compareLists(leftList, rightList);
assertEquals(-1, result);
-
+
leftList.remove(leftList.size() - 1);
rightList.remove(rightList.size() - 1);
result = CollectionUtils.compareLists(leftList, rightList);
@@ -80,7 +80,7 @@ public class CollectionUtilitiesTest {
rightList.add("CCA");
result = CollectionUtils.compareLists(leftList, rightList);
assertEquals(1, result);
-
+
leftList.remove(leftList.size() - 1);
rightList.remove(rightList.size() - 1);
result = CollectionUtils.compareLists(leftList, rightList);
diff --git a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/TextFileUtilsTest.java b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/TextFileUtilsTest.java
index c84ee8618..d03dc7135 100644
--- a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/TextFileUtilsTest.java
+++ b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/TextFileUtilsTest.java
@@ -29,6 +29,7 @@ import java.io.IOException;
import org.junit.Test;
/**
+ * Test text file utilities.
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TextFileUtilsTest {
diff --git a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/TreeMapUtilsTest.java b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/TreeMapUtilsTest.java
index 10a31e3b9..791a4dcf9 100644
--- a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/TreeMapUtilsTest.java
+++ b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/TreeMapUtilsTest.java
@@ -30,6 +30,7 @@ import org.junit.Test;
import org.onap.policy.apex.model.utilities.TreeMapUtils;
/**
+ * Test the tree map utilities.
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TreeMapUtilsTest {
diff --git a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/json/JsonHandlerTest.java b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/json/JsonHandlerTest.java
index c9db6c395..5242a4a04 100644
--- a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/json/JsonHandlerTest.java
+++ b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/json/JsonHandlerTest.java
@@ -43,7 +43,7 @@ public class JsonHandlerTest {
final byte[] bytes = jsonString.getBytes(StandardCharsets.UTF_8);
try (final InputStream inputStream = new ByteArrayInputStream(bytes);) {
- final JSONHandler<OverTheMoonObject> objUnderTest = new JSONHandler<>();
+ final JsonHandler<OverTheMoonObject> objUnderTest = new JsonHandler<>();
final OverTheMoonObject actualObject = objUnderTest.read(OverTheMoonObject.class, inputStream);
assertEquals(VALUE, actualObject.name);
diff --git a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/ParserTest.java b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/ParserTest.java
index a979afddc..892f68ce1 100644
--- a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/ParserTest.java
+++ b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/ParserTest.java
@@ -32,14 +32,14 @@ import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.TokenStream;
import org.junit.Test;
-
/**
+ * Test Java parsing.
*/
public class ParserTest {
@Test
public void testParser() {
- final CharStream stream = CharStreams.fromString(
- "java.util.Map<java.util.List<java.lang.Integer>,java.util.Set<java.lang.String>>");
+ final CharStream stream = CharStreams
+ .fromString("java.util.Map<java.util.List<java.lang.Integer>,java.util.Set<java.lang.String>>");
final TokenStream tokenStream = new CommonTokenStream(new ParametrizedTypeLexer(stream));
final ParametrizedTypeParser parser = new ParametrizedTypeParser(tokenStream);
@@ -47,23 +47,23 @@ public class ParserTest {
parser.setErrorHandler(new BailErrorStrategy());
parser.setBuildParseTree(true);
assertEquals("java.util.Map<java.util.List<java.lang.Integer>, java.util.Set<java.lang.String>>",
- parser.type().value.build().getTypeName());
+ parser.type().value.build().getTypeName());
}
@Test
public void testBuilder() throws IllegalArgumentException {
- String t = "java.util.Map<java.util.List<java.lang.Integer>,java.util.Set<java.lang.String>>";
- Type ret = TypeBuilder.build(t);
+ String typeString = "java.util.Map<java.util.List<java.lang.Integer>,java.util.Set<java.lang.String>>";
+ Type ret = TypeBuilder.build(typeString);
assertEquals("java.util.Map<java.util.List<java.lang.Integer>, java.util.Set<java.lang.String>>",
- ret.getTypeName());
+ ret.getTypeName());
assertEquals(java.util.Map.class, TypeBuilder.getJavaTypeClass(ret));
final Type[] args = TypeBuilder.getJavaTypeParameters(ret);
assertEquals("java.util.List<java.lang.Integer>", args[0].getTypeName());
assertEquals("java.util.Set<java.lang.String>", args[1].getTypeName());
- t = "java.lang.Integer";
- ret = TypeBuilder.build(t);
+ typeString = "java.lang.Integer";
+ ret = TypeBuilder.build(typeString);
assertEquals(java.lang.Integer.class, TypeBuilder.getJavaTypeClass(ret));
}
@@ -74,17 +74,19 @@ public class ParserTest {
TypeBuilder.build(null);
fail("Test should throw exception");
} catch (final IllegalArgumentException e) {
- assertEquals(
- "Blank type string passed to org.onap.policy.apex.model.utilities.typeutils.TypeBuilder.build(String type)",
- e.getMessage());
+ assertEquals("Blank type string passed to "
+ + "org.onap.policy.apex.model.utilities.typeutils.TypeBuilder.build(String type)",
+ e.getMessage());
}
try {
TypeBuilder.build("org.zooby.Wooby");
fail("Test should throw exception");
} catch (final IllegalArgumentException e) {
- assertEquals(e.getMessage(), "Failed to build type 'org.zooby.Wooby': java.lang.IllegalArgumentException: "
- + "Class 'org.zooby.Wooby' not found. Also looked for a class called 'java.lang.org.zooby.Wooby'");
+ assertEquals(e.getMessage(),
+ "Failed to build type 'org.zooby.Wooby': java.lang.IllegalArgumentException: "
+ + "Class 'org.zooby.Wooby' not found. "
+ + "Also looked for a class called 'java.lang.org.zooby.Wooby'");
}
assertEquals(TypeBuilder.getJavaTypeClass("java.lang.String"), String.class);
diff --git a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/TestKeyComparer.java b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/TestKeyComparer.java
index c2e84c6fb..538028de0 100644
--- a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/TestKeyComparer.java
+++ b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/TestKeyComparer.java
@@ -28,6 +28,7 @@ import org.onap.policy.apex.model.utilities.comparison.KeyComparer;
import org.onap.policy.apex.model.utilities.comparison.KeyDifference;
/**
+ * Test key comparisons.
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TestKeyComparer {
diff --git a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/TestKeyedMapComparer.java b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/TestKeyedMapComparer.java
index 33b8101a1..de71ea164 100644
--- a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/TestKeyedMapComparer.java
+++ b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/TestKeyedMapComparer.java
@@ -31,6 +31,8 @@ import org.onap.policy.apex.model.utilities.comparison.KeyedMapComparer;
import org.onap.policy.apex.model.utilities.comparison.KeyedMapDifference;
/**
+ * Test key map comparisons.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TestKeyedMapComparer {
@@ -50,21 +52,23 @@ public class TestKeyedMapComparer {
rightMap.put("E", "EEEEE");
rightMap.put("F", "FFFFF");
rightMap.put("G", "G");
-
- KeyedMapDifference<String, String> kmComparedSame = new KeyedMapComparer<String, String>().compareMaps(leftMap, leftMap);
- KeyedMapDifference<String, String> kmComparedDiff = new KeyedMapComparer<String, String>().compareMaps(leftMap, rightMap);
-
+
+ KeyedMapDifference<String, String> kmComparedSame = new KeyedMapComparer<String, String>().compareMaps(leftMap,
+ leftMap);
+ KeyedMapDifference<String, String> kmComparedDiff = new KeyedMapComparer<String, String>().compareMaps(leftMap,
+ rightMap);
+
assertTrue(kmComparedSame.getIdenticalValues().equals(leftMap));
assertEquals(1, kmComparedDiff.getLeftOnly().size());
assertEquals(3, kmComparedDiff.getRightOnly().size());
assertEquals(2, kmComparedDiff.getDifferentValues().size());
assertEquals(1, kmComparedDiff.getIdenticalValues().size());
-
+
assertNotNull(kmComparedSame.asString(true, true));
assertNotNull(kmComparedSame.asString(true, false));
assertNotNull(kmComparedSame.asString(false, false));
assertNotNull(kmComparedSame.asString(false, true));
-
+
assertNotNull(kmComparedDiff.asString(true, true));
assertNotNull(kmComparedDiff.asString(true, false));
assertNotNull(kmComparedDiff.asString(false, false));