org.fest.assertions
Class BigDecimalAssert

java.lang.Object
  extended by org.fest.assertions.Assert
      extended by org.fest.assertions.GenericAssert<T>
          extended by org.fest.assertions.ComparableAssert<BigDecimal>
              extended by org.fest.assertions.BigDecimalAssert
All Implemented Interfaces:
NumberAssert

public class BigDecimalAssert
extends ComparableAssert<BigDecimal>
implements NumberAssert

Understands assertion methods for BigDecimal. To create a new instance of this class use the method Assertions.assertThat(BigDecimal).

Author:
David DIDIER, Ted M. Young, Yvonne Wang, Alex Ruiz

Field Summary
 
Fields inherited from class org.fest.assertions.GenericAssert
actual
 
Constructor Summary
protected BigDecimalAssert(BigDecimal actual)
          Creates a new BigDecimalAssert.
 
Method Summary
 BigDecimalAssert as(Description description)
          Sets the description of the actual value, to be used in as message of any AssertionError thrown when an assertion fails.
 BigDecimalAssert as(String description)
          Sets the description of the actual value, to be used in as message of any AssertionError thrown when an assertion fails.
 BigDecimalAssert describedAs(Description description)
          Alias for GenericAssert.as(Description), since "as" is a keyword in Groovy.
 BigDecimalAssert describedAs(String description)
          Alias for GenericAssert.as(String), since "as" is a keyword in Groovy.
 BigDecimalAssert doesNotSatisfy(Condition<BigDecimal> condition)
          Verifies that the actual BigDecimal does not satisfy the given condition.
 BigDecimalAssert is(Condition<BigDecimal> condition)
          Alias for satisfies(Condition).
 BigDecimalAssert isEqualByComparingTo(BigDecimal expected)
          Verifies that the actual BigDecimal is equal to the given one.
 BigDecimalAssert isEqualTo(BigDecimal expected)
          Verifies that the actual BigDecimal is equal to the given one.
 BigDecimalAssert isGreaterThan(BigDecimal other)
          Verifies that the actual BigDecimal value is greater than the given one.
 BigDecimalAssert isGreaterThanOrEqualTo(BigDecimal other)
          Verifies that the actual BigDecimal value is greater than or equal to the given one.
 BigDecimalAssert isLessThan(BigDecimal other)
          Verifies that the actual BigDecimal value is less than the given one.
 BigDecimalAssert isLessThanOrEqualTo(BigDecimal other)
          Verifies that the actual BigDecimal value is less than or equal to the given one.
 BigDecimalAssert isNegative()
          Verifies that the actual BigDecimal is negative.
 BigDecimalAssert isNot(Condition<BigDecimal> condition)
          Alias for doesNotSatisfy(Condition).
 BigDecimalAssert isNotEqualByComparingTo(BigDecimal expected)
          Verifies that the actual BigDecimal is not equal to the given one.
 BigDecimalAssert isNotEqualTo(BigDecimal other)
          Verifies that the actual BigDecimal is not equal to the given one.
 BigDecimalAssert isNotNull()
          Verifies that the actual BigDecimal is not null.
 BigDecimalAssert isNotSameAs(BigDecimal other)
          Verifies that the actual BigDecimal is not the same as the given one.
 BigDecimalAssert isPositive()
          Verifies that the actual BigDecimal is positive.
 BigDecimalAssert isSameAs(BigDecimal expected)
          Verifies that the actual BigDecimal is the same as the given one.
 BigDecimalAssert isZero()
          Verifies that the actual BigDecimal is equal to zero, regardless of precision.
 BigDecimalAssert overridingErrorMessage(String message)
          Replaces the default message displayed in case of a failure with the given one.
 BigDecimalAssert satisfies(Condition<BigDecimal> condition)
          Verifies that the actual BigDecimal satisfies the given condition.
 
Methods inherited from class org.fest.assertions.ComparableAssert
assertIsEqualByComparingTo, assertIsGreaterThan, assertIsGreaterThanOrEqualTo, assertIsLessThan, assertIsLessThanOrEqualTo, assertIsNotEqualByComparingTo
 
Methods inherited from class org.fest.assertions.GenericAssert
assertDoesNotSatisfy, assertEqualTo, assertIs, assertIsNot, assertNotEqualTo, assertNotNull, assertNotSameAs, assertSameAs, assertSatisfies, isNull
 
Methods inherited from class org.fest.assertions.Assert
customErrorMessage, description, description, description, equals, fail, fail, failIfCustomMessageIsSet, failIfCustomMessageIsSet, failure, formattedErrorMessage, hashCode, rawDescription, replaceDefaultErrorMessagesWith
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BigDecimalAssert

protected BigDecimalAssert(BigDecimal actual)
Creates a new BigDecimalAssert.

Parameters:
actual - the target to verify.
Method Detail

as

public BigDecimalAssert as(String description)
Sets the description of the actual value, to be used in as message of any AssertionError thrown when an assertion fails. This method should be called before any assertion method, otherwise any assertion failure will not show the provided description.

For example:

 assertThat(val).as("name").isEqualTo("Frodo");
 

Specified by:
as in class GenericAssert<BigDecimal>
Parameters:
description - the description of the actual value.
Returns:
this assertion object.

describedAs

public BigDecimalAssert describedAs(String description)
Alias for GenericAssert.as(String), since "as" is a keyword in Groovy. This method should be called before any assertion method, otherwise any assertion failure will not show the provided description.

For example:

 assertThat(val).describedAs("name").isEqualTo("Frodo");
 

Specified by:
describedAs in class GenericAssert<BigDecimal>
Parameters:
description - the description of the actual value.
Returns:
this assertion object.

as

public BigDecimalAssert as(Description description)
Sets the description of the actual value, to be used in as message of any AssertionError thrown when an assertion fails. This method should be called before any assertion method, otherwise any assertion failure will not show the provided description.

For example:

 assertThat(val).as(new BasicDescription("name")).isEqualTo("Frodo");
 

Specified by:
as in class GenericAssert<BigDecimal>
Parameters:
description - the description of the actual value.
Returns:
this assertion object.

describedAs

public BigDecimalAssert describedAs(Description description)
Alias for GenericAssert.as(Description), since "as" is a keyword in Groovy. This method should be called before any assertion method, otherwise any assertion failure will not show the provided description.

For example:

 assertThat(val).describedAs(new BasicDescription("name")).isEqualTo("Frodo");
 

Specified by:
describedAs in class GenericAssert<BigDecimal>
Parameters:
description - the description of the actual value.
Returns:
this assertion object.

satisfies

public BigDecimalAssert satisfies(Condition<BigDecimal> condition)
Verifies that the actual BigDecimal satisfies the given condition.

Specified by:
satisfies in class GenericAssert<BigDecimal>
Parameters:
condition - the given condition.
Returns:
this assertion object.
Throws:
NullPointerException - if the given condition is null.
AssertionError - if the actual BigDecimal does not satisfy the given condition.
See Also:
is(Condition)

doesNotSatisfy

public BigDecimalAssert doesNotSatisfy(Condition<BigDecimal> condition)
Verifies that the actual BigDecimal does not satisfy the given condition.

Specified by:
doesNotSatisfy in class GenericAssert<BigDecimal>
Parameters:
condition - the given condition.
Returns:
this assertion object.
Throws:
NullPointerException - if the given condition is null.
AssertionError - if the actual value does satisfies the given condition.
See Also:
isNot(Condition)

is

public BigDecimalAssert is(Condition<BigDecimal> condition)
Alias for satisfies(Condition).

Specified by:
is in class GenericAssert<BigDecimal>
Parameters:
condition - the given condition.
Returns:
this assertion object.
Throws:
NullPointerException - if the given condition is null.
AssertionError - if the actual BigDecimal does not satisfy the given condition.
Since:
1.2

isNot

public BigDecimalAssert isNot(Condition<BigDecimal> condition)
Alias for doesNotSatisfy(Condition).

Specified by:
isNot in class GenericAssert<BigDecimal>
Parameters:
condition - the given condition.
Returns:
this assertion object.
Throws:
NullPointerException - if the given condition is null.
AssertionError - if the actual value does satisfies the given condition.
Since:
1.2

isPositive

public BigDecimalAssert isPositive()
Verifies that the actual BigDecimal is positive.

Specified by:
isPositive in interface NumberAssert
Returns:
this assertion object.
Throws:
AssertionError - if the actual BigDecimal value is null.
AssertionError - if the actual BigDecimal value is not positive.

isNegative

public BigDecimalAssert isNegative()
Verifies that the actual BigDecimal is negative.

Specified by:
isNegative in interface NumberAssert
Returns:
this assertion object.
Throws:
AssertionError - if the actual BigDecimal value is null.
AssertionError - if the actual BigDecimal value is not negative.

isZero

public BigDecimalAssert isZero()
Verifies that the actual BigDecimal is equal to zero, regardless of precision. Essentially, this is the same as isEqualByComparingTo(BigDecimal.ZERO).

Specified by:
isZero in interface NumberAssert
Returns:
this assertion object.
Throws:
AssertionError - if the actual BigDecimal value is null.
AssertionError - if the actual BigDecimal value is not equal to zero.

isNotNull

public BigDecimalAssert isNotNull()
Verifies that the actual BigDecimal is not null.

Specified by:
isNotNull in class GenericAssert<BigDecimal>
Returns:
this assertion object.
Throws:
AssertionError - if the actual BigDecimal value is null.

isSameAs

public BigDecimalAssert isSameAs(BigDecimal expected)
Verifies that the actual BigDecimal is the same as the given one.

Specified by:
isSameAs in class GenericAssert<BigDecimal>
Parameters:
expected - the given BigDecimal to compare the actual BigDecimal to.
Returns:
this assertion object.
Throws:
AssertionError - if the actual BigDecimal value is not the same as the given one.

isNotSameAs

public BigDecimalAssert isNotSameAs(BigDecimal other)
Verifies that the actual BigDecimal is not the same as the given one.

Specified by:
isNotSameAs in class GenericAssert<BigDecimal>
Parameters:
other - the given BigDecimal to compare the actual BigDecimal to.
Returns:
this assertion object.
Throws:
AssertionError - if the actual BigDecimal value is the same as the given one.

isEqualTo

public BigDecimalAssert isEqualTo(BigDecimal expected)
Verifies that the actual BigDecimal is equal to the given one. Unlike isEqualByComparingTo(BigDecimal), this method considers two BigDecimal objects equal only if they are equal in value and scale (thus 2.0 is not equal to 2.00 when compared by this method).

Specified by:
isEqualTo in class GenericAssert<BigDecimal>
Parameters:
expected - the given BigDecimal to compare the actual BigDecimal to.
Returns:
this assertion object.
Throws:
AssertionError - if the actual BigDecimal value is not equal to the given one.
See Also:
BigDecimal.equals(Object), isEqualByComparingTo(BigDecimal)

isNotEqualTo

public BigDecimalAssert isNotEqualTo(BigDecimal other)
Verifies that the actual BigDecimal is not equal to the given one.

Specified by:
isNotEqualTo in class GenericAssert<BigDecimal>
Parameters:
other - the given BigDecimal to compare the actual BigDecimal to.
Returns:
this assertion object.
Throws:
AssertionError - if the actual BigDecimal value is equal to the given one.

isEqualByComparingTo

public BigDecimalAssert isEqualByComparingTo(BigDecimal expected)
Verifies that the actual BigDecimal is equal to the given one. Two BigDecimal objects that are equal in value but have a different scale (like 2.0 and 2.00) are considered equal by this method.

Specified by:
isEqualByComparingTo in class ComparableAssert<BigDecimal>
Parameters:
expected - the given BigDecimal to compare the actual BigDecimal to.
Returns:
this assertion object.
Throws:
AssertionError - if the actual BigDecimal value is null.
AssertionError - if the actual BigDecimal value is not equal to the given one.
See Also:
BigDecimal.compareTo(BigDecimal)

isNotEqualByComparingTo

public BigDecimalAssert isNotEqualByComparingTo(BigDecimal expected)
Verifies that the actual BigDecimal is not equal to the given one. Two BigDecimal objects that are equal in value but have a different scale (like 2.0 and 2.00) are considered equal by this method.

Specified by:
isNotEqualByComparingTo in class ComparableAssert<BigDecimal>
Parameters:
expected - the given BigDecimal to use to compare to the actual BigDecimal.
Returns:
this assertion object.
Throws:
AssertionError - if the actual BigDecimal value is null.
AssertionError - if the actual BigDecimal value is equal to the given one.
See Also:
BigDecimal.compareTo(BigDecimal)

isLessThan

public BigDecimalAssert isLessThan(BigDecimal other)
Verifies that the actual BigDecimal value is less than the given one.

Specified by:
isLessThan in class ComparableAssert<BigDecimal>
Parameters:
other - the given value.
Returns:
this assertion object.
Throws:
AssertionError - if the actual BigDecimal value is null.
AssertionError - if the actual BigDecimal value is not less than the given one.

isGreaterThan

public BigDecimalAssert isGreaterThan(BigDecimal other)
Verifies that the actual BigDecimal value is greater than the given one.

Specified by:
isGreaterThan in class ComparableAssert<BigDecimal>
Parameters:
other - the given value.
Returns:
this assertion object.
Throws:
AssertionError - if the actual BigDecimal value is null.
AssertionError - if the actual BigDecimal value is not greater than the given one.

isLessThanOrEqualTo

public BigDecimalAssert isLessThanOrEqualTo(BigDecimal other)
Verifies that the actual BigDecimal value is less than or equal to the given one.

Specified by:
isLessThanOrEqualTo in class ComparableAssert<BigDecimal>
Parameters:
other - the given value.
Returns:
this assertion object.
Throws:
AssertionError - if the actual BigDecimal value is null.
AssertionError - if the actual BigDecimal value is not less than or equal to the given one.

isGreaterThanOrEqualTo

public BigDecimalAssert isGreaterThanOrEqualTo(BigDecimal other)
Verifies that the actual BigDecimal value is greater than or equal to the given one.

Specified by:
isGreaterThanOrEqualTo in class ComparableAssert<BigDecimal>
Parameters:
other - the given value.
Returns:
this assertion object.
Throws:
AssertionError - if the actual BigDecimal value is null.
AssertionError - if the actual BigDecimal value is not greater than or equal to the given one.

overridingErrorMessage

public BigDecimalAssert overridingErrorMessage(String message)
Replaces the default message displayed in case of a failure with the given one.

For example, the following assertion:

 assertThat("Hello").isEqualTo("Bye");
 
will fail with the default message "expected:<'[Bye]'> but was:<'[Hello]'>."

We can replace this message with our own:

 assertThat("Hello").overridingErrorMessage("'Hello' should be equal to 'Bye'").isEqualTo("Bye");
 
in this case, the assertion will fail showing the message "'Hello' should be equal to 'Bye'".

Specified by:
overridingErrorMessage in class GenericAssert<BigDecimal>
Parameters:
message - the given error message, which will replace the default one.
Returns:
this assertion.


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