@API(status=MAINTAINED,
since="1.7")
public final class Events
extends java.lang.Object
Events is a facade that provides a fluent API for working with
events.| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
category |
private java.util.List<Event> |
events |
| Constructor and Description |
|---|
Events(java.util.List<Event> events,
java.lang.String category) |
Events(java.util.stream.Stream<Event> events,
java.lang.String category) |
| Modifier and Type | Method and Description |
|---|---|
Events |
aborted()
Get the aborted
Events contained in this Events object. |
void |
assertEventsMatchExactly(org.assertj.core.api.Condition<? super Event>... conditions)
Assert that all events contained in this
Events
object exactly match the provided conditions. |
private static void |
assertEventsMatchExactly(java.util.List<Event> events,
org.assertj.core.api.Condition<? super Event>... conditions) |
void |
assertEventsMatchLoosely(org.assertj.core.api.Condition<? super Event>... conditions)
Assert that all provided conditions are matched by an event
contained in this
Events object, regardless of order. |
private static void |
assertEventsMatchLoosely(java.util.List<Event> events,
org.assertj.core.api.Condition<? super Event>... conditions) |
void |
assertEventsMatchLooselyInOrder(org.assertj.core.api.Condition<? super Event>... conditions)
Assert that all provided conditions are matched by an event
contained in this
Events object. |
private static void |
assertEventsMatchLooselyInOrder(java.util.List<Event> events,
org.assertj.core.api.Condition<? super Event>... conditions) |
Events |
assertStatistics(java.util.function.Consumer<EventStatistics> statisticsConsumer)
Assert statistics for the events contained in this
Events object. |
org.assertj.core.api.ListAssert<Event> |
assertThatEvents()
Shortcut for
org.assertj.core.api.Assertions.assertThat(events.list()). |
private static void |
checkCondition(java.util.List<Event> events,
org.assertj.core.api.SoftAssertions softly,
org.assertj.core.api.Condition<? super Event> condition) |
long |
count()
Get the number of events contained in this
Events
object. |
Events |
debug()
Print all events to
System.out. |
Events |
debug(java.io.OutputStream out)
Print all events to the supplied
OutputStream. |
private Events |
debug(java.io.PrintWriter printWriter) |
Events |
debug(java.io.Writer writer)
Print all events to the supplied
Writer. |
Events |
dynamicallyRegistered()
Get the dynamic registration
Events contained in this
Events object. |
private java.util.stream.Stream<Event> |
eventsByType(EventType type) |
Executions |
executions()
Get the
Executions for the current set of events. |
Events |
failed()
Get the failed
Events contained in this Events object. |
java.util.stream.Stream<Event> |
filter(java.util.function.Predicate<? super Event> predicate)
Shortcut for
events.stream().filter(predicate). |
private static Event |
findEvent(java.util.List<Event> events,
org.assertj.core.api.SoftAssertions softly,
org.assertj.core.api.Condition<? super Event> condition) |
Events |
finished()
Get the finished
Events contained in this Events object. |
private java.util.stream.Stream<Event> |
finishedEventsByStatus(TestExecutionResult.Status status) |
(package private) java.lang.String |
getCategory() |
private static boolean |
isNotInIncreasingOrder(java.util.List<java.lang.Integer> indices) |
java.util.List<Event> |
list()
Get the events as a
List. |
<R> java.util.stream.Stream<R> |
map(java.util.function.Function<? super Event,? extends R> mapper)
Shortcut for
events.stream().map(mapper). |
Events |
reportingEntryPublished()
Get the reporting entry publication
Events contained in this
Events object. |
Events |
skipped()
Get the skipped
Events contained in this Events object. |
Events |
started()
Get the started
Events contained in this Events object. |
java.util.stream.Stream<Event> |
stream()
Get the events as a
Stream. |
Events |
succeeded()
Get the succeeded
Events contained in this Events object. |
private final java.util.List<Event> events
private final java.lang.String category
Events(java.util.stream.Stream<Event> events, java.lang.String category)
Events(java.util.List<Event> events, java.lang.String category)
java.lang.String getCategory()
public java.util.List<Event> list()
List.nullstream()public java.util.stream.Stream<Event> stream()
Stream.nulllist()public <R> java.util.stream.Stream<R> map(java.util.function.Function<? super Event,? extends R> mapper)
events.stream().map(mapper).mapper - a Function to apply to each event; never nullnullstream(),
Stream.map(Function)public java.util.stream.Stream<Event> filter(java.util.function.Predicate<? super Event> predicate)
events.stream().filter(predicate).predicate - a Predicate to apply to each event to decide if
it should be included in the filtered stream; never nullnullstream(),
Stream.filter(Predicate)public Executions executions()
Executions for the current set of events.Executions for the current set of events;
never nullpublic long count()
Events
object.public Events skipped()
Events contained in this Events object.Events; never nullpublic Events started()
Events contained in this Events object.Events; never nullpublic Events finished()
Events contained in this Events object.Events; never nullpublic Events aborted()
Events contained in this Events object.Events; never nullpublic Events succeeded()
Events contained in this Events object.Events; never nullpublic Events failed()
Events contained in this Events object.Events; never nullpublic Events reportingEntryPublished()
Events contained in this
Events object.Events; never nullpublic Events dynamicallyRegistered()
Events contained in this
Events object.Events; never nullpublic Events assertStatistics(java.util.function.Consumer<EventStatistics> statisticsConsumer)
Events object.
events.assertStatistics(stats -> stats.started(1).succeeded(1).failed(0));
statisticsConsumer - a Consumer of EventStatistics;
never nullEvents object for method chaining; never null@SafeVarargs public final void assertEventsMatchExactly(org.assertj.core.api.Condition<? super Event>... conditions)
Events
object exactly match the provided conditions.
Conditions can be imported statically from EventConditions
and TestExecutionResultConditions.
executionResults.testEvents().assertEventsMatchExactly(
event(test("exampleTestMethod"), started()),
event(test("exampleTestMethod"), finishedSuccessfully())
);
conditions - the conditions to match against; never nullassertEventsMatchLoosely(Condition...),
assertEventsMatchLooselyInOrder(Condition...),
EventConditions,
TestExecutionResultConditions@SafeVarargs public final void assertEventsMatchLoosely(org.assertj.core.api.Condition<? super Event>... conditions)
Events object, regardless of order.
Note that this method performs a partial match. Thus, some events may not match any of the provided conditions.
Conditions can be imported statically from EventConditions
and TestExecutionResultConditions.
executionResults.testEvents().assertEventsMatchLoosely(
event(test("exampleTestMethod"), started()),
event(test("exampleTestMethod"), finishedSuccessfully())
);
conditions - the conditions to match against; never nullassertEventsMatchExactly(Condition...),
assertEventsMatchLooselyInOrder(Condition...),
EventConditions,
TestExecutionResultConditions@SafeVarargs public final void assertEventsMatchLooselyInOrder(org.assertj.core.api.Condition<? super Event>... conditions)
Events object.
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.
Conditions can be imported statically from EventConditions
and TestExecutionResultConditions.
executionResults.testEvents().assertEventsMatchLooselyInOrder(
event(test("exampleTestMethod"), started()),
event(test("exampleTestMethod"), finishedSuccessfully())
);
conditions - the conditions to match against; never nullassertEventsMatchExactly(Condition...),
assertEventsMatchLoosely(Condition...),
EventConditions,
TestExecutionResultConditionspublic org.assertj.core.api.ListAssert<Event> assertThatEvents()
org.assertj.core.api.Assertions.assertThat(events.list()).ListAssert for events; never nullAssertions.assertThat(List),
ListAssertpublic Events debug()
System.out.Events object for method chaining; never nullpublic Events debug(java.io.OutputStream out)
OutputStream.out - the OutputStream to print to; never nullEvents object for method chaining; never nullpublic Events debug(java.io.Writer writer)
Writer.writer - the Writer to print to; never nullEvents object for method chaining; never nullprivate Events debug(java.io.PrintWriter printWriter)
private java.util.stream.Stream<Event> finishedEventsByStatus(TestExecutionResult.Status status)
@SafeVarargs private static void assertEventsMatchExactly(java.util.List<Event> events, org.assertj.core.api.Condition<? super Event>... conditions)
@SafeVarargs private static void assertEventsMatchLoosely(java.util.List<Event> events, org.assertj.core.api.Condition<? super Event>... conditions)
@SafeVarargs private static void assertEventsMatchLooselyInOrder(java.util.List<Event> events, org.assertj.core.api.Condition<? super Event>... conditions)
private static boolean isNotInIncreasingOrder(java.util.List<java.lang.Integer> indices)
private static void checkCondition(java.util.List<Event> events, org.assertj.core.api.SoftAssertions softly, org.assertj.core.api.Condition<? super Event> condition)