Package org.assertj.core.api
Class ObjectAssert<ACTUAL>
java.lang.Object
org.assertj.core.api.AbstractAssert<SELF,ACTUAL>
org.assertj.core.api.AbstractObjectAssert<ObjectAssert<ACTUAL>,ACTUAL>
org.assertj.core.api.ObjectAssert<ACTUAL>
- Type Parameters:
ACTUAL- the type of the "actual" value.
- All Implemented Interfaces:
Assert<ObjectAssert<ACTUAL>,,ACTUAL> Descriptable<ObjectAssert<ACTUAL>>,ExtensionPoints<ObjectAssert<ACTUAL>,ACTUAL>
Assertion methods for
Objects.
To create a new instance of this class, invoke .
Assertions.assertThat(Object)
-
Field Summary
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, assertionErrorCreator, conditions, info, myself, objects, throwUnsupportedExceptionOnEquals -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal AbstractListAssert<?,List<?>, Object, ObjectAssert<Object>> extracting(Function<? super ACTUAL, ?>... extractors) Uses the givenFunctions to extract the values from the object under test into a list, this new list becoming the object under test.Methods inherited from class org.assertj.core.api.AbstractObjectAssert
as, as, extracting, extracting, extracting, extracting, extracting, getComparatorsByType, hasAllNullFieldsOrProperties, hasAllNullFieldsOrPropertiesExcept, hasFieldOrProperty, hasFieldOrPropertyWithValue, hasNoNullFieldsOrProperties, hasNoNullFieldsOrPropertiesExcept, hasOnlyFields, isEqualToComparingFieldByField, isEqualToComparingFieldByFieldRecursively, isEqualToComparingOnlyGivenFields, isEqualToIgnoringGivenFields, isEqualToIgnoringNullFields, newObjectAssert, returns, usingComparatorForFields, usingComparatorForType, usingRecursiveComparison, usingRecursiveComparison, withAssertionState, withComparatorByPropertyOrField, withTypeComparatorMethods inherited from class org.assertj.core.api.AbstractAssert
asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, isElementOfCustomAssert, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOf, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnErrorMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.assertj.core.api.Descriptable
as, describedAs
-
Constructor Details
-
ObjectAssert
-
ObjectAssert
-
-
Method Details
-
extracting
@SafeVarargs public final AbstractListAssert<?,List<?>, extractingObject, ObjectAssert<Object>> (Function<? super ACTUAL, ?>... extractors) Description copied from class:AbstractObjectAssertUses the givenFunctions to extract the values from the object under test into a list, this new list becoming the object under test.If the given
Functions extract the id, name and email values then the list will contain the id, name and email values of the object under test, you can then perform list assertions on the extracted values.Example:
// Create frodo, setting its name, age and Race (Race having a name property) TolkienCharacter frodo = new TolkienCharacter("Frodo", 33, HOBBIT); // let's verify Frodo's name, age and race name: assertThat(frodo).extracting(TolkienCharacter::getName, character -> character.age, // public field character -> character.getRace().getName()) .containsExactly("Frodo", 33, "Hobbit");Note that the order of extracted values is consistent with the order of given extractor functions.
- Overrides:
extractingin classAbstractObjectAssert<ObjectAssert<ACTUAL>,ACTUAL> - Parameters:
extractors- the extractor functions to extract values from the Object under test.- Returns:
- a new assertion object whose object under test is the list containing the extracted values
-