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>
public class ObjectAssert<ACTUAL> extends AbstractObjectAssert<ObjectAssert<ACTUAL>,ACTUAL>
Assertion methods forObject
s.To create a new instance of this class, invoke
.Assertions.assertThat(Object)
- Author:
- Yvonne Wang, Alex Ruiz, Nicolas François, Mikhail Mazursky
-
-
Field Summary
-
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, assertionErrorCreator, conditions, info, myself, objects, throwUnsupportedExceptionOnEquals
-
-
Constructor Summary
Constructors Constructor Description ObjectAssert(ACTUAL actual)
ObjectAssert(AtomicReference<ACTUAL> actual)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AbstractListAssert<?,List<?>,Object,ObjectAssert<Object>>
extracting(Function<? super ACTUAL,?>... extractors)
Uses the givenFunction
s 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, isEqualToComparingFieldByField, isEqualToComparingFieldByFieldRecursively, isEqualToComparingOnlyGivenFields, isEqualToIgnoringGivenFields, isEqualToIgnoringNullFields, newObjectAssert, returns, usingComparatorForFields, usingComparatorForType, usingRecursiveComparison, usingRecursiveComparison, withAssertionState, withComparatorByPropertyOrField, withTypeComparator
-
Methods inherited from class org.assertj.core.api.AbstractAssert
asInstanceOf, asList, asString, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, setCustomRepresentation, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, withFailMessage, withRepresentation, withThreadDumpOnError
-
-
-
-
Constructor Detail
-
ObjectAssert
public ObjectAssert(ACTUAL actual)
-
ObjectAssert
public ObjectAssert(AtomicReference<ACTUAL> actual)
-
-
Method Detail
-
extracting
@SafeVarargs public final AbstractListAssert<?,List<?>,Object,ObjectAssert<Object>> extracting(Function<? super ACTUAL,?>... extractors)
Description copied from class:AbstractObjectAssert
Uses the givenFunction
s to extract the values from the object under test into a list, this new list becoming the object under test.If the given
Function
s 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:
extracting
in 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
-
-