+ assertEquals(errorMessage, Double.valueOf(expected),
+ Double.valueOf(actual));
+ }
+
+ /**
+ * Check that 2 {@link List}s are equals.
+ *
+ * @param errorMessage
+ * the error message to display if they differ
+ * @param expected
+ * the expected value
+ * @param actual
+ * the actual value
+ *
+ * @throws AssertException
+ * in case they differ
+ */
+ public void assertEquals(List<?> expected, List<?> actual)
+ throws AssertException {
+
+ assertEquals("The 2 lists don't contain the same number of items",
+ expected.size(), actual.size());
+
+ int size = expected.size();
+ for (int i = 0; i < size; i++) {
+ assertEquals("Line " + i + " (0-based) is not correct",
+ expected.get(i), actual.get(i));
+ }
+ }
+
+ /**
+ * Check that given {@link Object} is not NULL.
+ *
+ * @param errorMessage
+ * the error message to display if it is NULL
+ * @param actual
+ * the actual value
+ *
+ * @throws AssertException
+ * in case they differ
+ */
+ public void assertNotNull(String errorMessage, Object actual)
+ throws AssertException {
+ if (actual == null) {
+ String defaultReason = String.format("" //
+ + "Assertion failed!%n" //
+ + "Object should not have been NULL");
+
+ if (errorMessage == null) {
+ throw new AssertException(defaultReason);
+ }
+
+ throw new AssertException(errorMessage, new AssertException(
+ defaultReason));
+ }
+ }
+
+ /**
+ * Generate the default assert message for 2 different values that were
+ * supposed to be equals.
+ *
+ * @param expected
+ * the expected value
+ * @param actual
+ * the actual value
+ *
+ * @return the message
+ */
+ public static String generateAssertMessage(Object expected, Object actual) {
+ return String.format("" //
+ + "Assertion failed!%n" //
+ + "Expected value: [%s]%n" //
+ + "Actual value: [%s]", expected, actual);