|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.assertj.core.internal.Objects
public class Objects
Reusable assertions for Object
s.
Nested Class Summary | |
---|---|
static class |
Objects.ByFieldsComparison
|
Constructor Summary | |
---|---|
Objects(ComparisonStrategy comparisonStrategy)
|
Method Summary | ||
---|---|---|
boolean |
areEqualToComparingOnlyGivenFields(Object actual,
Object other,
String... fields)
|
|
boolean |
areEqualToIgnoringGivenFields(Object actual,
Object other,
String... fields)
|
|
void |
assertDoesNotHaveSameClassAs(AssertionInfo info,
Object actual,
Object other)
Verifies that the actual value does not have the same class as the given object. |
|
void |
assertEqual(AssertionInfo info,
Object actual,
Object expected)
Asserts that two objects are equal. |
|
void |
assertHasSameClassAs(AssertionInfo info,
Object actual,
Object other)
Verifies that the actual value has the same class as the given object. |
|
|
assertIsEqualToComparingOnlyGivenFields(AssertionInfo info,
A actual,
A other,
String... fields)
Assert that the given object is lenient equals to other object by comparing given fields value only. |
|
|
assertIsEqualToIgnoringGivenFields(AssertionInfo info,
A actual,
A other,
String... fields)
Assert that the given object is lenient equals to the other by comparing all fields (including inherited fields) unless given ignored ones. |
|
void |
assertIsExactlyInstanceOf(AssertionInfo info,
Object actual,
Class<?> type)
Verifies that the actual value is exactly a instance of given type. |
|
void |
assertIsIn(AssertionInfo info,
Object actual,
Iterable<?> values)
Asserts that the given object is present in the given collection. |
|
void |
assertIsIn(AssertionInfo info,
Object actual,
Object[] values)
Asserts that the given object is present in the given array. |
|
void |
assertIsInstanceOf(AssertionInfo info,
Object actual,
Class<?> type)
Verifies that the given object is an instance of the given type. |
|
void |
assertIsInstanceOfAny(AssertionInfo info,
Object actual,
Class<?>[] types)
Verifies that the given object is an instance of any of the given types. |
|
|
assertIsLenientEqualsToIgnoringNullFields(AssertionInfo info,
A actual,
A other)
Assert that the given object is lenient equals by ignoring null fields value on other object (including inherited fields). |
|
void |
assertIsNotExactlyInstanceOf(AssertionInfo info,
Object actual,
Class<?> type)
Verifies that the actual value is not exactly a instance of given type. |
|
void |
assertIsNotIn(AssertionInfo info,
Object actual,
Iterable<?> values)
Asserts that the given object is not present in the given collection. |
|
void |
assertIsNotIn(AssertionInfo info,
Object actual,
Object[] values)
Asserts that the given object is not present in the given array. |
|
void |
assertIsNotInstanceOf(AssertionInfo info,
Object actual,
Class<?> type)
Verifies that the given object is not an instance of the given type. |
|
void |
assertIsNotInstanceOfAny(AssertionInfo info,
Object actual,
Class<?>[] types)
Verifies that the given object is not an instance of any of the given types. |
|
void |
assertIsNotOfAnyClassIn(AssertionInfo info,
Object actual,
Class<?>[] types)
Verifies that the actual value type is not in given types. |
|
void |
assertIsOfAnyClassIn(AssertionInfo info,
Object actual,
Class<?>[] types)
Verifies that the actual value type is in given types. |
|
void |
assertNotEqual(AssertionInfo info,
Object actual,
Object other)
Asserts that two objects are not equal. |
|
void |
assertNotNull(AssertionInfo info,
Object actual)
Asserts that the given object is not null . |
|
void |
assertNotSame(AssertionInfo info,
Object actual,
Object other)
Asserts that two objects do not refer to the same object. |
|
void |
assertNull(AssertionInfo info,
Object actual)
Asserts that the given object is null . |
|
void |
assertSame(AssertionInfo info,
Object actual,
Object expected)
Asserts that two objects refer to the same object. |
|
Comparator<?> |
getComparator()
|
|
ComparisonStrategy |
getComparisonStrategy()
|
|
static Objects |
instance()
Returns the singleton instance of this class based on StandardComparisonStrategy . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Objects(ComparisonStrategy comparisonStrategy)
Method Detail |
---|
public static Objects instance()
StandardComparisonStrategy
.
StandardComparisonStrategy
.public Comparator<?> getComparator()
public ComparisonStrategy getComparisonStrategy()
public void assertIsInstanceOf(AssertionInfo info, Object actual, Class<?> type)
info
- contains information about the assertion.actual
- the given object.type
- the type to check the given object against.
NullPointerException
- if the given type is null
.
AssertionError
- if the given object is null
.
AssertionError
- if the given object is not an instance of the given type.public void assertIsInstanceOfAny(AssertionInfo info, Object actual, Class<?>[] types)
info
- contains information about the assertion.actual
- the given object.types
- the types to check the given object against.
NullPointerException
- if the given array is null
.
IllegalArgumentException
- if the given array is empty.
NullPointerException
- if the given array has null
elements.
AssertionError
- if the given object is null
.
AssertionError
- if the given object is not an instance of any of the given types.public void assertIsNotInstanceOf(AssertionInfo info, Object actual, Class<?> type)
info
- contains information about the assertion.actual
- the given object.type
- the type to check the given object against.
NullPointerException
- if the given type is null
.
AssertionError
- if the given object is null
.
AssertionError
- if the given object is an instance of the given type.public void assertIsNotInstanceOfAny(AssertionInfo info, Object actual, Class<?>[] types)
info
- contains information about the assertion.actual
- the given object.types
- the types to check the given object against.
NullPointerException
- if the given array is null
.
IllegalArgumentException
- if the given array is empty.
NullPointerException
- if the given array has null
elements.
AssertionError
- if the given object is null
.
AssertionError
- if the given object is an instance of any of the given types.public void assertHasSameClassAs(AssertionInfo info, Object actual, Object other)
info
- contains information about the assertion.actual
- the given object.
AssertionError
- if the actual has not the same type has the given object.
NullPointerException
- if the actual value is null.
NullPointerException
- if the given object is null.public void assertDoesNotHaveSameClassAs(AssertionInfo info, Object actual, Object other)
info
- contains information about the assertion.actual
- the given object.other
- the object to check type against.
AssertionError
- if the actual has the same type has the given object.
NullPointerException
- if the actual value is null.
NullPointerException
- if the given object is null.public void assertIsExactlyInstanceOf(AssertionInfo info, Object actual, Class<?> type)
info
- contains information about the assertion.actual
- the given object.type
- the type to check the actual value against.
AssertionError
- if the actual is not exactly a instance of given type.
NullPointerException
- if the actual value is null.
NullPointerException
- if the given object is null.public void assertIsNotExactlyInstanceOf(AssertionInfo info, Object actual, Class<?> type)
info
- contains information about the assertion.actual
- the given object.type
- the type to check the actual value against.
AssertionError
- if the actual is exactly a instance of given type.
NullPointerException
- if the actual value is null.
NullPointerException
- if the given object is null.public void assertIsOfAnyClassIn(AssertionInfo info, Object actual, Class<?>[] types)
info
- contains information about the assertion.actual
- the given object.types
- the types to check the actual value against.
AssertionError
- if the actual value type is in given type.
NullPointerException
- if the actual value is null.
NullPointerException
- if the given types is null.public void assertIsNotOfAnyClassIn(AssertionInfo info, Object actual, Class<?>[] types)
info
- contains information about the assertion.actual
- the given object.types
- the types to check the actual value against.
AssertionError
- if the actual value type is in given type.
NullPointerException
- if the actual value is null.
NullPointerException
- if the given types is null.public void assertEqual(AssertionInfo info, Object actual, Object expected)
info
- contains information about the assertion.actual
- the "actual" object.expected
- the "expected" object.
AssertionError
- if actual
is not equal to expected
. This method will throw a
org.junit.ComparisonFailure
instead if JUnit is in the classpath and the given objects are not
equal.public void assertNotEqual(AssertionInfo info, Object actual, Object other)
info
- contains information about the assertion.actual
- the given object.other
- the object to compare actual
to.
AssertionError
- if actual
is equal to other
.public void assertNull(AssertionInfo info, Object actual)
null
.
info
- contains information about the assertion.actual
- the given object.
AssertionError
- if the given object is not null
.public void assertNotNull(AssertionInfo info, Object actual)
null
.
info
- contains information about the assertion.actual
- the given object.
AssertionError
- if the given object is null
.public void assertSame(AssertionInfo info, Object actual, Object expected)
info
- contains information about the assertion.actual
- the given object.expected
- the expected object.
AssertionError
- if the given objects do not refer to the same object.public void assertNotSame(AssertionInfo info, Object actual, Object other)
info
- contains information about the assertion.actual
- the given object.other
- the object to compare actual
to.
AssertionError
- if the given objects refer to the same object.public void assertIsIn(AssertionInfo info, Object actual, Object[] values)
info
- contains information about the assertion.actual
- the given object.values
- the given array.
NullPointerException
- if the given array is null
.
IllegalArgumentException
- if the given array is empty.
AssertionError
- if the given object is not present in the given array.public void assertIsNotIn(AssertionInfo info, Object actual, Object[] values)
info
- contains information about the assertion.actual
- the given object.values
- the given array.
NullPointerException
- if the given array is null
.
IllegalArgumentException
- if the given array is empty.
AssertionError
- if the given object is present in the given array.public void assertIsIn(AssertionInfo info, Object actual, Iterable<?> values)
info
- contains information about the assertion.actual
- the given object.values
- the given iterable.
NullPointerException
- if the given collection is null
.
IllegalArgumentException
- if the given collection is empty.
AssertionError
- if the given object is not present in the given collection.public void assertIsNotIn(AssertionInfo info, Object actual, Iterable<?> values)
info
- contains information about the assertion.actual
- the given object.values
- the given collection.
NullPointerException
- if the given iterable is null
.
IllegalArgumentException
- if the given collection is empty.
AssertionError
- if the given object is present in the given collection.public <A> void assertIsLenientEqualsToIgnoringNullFields(AssertionInfo info, A actual, A other)
info
- contains information about the assertion.actual
- the given object.other
- the object to compare actual
to.
NullPointerException
- if the actual type is null
.
NullPointerException
- if the other type is null
.
AssertionError
- if the actual and the given object are not lenient equals.
AssertionError
- if the other object is not an instance of the actual type.public <A> void assertIsEqualToComparingOnlyGivenFields(AssertionInfo info, A actual, A other, String... fields)
info
- contains information about the assertion.actual
- the given object.other
- the object to compare actual
to.fields
- accepted fields
NullPointerException
- if the other type is null
.
AssertionError
- if actual is null
.
AssertionError
- if the actual and the given object are not lenient equals.
AssertionError
- if the other object is not an instance of the actual type.
IntrospectionError
- if a field does not exist in actual.public <A> void assertIsEqualToIgnoringGivenFields(AssertionInfo info, A actual, A other, String... fields)
info
- contains information about the assertion.actual
- the given object.other
- the object to compare actual
to.fields
- the fields to ignore in comparison
NullPointerException
- if the other type is null
.
AssertionError
- if actual is null
.
AssertionError
- if the actual and the given object are not lenient equals.
AssertionError
- if the other object is not an instance of the actual type.public boolean areEqualToIgnoringGivenFields(Object actual, Object other, String... fields)
public boolean areEqualToComparingOnlyGivenFields(Object actual, Object other, String... fields)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |