PTransformMatchers { public static PTransformMatcher emptyFlatten() { return new PTransformMatcher() { @Override public boolean matches(AppliedPTransform<?, ?, ?> application) { return (application.getTransform() instanceof Flatten.PCollections) && application.getInputs().isEmpty(); } @Override public String toString() { return MoreObjects.toStringHelper("EmptyFlattenMatcher").toString(); } }; } private  PTransformMatchers(); static PTransformMatcher urnEqualTo(String urn); static PTransformMatcher classEqualTo(Class<? extends PTransform> clazz); static PTransformMatcher requiresStableInputParDoSingle(); static PTransformMatcher requiresStableInputParDoMulti(); static PTransformMatcher splittableParDoSingle(); static PTransformMatcher stateOrTimerParDoSingle(); static PTransformMatcher splittableParDoMulti(); static PTransformMatcher splittableParDo(); static PTransformMatcher splittableProcessKeyedBounded(); static PTransformMatcher splittableProcessKeyedUnbounded(); static PTransformMatcher stateOrTimerParDo(); static PTransformMatcher stateOrTimerParDoMulti(); static PTransformMatcher parDoWithFnType(final Class<? extends DoFn> fnType); static PTransformMatcher createViewWithViewFn(final Class<? extends ViewFn> viewFnType); static PTransformMatcher emptyFlatten(); static PTransformMatcher flattenWithDuplicateInputs(); static PTransformMatcher groupWithShardableStates(); static PTransformMatcher writeWithRunnerDeterminedSharding();  }
@Test public void emptyFlattenWithEmptyFlatten() { AppliedPTransform application = AppliedPTransform.of( "EmptyFlatten", Collections.emptyMap(), Collections.singletonMap( new TupleTag<Integer>(), PCollection.createPrimitiveOutputInternal( p, WindowingStrategy.globalDefault(), IsBounded.BOUNDED, VarIntCoder.of())), Flatten.pCollections(), p); assertThat(PTransformMatchers.emptyFlatten().matches(application), is(true)); }
@Test public void emptyFlattenWithNonEmptyFlatten() { AppliedPTransform application = AppliedPTransform.of( "Flatten", Collections.singletonMap( new TupleTag<Integer>(), PCollection.createPrimitiveOutputInternal( p, WindowingStrategy.globalDefault(), IsBounded.BOUNDED, VarIntCoder.of())), Collections.singletonMap( new TupleTag<Integer>(), PCollection.createPrimitiveOutputInternal( p, WindowingStrategy.globalDefault(), IsBounded.BOUNDED, VarIntCoder.of())), Flatten.pCollections(), p); assertThat(PTransformMatchers.emptyFlatten().matches(application), is(false)); }
@Test public void emptyFlattenWithNonFlatten() { AppliedPTransform application = AppliedPTransform .<PCollection<Iterable<Integer>>, PCollection<Integer>, Flatten.Iterables<Integer>>of( "EmptyFlatten", Collections.emptyMap(), Collections.singletonMap( new TupleTag<Integer>(), PCollection.createPrimitiveOutputInternal( p, WindowingStrategy.globalDefault(), IsBounded.BOUNDED, VarIntCoder.of())), Flatten.iterables(), p); assertThat(PTransformMatchers.emptyFlatten().matches(application), is(false)); }