|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.fest.assertions.Assert
org.fest.assertions.GenericAssert<T>
org.fest.assertions.GroupAssert<Map<?,?>>
org.fest.assertions.MapAssert
public class MapAssert
Understands assertions for s. To create a new instance of this class use the method
Map.
Assertions.assertThat(Map)
| Nested Class Summary | |
|---|---|
static class |
MapAssert.Entry
Understands an entry in a . |
| Field Summary |
|---|
| Fields inherited from class org.fest.assertions.GenericAssert |
|---|
actual |
| Constructor Summary | |
|---|---|
protected |
MapAssert(Map<?,?> actual)
Creates a new MapAssert. |
| Method Summary | |
|---|---|
protected int |
actualGroupSize()
Returns the number of elements in the actual . |
MapAssert |
as(Description description)
Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails. |
MapAssert |
as(String description)
Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails. |
MapAssert |
describedAs(Description description)
Alias for , since "as" is a keyword in
Groovy. |
MapAssert |
describedAs(String description)
Alias for , since "as" is a keyword in
Groovy. |
MapAssert |
doesNotSatisfy(Condition<Map<?,?>> condition)
Verifies that the actual does not satisfy the given condition. |
static MapAssert.Entry |
entry(Object key,
Object value)
Creates a new map entry. |
MapAssert |
excludes(MapAssert.Entry... entries)
Verifies that the actual does not contain the given entries. |
MapAssert |
hasSize(int expected)
Verifies that the number of elements in the actual is equal to the given one. |
MapAssert |
includes(MapAssert.Entry... entries)
Verifies that the actual contains the given entries. |
MapAssert |
is(Condition<Map<?,?>> condition)
Alias for . |
void |
isEmpty()
Verifies that the actual is empty. |
MapAssert |
isEqualTo(Map<?,?> expected)
Verifies that the actual is equal to the given one. |
MapAssert |
isNot(Condition<Map<?,?>> condition)
Alias for . |
MapAssert |
isNotEmpty()
Verifies that the actual contains at least on element. |
MapAssert |
isNotEqualTo(Map<?,?> other)
Verifies that the actual is not equal to the given one. |
MapAssert |
isNotNull()
Verifies that the actual is not null. |
MapAssert |
isNotSameAs(Map<?,?> other)
Verifies that the actual is not the same as the given one. |
void |
isNullOrEmpty()
Verifies that the actual is null or empty. |
MapAssert |
isSameAs(Map<?,?> expected)
Verifies that the actual is the same as the given one. |
MapAssert |
overridingErrorMessage(String message)
Replaces the default message displayed in case of a failure with the given one. |
MapAssert |
satisfies(Condition<Map<?,?>> condition)
Verifies that the actual 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 |
|---|
protected MapAssert(Map<?,?> actual)
MapAssert.
actual - the target to verify.| Method Detail |
|---|
public MapAssert as(String description)
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");
as in class GenericAssert<Map<?,?>>description - the description of the actual value.
public MapAssert describedAs(String description)
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");
describedAs in class GenericAssert<Map<?,?>>description - the description of the actual value.
public MapAssert as(Description description)
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");
as in class GenericAssert<Map<?,?>>description - the description of the actual value.
public MapAssert describedAs(Description description)
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");
describedAs in class GenericAssert<Map<?,?>>description - the description of the actual value.
public MapAssert includes(MapAssert.Entry... entries)
Map contains the given entries.
Example:
// static import org.fest.assertions.Assertions.*; // static import org.fest.assertions.MapAssert.*; assertThat(myMap).includes(entry("jedi", yoda),entry("sith", anakin));
entries - the given entries.
AssertionError - if the actual map is null.
AssertionError - if the actual Map does not contain any of the given entries.
NullPointerException - if the given array of entries is null.
NullPointerException - if any of the entries in the given array is null.public MapAssert excludes(MapAssert.Entry... entries)
Map does not contain the given entries.
Example:
// static import org.fest.assertions.Assertions.*; // static import org.fest.assertions.MapAssert.*; assertThat(myMap).excludes(entry("jedi", yoda),entry("sith", anakin));
entries - the given entries.
AssertionError - if the actual map is null.
AssertionError - if the actual Map contains any of the given entries.
NullPointerException - if the given array of entries is null.
NullPointerException - if any of the entries in the given array is null.
public static MapAssert.Entry entry(Object key,
Object value)
key - the key of the entry.value - the value of the entry.
includes(org.fest.assertions.MapAssert.Entry...)public MapAssert hasSize(int expected)
Map is equal to the given one.
hasSize in class GroupAssert<Map<?,?>>expected - the expected number of elements in the actual Map.
AssertionError - if the actual map is null.
AssertionError - if the number of elements of the actual Map is not equal to the given one.public final void isNullOrEmpty()
Map is null or empty.
isNullOrEmpty in class GroupAssert<Map<?,?>>AssertionError - if the actual Map is not null or not empty.public void isEmpty()
Map is empty.
isEmpty in class GroupAssert<Map<?,?>>AssertionError - if the actual Map is null or not empty.public MapAssert isEqualTo(Map<?,?> expected)
Map is equal to the given one.
isEqualTo in class GenericAssert<Map<?,?>>expected - the given map to compare the actual Map to.
AssertionError - if the actual Map is not equal to the given one.public MapAssert isNotEmpty()
Map contains at least on element.
isNotEmpty in class GroupAssert<Map<?,?>>AssertionError - if the actual Map is empty.public MapAssert isNotEqualTo(Map<?,?> other)
Map is not equal to the given one.
isNotEqualTo in class GenericAssert<Map<?,?>>other - the given map to compare the actual Map to.
AssertionError - if the actual Map is equal to the given one.public MapAssert isNotNull()
Map is not null.
isNotNull in class GenericAssert<Map<?,?>>AssertionError - if the actual Map is null.public MapAssert isNotSameAs(Map<?,?> other)
Map is not the same as the given one.
isNotSameAs in class GenericAssert<Map<?,?>>other - the given map to compare the actual Map to.
AssertionError - if the actual Map is the same as the given one.public MapAssert isSameAs(Map<?,?> expected)
Map is the same as the given one.
isSameAs in class GenericAssert<Map<?,?>>expected - the given map to compare the actual Map to.
AssertionError - if the actual Map is not the same as the given one.public MapAssert satisfies(Condition<Map<?,?>> condition)
Map satisfies the given condition.
satisfies in class GenericAssert<Map<?,?>>condition - the given condition.
NullPointerException - if the given condition is null.
AssertionError - if the actual Map does not satisfy the given condition.is(Condition)public MapAssert doesNotSatisfy(Condition<Map<?,?>> condition)
Map does not satisfy the given condition.
doesNotSatisfy in class GenericAssert<Map<?,?>>condition - the given condition.
NullPointerException - if the given condition is null.
AssertionError - if the actual Map satisfies the given condition.isNot(Condition)public MapAssert is(Condition<Map<?,?>> condition)
satisfies(Condition).
is in class GenericAssert<Map<?,?>>condition - the given condition.
NullPointerException - if the given condition is null.
AssertionError - if the actual Map does not satisfy the given condition.public MapAssert isNot(Condition<Map<?,?>> condition)
doesNotSatisfy(Condition).
isNot in class GenericAssert<Map<?,?>>condition - the given condition.
NullPointerException - if the given condition is null.
AssertionError - if the actual Map satisfies the given condition.protected int actualGroupSize()
Map.
actualGroupSize in class GroupAssert<Map<?,?>>Map.public MapAssert overridingErrorMessage(String message)
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'".
overridingErrorMessage in class GenericAssert<Map<?,?>>message - the given error message, which will replace the default one.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||