|
||||||||||
| 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<T>
org.fest.assertions.ItemGroupAssert<T>
org.fest.assertions.ObjectGroupAssert<T>
T - the type of object implementations of this template can verify.public abstract class ObjectGroupAssert<T>
Understands a template for assertion methods related to arrays or collections.
| Field Summary |
|---|
| Fields inherited from class org.fest.assertions.GenericAssert |
|---|
actual |
| Constructor Summary | |
|---|---|
protected |
ObjectGroupAssert(T actual)
Creates a new ObjectGroupAssert. |
| Method Summary | |
|---|---|
protected abstract ObjectGroupAssert<T> |
as(Description description)
Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails. |
protected abstract ObjectGroupAssert<T> |
as(String description)
Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails. |
protected abstract ObjectGroupAssert<T> |
contains(Object... objects)
Verifies that the actual group of objects contains the given objects. |
protected abstract ObjectGroupAssert<T> |
containsOnly(Object... objects)
Verifies that the actual group of objects contains the given objects only, in any order. |
protected abstract ObjectGroupAssert<T> |
describedAs(Description description)
Alias for , since "as" is a keyword in
Groovy. |
protected abstract ObjectGroupAssert<T> |
describedAs(String description)
Alias for , since "as" is a keyword in
Groovy. |
protected abstract ObjectGroupAssert<T> |
doesNotHaveDuplicates()
Verifies that the actual group of objects does not have duplicates. |
protected abstract ObjectGroupAssert<T> |
excludes(Object... objects)
Verifies that the actual group of objects does not contain the given objects. |
protected abstract ObjectGroupAssert<T> |
onProperty(String propertyName)
Creates a new group of objects whose target collection contains the values of the given property name from the elements of the actual group of objects. |
protected abstract ObjectGroupAssert<T> |
overridingErrorMessage(String message)
Replaces the default message displayed in case of a failure with the given one. |
| Methods inherited from class org.fest.assertions.ItemGroupAssert |
|---|
actualAsList, actualAsSet, assertContains, assertContainsOnly, assertDoesNotHaveDuplicates, assertExcludes, asSet, validateIsNotNull |
| Methods inherited from class org.fest.assertions.GroupAssert |
|---|
actualGroupSize, assertHasSize, assertIsNotEmpty, hasSize, isEmpty, isNotEmpty, isNullOrEmpty |
| Methods inherited from class org.fest.assertions.GenericAssert |
|---|
assertDoesNotSatisfy, assertEqualTo, assertIs, assertIsNot, assertNotEqualTo, assertNotNull, assertNotSameAs, assertSameAs, assertSatisfies, doesNotSatisfy, is, isEqualTo, isNot, isNotEqualTo, isNotNull, isNotSameAs, isNull, isSameAs, satisfies |
| 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 ObjectGroupAssert(T actual)
ObjectGroupAssert.
actual - the target to verify.| Method Detail |
|---|
protected abstract ObjectGroupAssert<T> contains(Object... objects)
objects - the objects to look for.
AssertionError - if the actual group of objects is null.
NullPointerException - if the given array is null.
AssertionError - if the actual group of objects does not contain the given objects.protected abstract ObjectGroupAssert<T> containsOnly(Object... objects)
objects - the objects to look for.
AssertionError - if the actual group of objects is null.
NullPointerException - if the given group of objects is null.
AssertionError - if the actual group of objects does not contain the given objects, or if the actual group of
objects contains elements other than the ones specified.protected abstract ObjectGroupAssert<T> excludes(Object... objects)
objects - the objects that the group of objects should exclude.
AssertionError - if the actual group of objects is null.
NullPointerException - if the given array is null.
AssertionError - if the actual group of objects contains any of the given objects.protected abstract ObjectGroupAssert<T> doesNotHaveDuplicates()
AssertionError - if the actual group of objects is null.
AssertionError - if the actual group of objects has duplicates.protected abstract ObjectGroupAssert<T> onProperty(String propertyName)
Person.age
and nested properties Person.father.age.
For example, let's say we have a collection of Person objects and you want to verify their age:
assertThat(persons).onProperty("age").containsOnly(25, 16, 44, 37); // simple property
assertThat(persons).onProperty("father.age").containsOnly(55, 46, 74, 62); // nested property
propertyName - the name of the property to extract values from the actual collection to build a new group of
objects.
AssertionError - if the actual group of objects is null.
org.fest.util.IntrospectionError - if an element in the given collection does not have a matching property.protected abstract ObjectGroupAssert<T> 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 GroupAssert<T>description - the description of the actual value.
protected abstract ObjectGroupAssert<T> 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 GroupAssert<T>description - the description of the actual value.
protected abstract ObjectGroupAssert<T> 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 GroupAssert<T>description - the description of the actual value.
protected abstract ObjectGroupAssert<T> 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 GroupAssert<T>description - the description of the actual value.
protected abstract ObjectGroupAssert<T> 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 GroupAssert<T>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 | |||||||||