org.fest.assertions
Class IntAssert

java.lang.Object
  extended by org.fest.assertions.Assert
      extended by org.fest.assertions.GenericAssert<Integer>
          extended by org.fest.assertions.IntAssert
All Implemented Interfaces:
NumberAssert

public class IntAssert
extends GenericAssert<Integer>
implements NumberAssert

Understands assert method for Integers and ints. To create a new instance of this class call Assertions.assertThat(Integer) or Assertions.assertThat(int).

Author:
Yvonne Wang, David DIDIER, Ansgar Konermann, Alex Ruiz

Field Summary
 
Fields inherited from class org.fest.assertions.GenericAssert
actual
 
Constructor Summary
protected IntAssert(int actual)
          Creates a new IntAssert.
protected IntAssert(Integer actual)
          Creates a new IntAssert.
 
Method Summary
 IntAssert as(Description description)
          Sets the description of the actual value, to be used in as message of any AssertionError thrown when an assertion fails.
 IntAssert as(String description)
          Sets the description of the actual value, to be used in as message of any AssertionError thrown when an assertion fails.
 IntAssert describedAs(Description description)
          Alias for GenericAssert.as(Description), since "as" is a keyword in Groovy.
 IntAssert describedAs(String description)
          Alias for GenericAssert.as(String), since "as" is a keyword in Groovy.
 IntAssert doesNotSatisfy(Condition<Integer> condition)
          Verifies that the actual Integer does not satisfy the given condition.
 IntAssert is(Condition<Integer> condition)
          Alias for satisfies(Condition).
 IntAssert isEqualTo(int expected)
          Verifies that the actual Integer is equal to the given one.
 IntAssert isEqualTo(Integer expected)
          Verifies that the actual Integer is equal to the given one.
 IntAssert isGreaterThan(int other)
          Verifies that the actual Integer is greater than the given one.
 IntAssert isGreaterThanOrEqualTo(int other)
          Verifies that the actual Integer is greater or equal to the given one.
 IntAssert isLessThan(int other)
          Verifies that the actual Integer is less than the given one.
 IntAssert isLessThanOrEqualTo(int other)
          Verifies that the actual Integer is less or equal to the given one.
 IntAssert isNegative()
          Verifies that the actual Integer is negative.
 IntAssert isNot(Condition<Integer> condition)
          Alias for doesNotSatisfy(Condition).
 IntAssert isNotEqualTo(int other)
          Verifies that the actual Integer is not equal to the given one.
 IntAssert isNotEqualTo(Integer other)
          Verifies that the actual Integer is not equal to the given one.
 IntAssert isNotNull()
          Verifies that the actual Integer is not null.
 IntAssert isNotSameAs(Integer other)
          Verifies that the actual Integer is not the same object as the given one.
 IntAssert isPositive()
          Verifies that the actual Integer is positive.
 IntAssert isSameAs(Integer expected)
          Verifies that the actual Integer is the same object as the given one.
 IntAssert isZero()
          Verifies that the actual Integer is equal to zero.
 IntAssert overridingErrorMessage(String message)
          Replaces the default message displayed in case of a failure with the given one.
 IntAssert satisfies(Condition<Integer> condition)
          Verifies that the actual Integer satisfies the given condition.
 
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

IntAssert

protected IntAssert(int actual)
Creates a new IntAssert.

Parameters:
actual - the actual value to verify.

IntAssert

protected IntAssert(Integer actual)
Creates a new IntAssert.

Parameters:
actual - the actual value to verify.
Method Detail

as

public IntAssert 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<Integer>
Parameters:
description - the description of the actual value.
Returns:
this assertion object.

describedAs

public IntAssert 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<Integer>
Parameters:
description - the description of the actual value.
Returns:
this assertion object.

as

public IntAssert 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<Integer>
Parameters:
description - the description of the actual value.
Returns:
this assertion object.

describedAs

public IntAssert 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<Integer>
Parameters:
description - the description of the actual value.
Returns:
this assertion object.

isEqualTo

public IntAssert isEqualTo(int expected)
Verifies that the actual Integer is equal to the given one.

Parameters:
expected - the value to compare the actual one to.
Returns:
this assertion object.
Throws:
AssertionError - if the actual Integer is not equal to the given one.

isEqualTo

public IntAssert isEqualTo(Integer expected)
Verifies that the actual Integer is equal to the given one.

Specified by:
isEqualTo in class GenericAssert<Integer>
Parameters:
expected - the given Integer to compare the actual Integer to.
Returns:
this assertion object.
Throws:
AssertionError - if the actual Integer is not equal to the given one.
Since:
1.3

isNotEqualTo

public IntAssert isNotEqualTo(int other)
Verifies that the actual Integer is not equal to the given one.

Parameters:
other - the given value.
Returns:
this assertion object.
Throws:
AssertionError - if the actual Integer is equal to the given one.

isNotEqualTo

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

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

isGreaterThan

public IntAssert isGreaterThan(int other)
Verifies that the actual Integer is greater than the given one.

Parameters:
other - the given value.
Returns:
this assertion object.
Throws:
AssertionError - if the actual Integer is not greater than the given one.

isLessThan

public IntAssert isLessThan(int other)
Verifies that the actual Integer is less than the given one.

Parameters:
other - the given value.
Returns:
this assertion object.
Throws:
AssertionError - if the actual Integer is not less than the given one.

isGreaterThanOrEqualTo

public IntAssert isGreaterThanOrEqualTo(int other)
Verifies that the actual Integer is greater or equal to the given one.

Parameters:
other - the given value.
Returns:
this assertion object.
Throws:
AssertionError - if the actual Integer is not greater than or equal to the given one.

isLessThanOrEqualTo

public IntAssert isLessThanOrEqualTo(int other)
Verifies that the actual Integer is less or equal to the given one.

Parameters:
other - the given value.
Returns:
this assertion object.
Throws:
AssertionError - if the actual Integer is not less than or equal to the given one.

isZero

public IntAssert isZero()
Verifies that the actual Integer is equal to zero.

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

isPositive

public IntAssert isPositive()
Verifies that the actual Integer is positive.

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

isNegative

public IntAssert isNegative()
Verifies that the actual Integer is negative.

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

overridingErrorMessage

public IntAssert 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<Integer>
Parameters:
message - the given error message, which will replace the default one.
Returns:
this assertion.

satisfies

public IntAssert satisfies(Condition<Integer> condition)
Verifies that the actual Integer satisfies the given condition.

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

doesNotSatisfy

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

Specified by:
doesNotSatisfy in class GenericAssert<Integer>
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.3
See Also:
isNot(Condition)

is

public IntAssert is(Condition<Integer> condition)
Alias for satisfies(Condition).

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

isNot

public IntAssert isNot(Condition<Integer> condition)
Alias for doesNotSatisfy(Condition).

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

isNotNull

public IntAssert isNotNull()
Verifies that the actual Integer is not null.

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

isSameAs

public IntAssert isSameAs(Integer expected)
Verifies that the actual Integer is the same object as the given one.

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

isNotSameAs

public IntAssert isNotSameAs(Integer other)
Verifies that the actual Integer is not the same object as the given one.

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


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