package org.gbif.registry;

import org.gbif.api.model.registry.LenientEquals;

import static org.junit.Assert.fail;

/**
 * Provides a lenient equals assertion, borrowing shamelessly from {@link org.junit.Assert}.
 */
public class LenientAssert {

  /**
   * Asserts that two objects are leniently equal. If they are not, an {@link AssertionError} is thrown with the given
   * message. If <code>expected</code> and <code>actual</code> are <code>null</code>,
   * they are considered equal.
   * 
   * @param message the identifying message for the {@link AssertionError} (<code>null</code> okay)
   * @param expected expected value
   * @param actual actual value
   */
  public static <T, L extends LenientEquals<T>> void assertLenientEquals(String message, L expected, T actual) {
    if (lenientlyEqualRegardingNull(expected, actual)) {
      return;
    } else {
      failNotEquals(message, expected, actual);
    }
  }

  private static <T, L extends LenientEquals<T>> boolean lenientlyEqualRegardingNull(L expected, T actual) {
    if (expected == null) {
      return actual == null;
    }

    return expected.lenientEquals(actual);
  }

  static private void failNotEquals(String message, Object expected,
    Object actual) {
    fail(format(message, expected, actual));
  }

  static String format(String message, Object expected, Object actual) {
    String formatted = "";
    if (message != null && !message.equals("")) {
      formatted = message + " ";
    }
    String expectedString = String.valueOf(expected);
    String actualString = String.valueOf(actual);
    if (expectedString.equals(actualString)) {
      return formatted + "expected: "
        + formatClassAndValue(expected, expectedString)
        + " but was: " + formatClassAndValue(actual, actualString);
    } else {
      return formatted + "expected:<" + expectedString + "> but was:<"
        + actualString + ">";
    }
  }

  private static String formatClassAndValue(Object value, String valueString) {
    String className = value == null ? "null" : value.getClass().getName();
    return className + "<" + valueString + ">";
  }

}

@@ -492,10 +492,9 @@
    *
- 
 %0A
+
    *
@@ -784,16 +784,17 @@
     if (
+!
 lenientl
@@ -838,35 +838,8 @@
 ) %7B%0A
-      return;%0A    %7D else %7B%0A
     
@@ -1182,20 +1182,16 @@
 xpected,
-%0A   
  Object 
@@ -1246,26 +1246,34 @@
 ual));%0A  %7D%0A%0A
-
   
+private 
 static Strin

Fix LenientAssert