org.fest.assertions.internal
Class Objects

java.lang.Object
  extended by org.fest.assertions.internal.Objects

public class Objects
extends Object

Reusable assertions for Objects.

Author:
Yvonne Wang, Alex Ruiz

Constructor Summary
Objects(org.fest.util.ComparisonStrategy comparisonStrategy)
           
 
Method Summary
 void assertEqual(AssertionInfo info, Object actual, Object expected)
          Asserts that two objects are equal.
 void assertIsIn(AssertionInfo info, Object actual, Collection<?> 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.
 void assertIsNotIn(AssertionInfo info, Object actual, Collection<?> 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 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()
           
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

Objects

public Objects(org.fest.util.ComparisonStrategy comparisonStrategy)
Method Detail

instance

public static Objects instance()
Returns the singleton instance of this class based on StandardComparisonStrategy.

Returns:
the singleton instance of this class based on StandardComparisonStrategy.

getComparator

public Comparator<?> getComparator()

assertIsInstanceOf

public void assertIsInstanceOf(AssertionInfo info,
                               Object actual,
                               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:
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.

assertIsInstanceOfAny

public void assertIsInstanceOfAny(AssertionInfo info,
                                  Object actual,
                                  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:
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.

assertEqual

public void assertEqual(AssertionInfo info,
                        Object actual,
                        Object expected)
Asserts that two objects are equal.

Parameters:
info - contains information about the assertion.
actual - the "actual" object.
expected - the "expected" object.
Throws:
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.

assertNotEqual

public void assertNotEqual(AssertionInfo info,
                           Object actual,
                           Object other)
Asserts that two objects are not equal.

Parameters:
info - contains information about the assertion.
actual - the given object.
other - the object to compare actual to.
Throws:
AssertionError - if actual is equal to other.

assertNull

public void assertNull(AssertionInfo info,
                       Object actual)
Asserts that the given object is null.

Parameters:
info - contains information about the assertion.
actual - the given object.
Throws:
AssertionError - if the given object is not null.

assertNotNull

public void assertNotNull(AssertionInfo info,
                          Object actual)
Asserts that the given object is not null.

Parameters:
info - contains information about the assertion.
actual - the given object.
Throws:
AssertionError - if the given object is null.

assertSame

public void assertSame(AssertionInfo info,
                       Object actual,
                       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:
AssertionError - if the given objects do not refer to the same object.

assertNotSame

public void assertNotSame(AssertionInfo info,
                          Object actual,
                          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 compare actual to.
Throws:
AssertionError - if the given objects refer to the same object.

assertIsIn

public void assertIsIn(AssertionInfo info,
                       Object actual,
                       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:
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.

assertIsNotIn

public void assertIsNotIn(AssertionInfo info,
                          Object actual,
                          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:
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.

assertIsIn

public void assertIsIn(AssertionInfo info,
                       Object actual,
                       Collection<?> 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 collection.
Throws:
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.

assertIsNotIn

public void assertIsNotIn(AssertionInfo info,
                          Object actual,
                          Collection<?> 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:
NullPointerException - if the given collection is null.
IllegalArgumentException - if the given collection is empty.
AssertionError - if the given object is present in the given collection.


Copyright © 2007-2012 FEST (Fixtures for Easy Software Testing). All Rights Reserved.