1 package org.pojomatic.testng; 2 3 import org.pojomatic.Pojomatic; 4 import org.pojomatic.test.AssertUtils; 5 6 /** 7 * Pojomatic-related TestNG-style assertion methods useful for writing tests. 8 * @see org.testng.Assert 9 */ 10 public class PojomaticAssert { 11 12 /** 13 * Asserts that two objects are either both null or are equal according to 14 * {@link Object#equals(Object)}. If not, an {@code AssertionError} is thrown. If the objects are 15 * not equal, but the types of two objects are compatible for equality, then the differences as 16 * determined by {@link Pojomatic#diff(Object, Object)} are included in the failure message. 17 * 18 * @param expected the expected object 19 * @param actual the object which should be tested to equal the expected object 20 * @throws AssertionError if the objects are not equal, with details of the differences 21 * included in the message 22 * @see #assertEqualsWithDiff(Object, Object, String) 23 */ 24 public static void assertEqualsWithDiff(Object actual, Object expected) { 25 assertEqualsWithDiff(actual, expected, null); 26 } 27 28 /** 29 * Asserts that two objects are either both null or are equal according to 30 * {@link Object#equals(Object)}. If not, an {@code AssertionError} is thrown. If the objects are 31 * not equal, but the types of two objects are compatible for equality, then the differences as 32 * determined by {@link Pojomatic#diff(Object, Object)} are included in the failure message. 33 * 34 * @param expected the expected object 35 * @param actual the object which should be tested to equal the expected object 36 * @param message an optional message provided along with the diff if the objects are not equal 37 * @throws AssertionError if the objects are not equal, with details of the differences 38 * included in the message 39 */ 40 public static void assertEqualsWithDiff(Object actual, Object expected, String message) { 41 //the arguments are passed as follows according to display order for a potential error message 42 AssertUtils.assertEquals(message, expected, actual); 43 } 44 45 private PojomaticAssert() {} 46 }