Package org.fest.assertions.internal
Class Objects
- java.lang.Object
 - 
- org.fest.assertions.internal.Objects
 
 
- 
public class Objects extends java.lang.ObjectReusable assertions forObjects.- Author:
 - Yvonne Wang, Alex Ruiz, Nicolas François, Mikhail Mazursky
 
 
- 
- 
Constructor Summary
Constructors Constructor Description Objects(ComparisonStrategy comparisonStrategy) 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassertDoesNotHaveSameClassAs(AssertionInfo info, java.lang.Object actual, java.lang.Object other)Verifies that the actual value does not have the same class as the given object.voidassertEqual(AssertionInfo info, java.lang.Object actual, java.lang.Object expected)Asserts that two objects are equal.voidassertHasSameClassAs(AssertionInfo info, java.lang.Object actual, java.lang.Object other)Verifies that the actual value has the same class as the given object.voidassertIsExactlyInstanceOf(AssertionInfo info, java.lang.Object actual, java.lang.Class<?> type)Verifies that the actual value is exactly a instance of given type.<A> voidassertIsIn(AssertionInfo info, A actual, java.lang.Iterable<? extends A> values)Asserts that the given object is present in the given collection.voidassertIsIn(AssertionInfo info, java.lang.Object actual, java.lang.Object[] values)Asserts that the given object is present in the given array.voidassertIsInstanceOf(AssertionInfo info, java.lang.Object actual, java.lang.Class<?> type)Verifies that the given object is an instance of the given type.voidassertIsInstanceOfAny(AssertionInfo info, java.lang.Object actual, java.lang.Class<?>[] types)Verifies that the given object is an instance of any of the given types.<A> voidassertIsLenientEqualsToByAcceptingFields(AssertionInfo info, A actual, A other, java.lang.String... fields)Assert that the given object is lenient equals to other object by comparing given fields value only.<A> voidassertIsLenientEqualsToByIgnoringFields(AssertionInfo info, A actual, A other, java.lang.String... fields)Assert that the given object is lenient equals to the other by comparing all fields (including inherited fields) unless given ignored ones.<A> voidassertIsLenientEqualsToByIgnoringNullFields(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).voidassertIsNotExactlyInstanceOf(AssertionInfo info, java.lang.Object actual, java.lang.Class<?> type)Verifies that the actual value is not exactly a instance of given type.<A> voidassertIsNotIn(AssertionInfo info, A actual, java.lang.Iterable<? extends A> values)Asserts that the given object is not present in the given collection.voidassertIsNotIn(AssertionInfo info, java.lang.Object actual, java.lang.Object[] values)Asserts that the given object is not present in the given array.voidassertIsNotInstanceOf(AssertionInfo info, java.lang.Object actual, java.lang.Class<?> type)Verifies that the given object is not an instance of the given type.voidassertIsNotInstanceOfAny(AssertionInfo info, java.lang.Object actual, java.lang.Class<?>[] types)Verifies that the given object is not an instance of any of the given types.voidassertIsNotOfAnyClassIn(AssertionInfo info, java.lang.Object actual, java.lang.Class<?>[] types)Verifies that the actual value type is not in given types.voidassertIsOfAnyClassIn(AssertionInfo info, java.lang.Object actual, java.lang.Class<?>[] types)Verifies that the actual value type is in given types.voidassertNotEqual(AssertionInfo info, java.lang.Object actual, java.lang.Object other)Asserts that two objects are not equal.voidassertNotNull(AssertionInfo info, java.lang.Object actual)Asserts that the given object is notnull.voidassertNotSame(AssertionInfo info, java.lang.Object actual, java.lang.Object other)Asserts that two objects do not refer to the same object.voidassertNull(AssertionInfo info, java.lang.Object actual)Asserts that the given object isnull.voidassertSame(AssertionInfo info, java.lang.Object actual, java.lang.Object expected)Asserts that two objects refer to the same object.java.util.Comparator<?>getComparator()static Objectsinstance()Returns the singleton instance of this class based onStandardComparisonStrategy. 
 - 
 
- 
- 
Constructor Detail
- 
Objects
public Objects(ComparisonStrategy comparisonStrategy)
 
 - 
 
- 
Method Detail
- 
instance
public static Objects instance()
Returns the singleton instance of this class based onStandardComparisonStrategy.- Returns:
 - the singleton instance of this class based on 
StandardComparisonStrategy. 
 
- 
getComparator
public java.util.Comparator<?> getComparator()
 
- 
assertIsInstanceOf
public void assertIsInstanceOf(AssertionInfo info, java.lang.Object actual, java.lang.Class<?> type)
Verifies that the given object is an instance of the given type.- Parameters:
 info- contains information about the assertion.actual- the given object.type- the type to check the given object against.- Throws:
 java.lang.NullPointerException- if the given type isnull.java.lang.AssertionError- if the given object isnull.java.lang.AssertionError- if the given object is not an instance of the given type.
 
- 
assertIsInstanceOfAny
public void assertIsInstanceOfAny(AssertionInfo info, java.lang.Object actual, java.lang.Class<?>[] types)
Verifies that the given object is an instance of any of the given types.- Parameters:
 info- contains information about the assertion.actual- the given object.types- the types to check the given object against.- Throws:
 java.lang.NullPointerException- if the given array isnull.java.lang.IllegalArgumentException- if the given array is empty.java.lang.NullPointerException- if the given array hasnullelements.java.lang.AssertionError- if the given object isnull.java.lang.AssertionError- if the given object is not an instance of any of the given types.
 
- 
assertIsNotInstanceOf
public void assertIsNotInstanceOf(AssertionInfo info, java.lang.Object actual, java.lang.Class<?> type)
Verifies that the given object is not an instance of the given type.- Parameters:
 info- contains information about the assertion.actual- the given object.type- the type to check the given object against.- Throws:
 java.lang.NullPointerException- if the given type isnull.java.lang.AssertionError- if the given object isnull.java.lang.AssertionError- if the given object is an instance of the given type.
 
- 
assertIsNotInstanceOfAny
public void assertIsNotInstanceOfAny(AssertionInfo info, java.lang.Object actual, java.lang.Class<?>[] types)
Verifies that the given object is not an instance of any of the given types.- Parameters:
 info- contains information about the assertion.actual- the given object.types- the types to check the given object against.- Throws:
 java.lang.NullPointerException- if the given array isnull.java.lang.IllegalArgumentException- if the given array is empty.java.lang.NullPointerException- if the given array hasnullelements.java.lang.AssertionError- if the given object isnull.java.lang.AssertionError- if the given object is an instance of any of the given types.
 
- 
assertHasSameClassAs
public void assertHasSameClassAs(AssertionInfo info, java.lang.Object actual, java.lang.Object other)
Verifies that the actual value has the same class as the given object.- Parameters:
 info- contains information about the assertion.actual- the given object.- Throws:
 java.lang.AssertionError- if the actual has not the same type has the given object.java.lang.NullPointerException- if the actual value is null.java.lang.NullPointerException- if the given object is null.
 
- 
assertDoesNotHaveSameClassAs
public void assertDoesNotHaveSameClassAs(AssertionInfo info, java.lang.Object actual, java.lang.Object other)
Verifies that the actual value does not have the same class as the given object.- Parameters:
 info- contains information about the assertion.actual- the given object.other- the object to check type against.- Throws:
 java.lang.AssertionError- if the actual has the same type has the given object.java.lang.NullPointerException- if the actual value is null.java.lang.NullPointerException- if the given object is null.
 
- 
assertIsExactlyInstanceOf
public void assertIsExactlyInstanceOf(AssertionInfo info, java.lang.Object actual, java.lang.Class<?> type)
Verifies that the actual value is exactly a instance of given type.- Parameters:
 info- contains information about the assertion.actual- the given object.type- the type to check the actual value against.- Throws:
 java.lang.AssertionError- if the actual is not exactly a instance of given type.java.lang.NullPointerException- if the actual value is null.java.lang.NullPointerException- if the given object is null.
 
- 
assertIsNotExactlyInstanceOf
public void assertIsNotExactlyInstanceOf(AssertionInfo info, java.lang.Object actual, java.lang.Class<?> type)
Verifies that the actual value is not exactly a instance of given type.- Parameters:
 info- contains information about the assertion.actual- the given object.type- the type to check the actual value against.- Throws:
 java.lang.AssertionError- if the actual is exactly a instance of given type.java.lang.NullPointerException- if the actual value is null.java.lang.NullPointerException- if the given object is null.
 
- 
assertIsOfAnyClassIn
public void assertIsOfAnyClassIn(AssertionInfo info, java.lang.Object actual, java.lang.Class<?>[] types)
Verifies that the actual value type is in given types.- Parameters:
 info- contains information about the assertion.actual- the given object.types- the types to check the actual value against.- Throws:
 java.lang.AssertionError- if the actual value type is in given type.java.lang.NullPointerException- if the actual value is null.java.lang.NullPointerException- if the given types is null.
 
- 
assertIsNotOfAnyClassIn
public void assertIsNotOfAnyClassIn(AssertionInfo info, java.lang.Object actual, java.lang.Class<?>[] types)
Verifies that the actual value type is not in given types.- Parameters:
 info- contains information about the assertion.actual- the given object.types- the types to check the actual value against.- Throws:
 java.lang.AssertionError- if the actual value type is in given type.java.lang.NullPointerException- if the actual value is null.java.lang.NullPointerException- if the given types is null.
 
- 
assertEqual
public void assertEqual(AssertionInfo info, java.lang.Object actual, java.lang.Object expected)
Asserts that two objects are equal.- Parameters:
 info- contains information about the assertion.actual- the "actual" object.expected- the "expected" object.- Throws:
 java.lang.AssertionError- ifactualis not equal toexpected. This method will throw aorg.junit.ComparisonFailureinstead if JUnit is in the classpath and the given objects are not equal.
 
- 
assertNotEqual
public void assertNotEqual(AssertionInfo info, java.lang.Object actual, java.lang.Object other)
Asserts that two objects are not equal.- Parameters:
 info- contains information about the assertion.actual- the given object.other- the object to compareactualto.- Throws:
 java.lang.AssertionError- ifactualis equal toother.
 
- 
assertNull
public void assertNull(AssertionInfo info, java.lang.Object actual)
Asserts that the given object isnull.- Parameters:
 info- contains information about the assertion.actual- the given object.- Throws:
 java.lang.AssertionError- if the given object is notnull.
 
- 
assertNotNull
public void assertNotNull(AssertionInfo info, java.lang.Object actual)
Asserts that the given object is notnull.- Parameters:
 info- contains information about the assertion.actual- the given object.- Throws:
 java.lang.AssertionError- if the given object isnull.
 
- 
assertSame
public void assertSame(AssertionInfo info, java.lang.Object actual, java.lang.Object expected)
Asserts that two objects refer to the same object.- Parameters:
 info- contains information about the assertion.actual- the given object.expected- the expected object.- Throws:
 java.lang.AssertionError- if the given objects do not refer to the same object.
 
- 
assertNotSame
public void assertNotSame(AssertionInfo info, java.lang.Object actual, java.lang.Object other)
Asserts that two objects do not refer to the same object.- Parameters:
 info- contains information about the assertion.actual- the given object.other- the object to compareactualto.- Throws:
 java.lang.AssertionError- if the given objects refer to the same object.
 
- 
assertIsIn
public void assertIsIn(AssertionInfo info, java.lang.Object actual, java.lang.Object[] values)
Asserts that the given object is present in the given array.- Parameters:
 info- contains information about the assertion.actual- the given object.values- the given array.- Throws:
 java.lang.NullPointerException- if the given array isnull.java.lang.IllegalArgumentException- if the given array is empty.java.lang.AssertionError- if the given object is not present in the given array.
 
- 
assertIsNotIn
public void assertIsNotIn(AssertionInfo info, java.lang.Object actual, java.lang.Object[] values)
Asserts that the given object is not present in the given array.- Parameters:
 info- contains information about the assertion.actual- the given object.values- the given array.- Throws:
 java.lang.NullPointerException- if the given array isnull.java.lang.IllegalArgumentException- if the given array is empty.java.lang.AssertionError- if the given object is present in the given array.
 
- 
assertIsIn
public <A> void assertIsIn(AssertionInfo info, A actual, java.lang.Iterable<? extends A> values)
Asserts that the given object is present in the given collection.- Parameters:
 info- contains information about the assertion.actual- the given object.values- the given iterable.- Throws:
 java.lang.NullPointerException- if the given collection isnull.java.lang.IllegalArgumentException- if the given collection is empty.java.lang.AssertionError- if the given object is not present in the given collection.
 
- 
assertIsNotIn
public <A> void assertIsNotIn(AssertionInfo info, A actual, java.lang.Iterable<? extends A> values)
Asserts that the given object is not present in the given collection.- Parameters:
 info- contains information about the assertion.actual- the given object.values- the given collection.- Throws:
 java.lang.NullPointerException- if the given iterable isnull.java.lang.IllegalArgumentException- if the given collection is empty.java.lang.AssertionError- if the given object is present in the given collection.
 
- 
assertIsLenientEqualsToByIgnoringNullFields
public <A> void assertIsLenientEqualsToByIgnoringNullFields(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).- Parameters:
 info- contains information about the assertion.actual- the given object.other- the object to compareactualto.- Throws:
 java.lang.NullPointerException- if the actual type isnull.java.lang.NullPointerException- if the other type isnull.java.lang.AssertionError- if the actual and the given object are not lenient equals.java.lang.AssertionError- if the other object is not an instance of the actual type.
 
- 
assertIsLenientEqualsToByAcceptingFields
public <A> void assertIsLenientEqualsToByAcceptingFields(AssertionInfo info, A actual, A other, java.lang.String... fields)
Assert that the given object is lenient equals to other object by comparing given fields value only.- Parameters:
 info- contains information about the assertion.actual- the given object.other- the object to compareactualto.fields- accepted fields- Throws:
 java.lang.NullPointerException- if the other type isnull.java.lang.AssertionError- if actual isnull.java.lang.AssertionError- if the actual and the given object are not lenient equals.java.lang.AssertionError- if the other object is not an instance of the actual type.org.fest.util.IntrospectionError- if a field does not exist in actual.
 
- 
assertIsLenientEqualsToByIgnoringFields
public <A> void assertIsLenientEqualsToByIgnoringFields(AssertionInfo info, A actual, A other, java.lang.String... fields)
Assert that the given object is lenient equals to the other by comparing all fields (including inherited fields) unless given ignored ones.- Parameters:
 info- contains information about the assertion.actual- the given object.other- the object to compareactualto.fields- the fields to ignore in comparison- Throws:
 java.lang.NullPointerException- if the other type isnull.java.lang.AssertionError- if actual isnull.java.lang.AssertionError- if the actual and the given object are not lenient equals.java.lang.AssertionError- if the other object is not an instance of the actual type.
 
 - 
 
 -