org.fest.assertions
Class BooleanAssert

java.lang.Object
  extended by org.fest.assertions.Assert
      extended by org.fest.assertions.GenericAssert<Boolean>
          extended by org.fest.assertions.BooleanAssert

public class BooleanAssert
extends GenericAssert<Boolean>

Understands assertion methods for Booleans and booleans. To create a new instance of this class call Assertions.assertThat(Boolean) or Assertions.assertThat(boolean).

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

Field Summary
 
Fields inherited from class org.fest.assertions.GenericAssert
actual
 
Constructor Summary
protected BooleanAssert(boolean actual)
          Creates a new BooleanAssert.
protected BooleanAssert(Boolean actual)
          Creates a new BooleanAssert.
 
Method Summary
 BooleanAssert as(Description description)
          Sets the description of the actual value, to be used in as message of any AssertionError thrown when an assertion fails.
 BooleanAssert as(String description)
          Sets the description of the actual value, to be used in as message of any AssertionError thrown when an assertion fails.
 BooleanAssert describedAs(Description description)
          Alias for GenericAssert.as(Description), since "as" is a keyword in Groovy.
 BooleanAssert describedAs(String description)
          Alias for GenericAssert.as(String), since "as" is a keyword in Groovy.
 BooleanAssert doesNotSatisfy(Condition<Boolean> condition)
          Verifies that the actual Boolean does not satisfy the given condition.
 BooleanAssert is(Condition<Boolean> condition)
          Alias for satisfies(Condition).
 BooleanAssert isEqualTo(boolean expected)
          Verifies that the actual Boolean is equal to the given one.
 BooleanAssert isEqualTo(Boolean expected)
          Verifies that the actual Boolean value is equal to the given one.
 void isFalse()
          Verifies that the actual Boolean value is false.
 BooleanAssert isNot(Condition<Boolean> condition)
          Alias for doesNotSatisfy(Condition).
 BooleanAssert isNotEqualTo(boolean other)
          Verifies that the actual Boolean is not equal to the given one.
 BooleanAssert isNotEqualTo(Boolean other)
          Verifies that the actual Boolean is not equal to the given one.
 BooleanAssert isNotNull()
          Verifies that the actual Boolean is not null.
 BooleanAssert isNotSameAs(Boolean other)
          Verifies that the actual Boolean is not the same object as the given one.
 BooleanAssert isSameAs(Boolean expected)
          Verifies that the actual Boolean is the same object as the given one.
 void isTrue()
          Verifies that the actual Boolean value is true.
 BooleanAssert overridingErrorMessage(String message)
          Replaces the default message displayed in case of a failure with the given one.
 BooleanAssert satisfies(Condition<Boolean> condition)
          Verifies that the actual Boolean 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

BooleanAssert

protected BooleanAssert(boolean actual)
Creates a new BooleanAssert.

Parameters:
actual - the actual value to verify.

BooleanAssert

protected BooleanAssert(Boolean actual)
Creates a new BooleanAssert.

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

as

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

describedAs

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

as

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

describedAs

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

isTrue

public void isTrue()
Verifies that the actual Boolean value is true.

Throws:
AssertionError - if the actual Boolean value is false.

isFalse

public void isFalse()
Verifies that the actual Boolean value is false.

Throws:
AssertionError - if the actual Boolean value is true.

isEqualTo

public BooleanAssert isEqualTo(boolean expected)
Verifies that the actual Boolean is equal to the given one.

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

isEqualTo

public BooleanAssert isEqualTo(Boolean expected)
Verifies that the actual Boolean value is equal to the given one.

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

isNotEqualTo

public BooleanAssert isNotEqualTo(boolean other)
Verifies that the actual Boolean is not equal to the given one.

Parameters:
other - the given boolean to compare the actual Boolean to.
Returns:
this assertion object.
Throws:
AssertionError - if the actual Boolean is equal to the given one.

isNotEqualTo

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

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

satisfies

public BooleanAssert satisfies(Condition<Boolean> condition)
Verifies that the actual Boolean satisfies the given condition.

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

doesNotSatisfy

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

Specified by:
doesNotSatisfy in class GenericAssert<Boolean>
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 BooleanAssert is(Condition<Boolean> condition)
Alias for satisfies(Condition).

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

isNot

public BooleanAssert isNot(Condition<Boolean> condition)
Alias for doesNotSatisfy(Condition).

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

isNotNull

public BooleanAssert isNotNull()
Verifies that the actual Boolean is not null.

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

isSameAs

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

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

isNotSameAs

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

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

overridingErrorMessage

public BooleanAssert 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<Boolean>
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.