Condition that maps the object under test and then check the resulting mapped value against its nested Condition.
Example:
Condition<String> hasLineSeparator = new Condition<>(t -> t.contains(System.lineSeparator()), "has lineSeparator");
Condition<Optional<String>> optionalWithLineSeparator = MappedCondition.mappedCondition(Optional::get, hasLineSeparator, "optional value has lineSeparator");
// assertion succeeds
assertThat(Optional.of("a" + System.lineSeparator())).is(optionalWithLineSeparator);
// returns true
optionalWithLineSeparator.matches(Optional.of("a" + System.lineSeparator()));
// assertion fails
assertThat(Optional.of("a")).is(optionalWithLineSeparator);
// returns false
optionalWithLineSeparator.matches(Optional.of("a"));
| Modifier and Type | Field and Description |
|---|---|
| private Condition | |
| private Function | |
| private String |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| protected String | Returns: the mapped condition description .the value to map from, TO the mapped value to)Build the mapped condition description when applied with the FROM and TO values. |
| private String | |
| private static String | |
| public Description | conditionDescriptionWithStatus(FROM
the instance to evaluate the condition status against. actual)Overrides org. |
| public static < the type of object the given condition accept. FROM, the type of object the nested condition accept. TO> MappedCondition | Returns: the createdMappedCondition.the Function that maps the value to test to the a value for the nested condition. mapping, Condition<TO> the nested condition to evaluate. condition, String describes the mapping, follows mappingDescription, Object... String#format(String, Object. syntax.for describing the mapping as in args)String#format(String, Object. syntax.Creates a new |
| public static < the type of object the given condition accept. FROM, the type of object the nested condition accept. TO> MappedCondition | Returns: the createdMappedCondition.the Function that maps the value to test to the a value for the nested condition. mapping, Condition<TO> the nested condition to evaluate. condition)Creates a new |
| public boolean | Returns: true if the given mapped value satisfies the nested condition; false otherwise.the value to map value)Overrides org. .
|
| condition | back to summary |
|---|---|
| private Condition<TO> condition | |
| mapping | back to summary |
|---|---|
| private Function<FROM, TO> mapping | |
| mappingDescription | back to summary |
|---|---|
| private String mappingDescription | |
| MappedCondition | back to summary |
|---|---|
| private MappedCondition(Function<FROM, TO> mapping, Condition<TO> condition, String mappingDescription) | |
| buildMappingDescription | back to summary |
|---|---|
| protected String buildMappingDescription(FROM from, TO to) Build the mapped condition description when applied with the FROM and TO values.
| |
| buildMappingDescription | back to summary |
|---|---|
| private String buildMappingDescription(FROM from, TO to, boolean withNested) | |
| className | back to summary |
|---|---|
| private static String className(Object object) | |
| conditionDescriptionWithStatus | back to summary |
|---|---|
| public Description conditionDescriptionWithStatus(FROM actual) Overrides org. Doc from org. Returns the description of this condition with its status failed or success.
| |
| mappedCondition | back to summary |
|---|---|
| public static <FROM, TO> MappedCondition Creates a new Example:
Note that the mappingDescription argument follows
| |
| mappedCondition | back to summary |
|---|---|
| public static <FROM, TO> MappedCondition Creates a new
| |
| matches | back to summary |
|---|---|
| public boolean matches(FROM value) Overrides org. Maps the value with the given function and verifies that it satisfies the nested
| |