@Override public PCollectionSingletonIterableAssert<T> empty() { return containsInAnyOrder(Collections.emptyList()); }
@Override public IterableAssert<T> inEarlyGlobalWindowPanes() { return withPanes(GlobalWindow.INSTANCE, PaneExtractors.earlyPanes()); }
@Override public PCollectionSingletonIterableAssert<T> inOnTimePane(BoundedWindow window) { return withPanes(window, PaneExtractors.onTimePane()); }
@Override public PCollectionSingletonIterableAssert<T> containsInAnyOrder(Iterable<T> expectedElements) { return satisfies(new AssertContainsInAnyOrderRelation<>(), expectedElements); }
@Override public PCollectionSingletonIterableAssert<T> inCombinedNonLatePanes(BoundedWindow window) { return withPanes(window, PaneExtractors.nonLatePanes()); }
@Override public PCollectionSingletonIterableAssert<T> inEarlyPane(BoundedWindow window) { return withPanes(window, PaneExtractors.earlyPanes()); }
@Override public PCollectionSingletonIterableAssert<T> inFinalPane(BoundedWindow window) { return withPanes(window, PaneExtractors.finalPane()); }
@Override public PCollectionSingletonIterableAssert<T> inWindow(BoundedWindow window) { return withPanes(window, PaneExtractors.allPanes()); }
/** * Constructs an {@link IterableAssert} for the value of the provided {@link PCollection } with * the specified reason. The provided PCollection must contain a single {@code Iterable<T>} value. */ public static <T> IterableAssert<T> thatSingletonIterable( String reason, PCollection<? extends Iterable<T>> actual) { @SuppressWarnings("unchecked") // Safe covariant cast PCollection<Iterable<T>> actualIterables = (PCollection<Iterable<T>>) actual; return new PCollectionSingletonIterableAssert<>( actualIterables, PAssertionSite.capture(reason)); }
private PCollectionSingletonIterableAssert<T> withPanes( BoundedWindow window, SimpleFunction<Iterable<ValueInSingleWindow<Iterable<T>>>, Iterable<Iterable<T>>> paneExtractor) { @SuppressWarnings({"unchecked", "rawtypes"}) Coder<BoundedWindow> windowCoder = (Coder) actual.getWindowingStrategy().getWindowFn().windowCoder(); return new PCollectionSingletonIterableAssert<>( actual, IntoStaticWindows.of(windowCoder, window), paneExtractor, site); }
@Override @SafeVarargs public final PCollectionSingletonIterableAssert<T> containsInAnyOrder(T... expectedElements) { return containsInAnyOrder(Arrays.asList(expectedElements)); }
private PCollectionSingletonIterableAssert<T> satisfies( AssertRelation<Iterable<T>, Iterable<T>> relation, Iterable<T> expectedElements) { return satisfies( new CheckRelationAgainstExpected<>( relation, expectedElements, IterableCoder.of(elementCoder))); } }