Class PAssert.PCollectionContentsAssert<T>
- java.lang.Object
-
- org.apache.beam.sdk.testing.PAssert.PCollectionContentsAssert<T>
-
- All Implemented Interfaces:
PAssert.IterableAssert<T>
- Enclosing class:
- PAssert
protected static class PAssert.PCollectionContentsAssert<T> extends java.lang.Object implements PAssert.IterableAssert<T>
AnPAssert.IterableAssert
about the contents of aPCollection
. This does not require the runner to support side inputs.
-
-
Constructor Summary
Constructors Constructor Description PCollectionContentsAssert(PCollection<T> actual, org.apache.beam.sdk.testing.PAssert.AssertionWindows rewindowingStrategy, SimpleFunction<java.lang.Iterable<ValueInSingleWindow<T>>,java.lang.Iterable<T>> paneExtractor, PAssert.PAssertionSite site)
PCollectionContentsAssert(PCollection<T> actual, PAssert.PAssertionSite site)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description PAssert.PCollectionContentsAssert<T>
containsInAnyOrder()
Asserts that the iterable in question is empty.PAssert.PCollectionContentsAssert<T>
containsInAnyOrder(java.lang.Iterable<T> expectedElements)
Checks that theIterable
contains the expected elements, in any order.PAssert.PCollectionContentsAssert<T>
containsInAnyOrder(SerializableMatcher<? super T>... elementMatchers)
Checks that theIterable
contains elements that match the provided matchers, in any order.PAssert.PCollectionContentsAssert<T>
containsInAnyOrder(T... expectedElements)
Checks that theIterable
contains the expected elements, in any order.PAssert.PCollectionContentsAssert<T>
empty()
Asserts that the iterable in question is empty.boolean
equals(@Nullable java.lang.Object o)
Deprecated.Object.equals(Object)
is not supported on PAssert objects.int
hashCode()
Deprecated.Object.hashCode()
is not supported on PAssert objects.PAssert.PCollectionContentsAssert<T>
inCombinedNonLatePanes(BoundedWindow window)
Creates a newPAssert.IterableAssert
like this one, but with the assertion restricted to only run on the provided window across all panes that were not produced by the arrival of late data.PAssert.IterableAssert<T>
inEarlyGlobalWindowPanes()
Creates a newPAssert.IterableAssert
like this one, but with the assertion restricted to only run on panes in theGlobalWindow
that were emitted before theGlobalWindow
closed.PAssert.PCollectionContentsAssert<T>
inEarlyPane(BoundedWindow window)
Creates a newPAssert.IterableAssert
like this one, but with the assertion restricted to only run on the provided window across all panes that were produced by the arrival of early data.PAssert.PCollectionContentsAssert<T>
inFinalPane(BoundedWindow window)
Creates a newPAssert.IterableAssert
like this one, but with the assertion restricted to only run on the provided window, running the checker only on the final pane for each key.PAssert.PCollectionContentsAssert<T>
inLatePane(BoundedWindow window)
Creates a newPAssert.IterableAssert
with the assertion restricted to only run on the provided window across all panes that were produced by the arrival of late data.PAssert.PCollectionContentsAssert<T>
inOnlyPane(BoundedWindow window)
Creates a newPAssert.IterableAssert
like this one, but with the assertion restricted to only run on the provided window.PAssert.PCollectionContentsAssert<T>
inOnTimePane(BoundedWindow window)
Creates a newPAssert.IterableAssert
like this one, but with the assertion restricted to only run on the provided window.PAssert.PCollectionContentsAssert<T>
inWindow(BoundedWindow window)
Creates a newPAssert.IterableAssert
like this one, but with the assertion restricted to only run on the provided window.PAssert.PCollectionContentsAssert<T>
satisfies(SerializableFunction<java.lang.Iterable<T>,java.lang.Void> checkerFn)
Applies the provided checking function (presumably containing assertions) to the iterable in question.
-
-
-
Constructor Detail
-
PCollectionContentsAssert
public PCollectionContentsAssert(PCollection<T> actual, PAssert.PAssertionSite site)
-
PCollectionContentsAssert
public PCollectionContentsAssert(PCollection<T> actual, org.apache.beam.sdk.testing.PAssert.AssertionWindows rewindowingStrategy, SimpleFunction<java.lang.Iterable<ValueInSingleWindow<T>>,java.lang.Iterable<T>> paneExtractor, PAssert.PAssertionSite site)
-
-
Method Detail
-
inWindow
public PAssert.PCollectionContentsAssert<T> inWindow(BoundedWindow window)
Description copied from interface:PAssert.IterableAssert
Creates a newPAssert.IterableAssert
like this one, but with the assertion restricted to only run on the provided window.The assertion will concatenate all panes present in the provided window if the
Trigger
produces multiple panes. If the windowing strategy accumulates fired panes and triggers fire multple times, consider using insteadPAssert.IterableAssert.inFinalPane(BoundedWindow)
orPAssert.IterableAssert.inOnTimePane(BoundedWindow)
.- Specified by:
inWindow
in interfacePAssert.IterableAssert<T>
- Returns:
- a new
PAssert.IterableAssert
like this one but with the assertion only applied to the specified window.
-
inOnlyPane
public PAssert.PCollectionContentsAssert<T> inOnlyPane(BoundedWindow window)
Description copied from interface:PAssert.IterableAssert
Creates a newPAssert.IterableAssert
like this one, but with the assertion restricted to only run on the provided window.The assertion will expect outputs to be produced to the provided window exactly once. If the upstream
Trigger
may produce output multiple times, consider instead usingPAssert.IterableAssert.inFinalPane(BoundedWindow)
orPAssert.IterableAssert.inOnTimePane(BoundedWindow)
.- Specified by:
inOnlyPane
in interfacePAssert.IterableAssert<T>
- Returns:
- a new
PAssert.IterableAssert
like this one but with the assertion only applied to the specified window.
-
inFinalPane
public PAssert.PCollectionContentsAssert<T> inFinalPane(BoundedWindow window)
Description copied from interface:PAssert.IterableAssert
Creates a newPAssert.IterableAssert
like this one, but with the assertion restricted to only run on the provided window, running the checker only on the final pane for each key.If the input
WindowingStrategy
does not always produce final panes, the assertion may be executed over an empty input even if the trigger has fired previously. To ensure that a final pane is always produced, set theWindow.ClosingBehavior
of the windowing strategy (viaWindow.withAllowedLateness(Duration, ClosingBehavior)
settingWindow.ClosingBehavior
toWindow.ClosingBehavior.FIRE_ALWAYS
).- Specified by:
inFinalPane
in interfacePAssert.IterableAssert<T>
- Returns:
- a new
PAssert.IterableAssert
like this one but with the assertion only applied to the specified window.
-
inOnTimePane
public PAssert.PCollectionContentsAssert<T> inOnTimePane(BoundedWindow window)
Description copied from interface:PAssert.IterableAssert
Creates a newPAssert.IterableAssert
like this one, but with the assertion restricted to only run on the provided window.- Specified by:
inOnTimePane
in interfacePAssert.IterableAssert<T>
- Returns:
- a new
PAssert.IterableAssert
like this one but with the assertion only applied to the specified window.
-
inEarlyPane
public PAssert.PCollectionContentsAssert<T> inEarlyPane(BoundedWindow window)
Description copied from interface:PAssert.IterableAssert
Creates a newPAssert.IterableAssert
like this one, but with the assertion restricted to only run on the provided window across all panes that were produced by the arrival of early data.- Specified by:
inEarlyPane
in interfacePAssert.IterableAssert<T>
- Returns:
- a new
PAssert.IterableAssert
like this one but with the assertion only applied to the specified window.
-
inLatePane
public PAssert.PCollectionContentsAssert<T> inLatePane(BoundedWindow window)
Description copied from interface:PAssert.IterableAssert
Creates a newPAssert.IterableAssert
with the assertion restricted to only run on the provided window across all panes that were produced by the arrival of late data.- Specified by:
inLatePane
in interfacePAssert.IterableAssert<T>
- Returns:
- a new
PAssert.IterableAssert
like this one but with the assertion only applied to the specified window.
-
inCombinedNonLatePanes
public PAssert.PCollectionContentsAssert<T> inCombinedNonLatePanes(BoundedWindow window)
Description copied from interface:PAssert.IterableAssert
Creates a newPAssert.IterableAssert
like this one, but with the assertion restricted to only run on the provided window across all panes that were not produced by the arrival of late data.- Specified by:
inCombinedNonLatePanes
in interfacePAssert.IterableAssert<T>
- Returns:
- a new
PAssert.IterableAssert
like this one but with the assertion only applied to the specified window.
-
inEarlyGlobalWindowPanes
public PAssert.IterableAssert<T> inEarlyGlobalWindowPanes()
Description copied from interface:PAssert.IterableAssert
Creates a newPAssert.IterableAssert
like this one, but with the assertion restricted to only run on panes in theGlobalWindow
that were emitted before theGlobalWindow
closed. These panes havePaneInfo.Timing.EARLY
.- Specified by:
inEarlyGlobalWindowPanes
in interfacePAssert.IterableAssert<T>
-
containsInAnyOrder
@SafeVarargs public final PAssert.PCollectionContentsAssert<T> containsInAnyOrder(T... expectedElements)
Checks that theIterable
contains the expected elements, in any order.Returns this
IterableAssert
.- Specified by:
containsInAnyOrder
in interfacePAssert.IterableAssert<T>
- Returns:
- the same
PAssert.IterableAssert
builder for further assertions
-
containsInAnyOrder
public PAssert.PCollectionContentsAssert<T> containsInAnyOrder(java.lang.Iterable<T> expectedElements)
Checks that theIterable
contains the expected elements, in any order.Returns this
IterableAssert
.- Specified by:
containsInAnyOrder
in interfacePAssert.IterableAssert<T>
- Returns:
- the same
PAssert.IterableAssert
builder for further assertions
-
empty
public PAssert.PCollectionContentsAssert<T> empty()
Description copied from interface:PAssert.IterableAssert
Asserts that the iterable in question is empty.- Specified by:
empty
in interfacePAssert.IterableAssert<T>
- Returns:
- the same
PAssert.IterableAssert
builder for further assertions
-
satisfies
public PAssert.PCollectionContentsAssert<T> satisfies(SerializableFunction<java.lang.Iterable<T>,java.lang.Void> checkerFn)
Description copied from interface:PAssert.IterableAssert
Applies the provided checking function (presumably containing assertions) to the iterable in question.- Specified by:
satisfies
in interfacePAssert.IterableAssert<T>
- Returns:
- the same
PAssert.IterableAssert
builder for further assertions
-
containsInAnyOrder
@SafeVarargs public final PAssert.PCollectionContentsAssert<T> containsInAnyOrder(SerializableMatcher<? super T>... elementMatchers)
Checks that theIterable
contains elements that match the provided matchers, in any order.Returns this
IterableAssert
.- Specified by:
containsInAnyOrder
in interfacePAssert.IterableAssert<T>
- Returns:
- the same
PAssert.IterableAssert
builder for further assertions
-
containsInAnyOrder
public PAssert.PCollectionContentsAssert<T> containsInAnyOrder()
Description copied from interface:PAssert.IterableAssert
Asserts that the iterable in question is empty.- Specified by:
containsInAnyOrder
in interfacePAssert.IterableAssert<T>
- Returns:
- the same
PAssert.IterableAssert
builder for further assertions
-
equals
@Deprecated public boolean equals(@Nullable java.lang.Object o)
Deprecated.Object.equals(Object)
is not supported on PAssert objects. If you meant to test object equality, use a variant ofcontainsInAnyOrder(T...)
instead.- Overrides:
equals
in classjava.lang.Object
- Throws:
java.lang.UnsupportedOperationException
- always
-
hashCode
@Deprecated public int hashCode()
Deprecated.Object.hashCode()
is not supported on PAssert objects.- Overrides:
hashCode
in classjava.lang.Object
- Throws:
java.lang.UnsupportedOperationException
- always.
-
-