Skip to content

Commit

Permalink
Polish test kit Events
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Sep 11, 2020
1 parent 44c6742 commit 7afbe90
Showing 1 changed file with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ public Events assertStatistics(Consumer<EventStatistics> statisticsConsumer) {
* </pre>
*
* @param conditions the conditions to match against; never {@code null}
* @see #assertEventsMatchLoosely(Condition...)
* @see #assertEventsMatchLooselyInOrder(Condition...)
* @see EventConditions
* @see TestExecutionResultConditions
*/
Expand All @@ -267,9 +269,10 @@ public final void assertEventsMatchExactly(Condition<? super Event>... condition

/**
* Assert that all provided conditions are matched by an {@linkplain Event event}
* contained in this {@code Events} object regardless of order.
* Note that this method does a partial match, i.e. some events may not match any
* of the provided conditions.
* contained in this {@code Events} object, regardless of order.
*
* <p>Note that this method performs a partial match. Thus, some events may
* not match any of the provided conditions.
*
* <p>Conditions can be imported statically from {@link EventConditions}
* and {@link TestExecutionResultConditions}.
Expand All @@ -284,8 +287,11 @@ public final void assertEventsMatchExactly(Condition<? super Event>... condition
* </pre>
*
* @param conditions the conditions to match against; never {@code null}
* @see #assertEventsMatchExactly(Condition...)
* @see #assertEventsMatchLooselyInOrder(Condition...)
* @see EventConditions
* @see TestExecutionResultConditions
* @since 1.7
*/
@SafeVarargs
@SuppressWarnings("varargs")
Expand All @@ -298,9 +304,10 @@ public final void assertEventsMatchLoosely(Condition<? super Event>... condition
/**
* Assert that all provided conditions are matched by an {@linkplain Event event}
* contained in this {@code Events} object.
* Note that this method does a partial match, i.e. some events may not match any
* of the provided conditions.
* However, the conditions provided must be in the correct order.
*
* <p>Note that this method performs a partial match. Thus, some events may
* not match any of the provided conditions; however, the conditions provided
* must be in the correct order.
*
* <p>Conditions can be imported statically from {@link EventConditions}
* and {@link TestExecutionResultConditions}.
Expand All @@ -315,8 +322,11 @@ public final void assertEventsMatchLoosely(Condition<? super Event>... condition
* </pre>
*
* @param conditions the conditions to match against; never {@code null}
* @see #assertEventsMatchExactly(Condition...)
* @see #assertEventsMatchLoosely(Condition...)
* @see EventConditions
* @see TestExecutionResultConditions
* @since 1.7
*/
@SafeVarargs
@SuppressWarnings("varargs")
Expand Down Expand Up @@ -441,9 +451,7 @@ private static boolean isNotInIncreasingOrder(List<Integer> indices) {
}

private static void checkCondition(List<Event> events, SoftAssertions softly, Condition<? super Event> condition) {
boolean matches = events.stream().anyMatch(condition::matches);

if (!matches) {
if (events.stream().noneMatch(condition::matches)) {
softly.fail("Condition did not match any event: " + condition);
}
}
Expand Down

0 comments on commit 7afbe90

Please sign in to comment.