|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectsk.baka.tools.test.Assert
public class Assert
Adds several array-comparing asserts.
| Constructor Summary | |
|---|---|
Assert()
|
|
| Method Summary | ||
|---|---|---|
static void |
assertArrayEquals(Object actual,
Object expected)
Asserts that two arrays contain the same elements in the same order. |
|
static void |
assertArrayEquals(Object actual,
Object expected,
String message)
Asserts that two arrays contain the same elements in the same order. |
|
static void |
assertArrayEqualsNoOrder(Object actual,
Object expected)
Asserts that two arrays contain the same elements in no particular order. |
|
static void |
assertArrayEqualsNoOrder(Object actual,
Object expected,
String message)
Asserts that two arrays contain the same elements in no particular order. |
|
static
|
assertBeansEquals(T got,
T expected)
Verifies that given beans are equal. |
|
static
|
assertBeansEquals(T got,
T expected,
JavaUtils.IEqualsComparator comparator)
Verifies that given beans are equal. |
|
static
|
assertCorrectEquals(T object,
T differentInstance,
T differentValues,
T extendingClass)
Tests given object for correct Object.equals(java.lang.Object) contract. |
|
static void |
assertCorrectEqualsForJpaBean(Class<?> clazz,
Object id1,
Object id2)
Verifies that given JPA bean has a correct implementation of Object.equals(java.lang.Object) and Object.hashCode() methods. |
|
static void |
assertUtilityClass(Class<?> clazz)
Checks that given class is really an utility class - it has a private zero-arg constructor, does not have any other constructors and the constructor throws AssertionError. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Assert()
| Method Detail |
|---|
public static void assertArrayEquals(Object actual,
Object expected,
String message)
Assert#assertEquals(java.lang.Object[], java.lang.Object[]) and supports more
array types. The array type must match before any comparison will occur. For example, the function will fail when comparing
e.g. Integer[] and Collection
actual - the actual array, must not be null. Accepts Collections and arrays of both primitive and object types.expected - the expected array, must not be null. Accepts Collections and arrays of both primitive and object types.message - an optional message
public static void assertArrayEquals(Object actual,
Object expected)
Assert#assertEquals(java.lang.Object[], java.lang.Object[]).
actual - the actual array, must not be null. Accepts arrays of both primitive and object types and supports more
array types. The array type must match before any comparison will occur. For example, the function will fail when comparing
e.g. Integer[] and Collectionexpected - the expected array, must not be null. Accepts arrays of both primitive and object types.
public static void assertArrayEqualsNoOrder(Object actual,
Object expected)
Assert#assertEqualsNoOrder(java.lang.Object[], java.lang.Object[], java.lang.String) and supports more array types.
The array type must match before any comparison will occur. For example, the function will fail when comparing
e.g. Integer[] and Collection
actual - the actual valueexpected - the expected value
public static void assertArrayEqualsNoOrder(Object actual,
Object expected,
String message)
Assert#assertEqualsNoOrder(java.lang.Object[], java.lang.Object[], java.lang.String) and supports more array types.
The array type must match before any comparison will occur. For example, the function will fail when comparing
e.g. Integer[] and CollectionHashSet.
actual - the actual valueexpected - the expected valuemessage - the assertion error message
public static <T> void assertCorrectEquals(T object,
T differentInstance,
T differentValues,
T extendingClass)
Object.equals(java.lang.Object) contract. Inspired by the
Gargoylesoftware's EqualsTester. Example:final Object a = new Foo(4); // original object
final Object b = new Foo(4); // another object that has the same values as the original
final Object c = new Foo(5); // another object with different values
final Object d = new Foo(4) {}; // a subclass of Foo with the same values as the original
new EqualsTester(a, b, c, d);
Throws AssertionError on failure.
T - the object typeobject - the original objectdifferentInstance - another object that has the same values as the original. May be the same instance as the object if the object is meant to be a singleton.differentValues - another object with different values. May be null if the object is meant to be a singleton.extendingClass - a subclass of Foo with the same values as the original. May be null if T is final.public static void assertUtilityClass(Class<?> clazz)
clazz - the class to construct, must not be null.
public static void assertCorrectEqualsForJpaBean(Class<?> clazz,
Object id1,
Object id2)
Object.equals(java.lang.Object) and Object.hashCode() methods.
Requires the CGLIB library.
clazz - the JPA bean class. The bean is instantiated automatically using a zero-arg constructor. The bean is expected to have
a method "setId()" which takes given id as a single parameter.id1 - a first ID to feed to the JPA bean entity.id2 - second ID to be set to a JPA bean instance. Must not be equal to the first ID.
public static <T> void assertBeansEquals(T got,
T expected)
equal.
T - the bean type.got - what we got.expected - what was expected.
public static <T> void assertBeansEquals(T got,
T expected,
JavaUtils.IEqualsComparator comparator)
equal.
T - the bean type.got - what we got.expected - what was expected.comparator - the comparator to use
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||