Java Utililty Methods Assert Equal

List of utility methods to do Assert Equal

Description

The list of methods to do Assert Equal are organized into topic(s).

Method

voidassertEquals(Object expected, Object actual)
assert Equals
if (!expected.equals(actual)) {
    throw new RuntimeException(String.format("Values didn't match, epected: %s actual: %s",
            expected.toString(), actual.toString()));
booleanassertEquals(Object o1, Object o2)
assert Equals
return o1 == null && o2 == null ? true : (o1 != null ? o1.equals(o2) : false);
voidassertEquals(Object obj1, Object obj2, String errMsg)
assert Equals
if (obj1 == null) {
    assertNull(obj2, errMsg);
    return;
if (!obj1.equals(obj2)) {
    throw new RuntimeException(errMsg);
voidassertEquals(Object obj1, Object obj2, String message)
Solleva una @link(IllegalArgumentException) con message message in caso di object non null
if (!obj1.equals(obj2)) {
    throw new IllegalArgumentException(message);
voidassertEquals(Object val1, Object val2)
assert Equals
assertEquals(null, val1, val2);
voidassertEquals(String expected, String actual)
assert Equals
if (expected == null && actual != null || expected != null && !expected.equals(actual)) {
    throw new AssertionError("Expected: " + coalesce(expected) + ", actual: " + coalesce(actual));
System.out.println("Passed: " + coalesce(actual));
voidassertEquals(String expected, String current)
This method is used in the static block to checks whether the field costCenter is available.
if (!expected.equals(current)) {
    throw new RuntimeException("Assertion failed. Expected: <" + expected + "> but was: <" + current + ">");
voidassertEquals(String message, Object expected, Object actual)
Asserts that two objects are equal.
if (expected == null && actual == null)
    return;
if (expected != null && isEquals(expected, actual))
    return;
failNotEquals(message, expected, actual);
voidassertEquals(T expected, T actual)
assert Equals
if (expected == null) {
    if (actual != null) {
        throw new AssertionError("Not equals. expected is null, but actual is [" + actual + "]");
if (!expected.equals(actual)) {
    throw new AssertionError("Not equals. expected is [" + expected + "], but actual is [" + actual + "]");
voidassertEqualsAny(Object obj1, Object[] objects, String errMsg)
assert Equals Any
if (null == objects) {
    throw new RuntimeException(errMsg);
for (Object obj2 : objects) {
    if (obj1 == null) {
        if (obj2 == null) {
            return;
        continue;
    if (obj1.equals(obj2)) {
        return;
throw new RuntimeException(errMsg);