PTransformMatchers { public static PTransformMatcher classEqualTo(Class<? extends PTransform> clazz) { return new EqualClassPTransformMatcher(clazz); } 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 classEqualToMatchesSameClass() { PTransformMatcher matcher = PTransformMatchers.classEqualTo(ParDo.SingleOutput.class); AppliedPTransform<?, ?, ?> application = getAppliedTransform( ParDo.of( new DoFn<KV<String, Integer>, Integer>() { @ProcessElement public void doStuff(ProcessContext ctxt) {} })); assertThat(matcher.matches(application), is(true)); }
@Test public void classEqualToDoesNotMatchSubclass() { class MyPTransform extends PTransform<PCollection<KV<String, Integer>>, PCollection<Integer>> { @Override public PCollection<Integer> expand(PCollection<KV<String, Integer>> input) { return PCollection.createPrimitiveOutputInternal( input.getPipeline(), input.getWindowingStrategy(), input.isBounded(), VarIntCoder.of()); } } PTransformMatcher matcher = PTransformMatchers.classEqualTo(MyPTransform.class); MyPTransform subclass = new MyPTransform() {}; assertThat(subclass.getClass(), not(Matchers.<Class<?>>equalTo(MyPTransform.class))); assertThat(subclass, instanceOf(MyPTransform.class)); AppliedPTransform<?, ?, ?> application = getAppliedTransform(subclass); assertThat(matcher.matches(application), is(false)); }
@Test public void classEqualToDoesNotMatchUnrelatedClass() { PTransformMatcher matcher = PTransformMatchers.classEqualTo(ParDo.SingleOutput.class); AppliedPTransform<?, ?, ?> application = getAppliedTransform(Window.<KV<String, Integer>>into(new GlobalWindows())); assertThat(matcher.matches(application), is(false)); }