ACTUAL
- the type of the "actual" value.public class ObjectAssert<ACTUAL> extends AbstractObjectAssert<ObjectAssert<ACTUAL>,ACTUAL>
Object
s.
To create a new instance of this class, invoke
.
Assertions.assertThat(Object)
actual, info, myself, throwUnsupportedExceptionOnEquals
Constructor and Description |
---|
ObjectAssert(ACTUAL actual) |
ObjectAssert(AtomicReference<ACTUAL> actual) |
Modifier and Type | Method and Description |
---|---|
AbstractListAssert<?,List<? extends Object>,Object,ObjectAssert<Object>> |
extracting(Function<? super ACTUAL,Object>... extractors)
Uses the given
Function s to extract the values from the object under test into a list, this new list becoming
the object under test. |
as, as, extracting, extracting, getComparatorsByType, hasAllNullFieldsOrProperties, hasAllNullFieldsOrPropertiesExcept, hasFieldOrProperty, hasFieldOrPropertyWithValue, hasNoNullFieldsOrProperties, hasNoNullFieldsOrPropertiesExcept, isEqualToComparingFieldByField, isEqualToComparingFieldByFieldRecursively, isEqualToComparingOnlyGivenFields, isEqualToIgnoringGivenFields, isEqualToIgnoringNullFields, newObjectAssert, returns, usingComparatorForFields, usingComparatorForType, usingRecursiveComparison, usingRecursiveComparison
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
public ObjectAssert(ACTUAL actual)
public ObjectAssert(AtomicReference<ACTUAL> actual)
@SafeVarargs public final AbstractListAssert<?,List<? extends Object>,Object,ObjectAssert<Object>> extracting(Function<? super ACTUAL,Object>... extractors)
AbstractObjectAssert
Function
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.
extracting
in class AbstractObjectAssert<ObjectAssert<ACTUAL>,ACTUAL>
extractors
- the extractor functions to extract values from the Object under test.Copyright © 2014–2019 AssertJ. All rights reserved.