PTransformMatchers { public static PTransformMatcher stateOrTimerParDo() { return new PTransformMatcher() { @Override public boolean matches(AppliedPTransform<?, ?, ?> application) { if (PTransformTranslation.PAR_DO_TRANSFORM_URN.equals( PTransformTranslation.urnForTransformOrNull(application.getTransform()))) { try { return ParDoTranslation.usesStateOrTimers(application); } catch (IOException e) { throw new RuntimeException( String.format( "Transform with URN %s could not be translated", PTransformTranslation.PAR_DO_TRANSFORM_URN), e); } } return false; } @Override public String toString() { return MoreObjects.toStringHelper("StateOrTimerParDoMatcher").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 parDoWithState() { AppliedPTransform<?, ?, ?> statefulApplication = getAppliedTransform( ParDo.of(doFnWithState).withOutputTags(new TupleTag<>(), TupleTagList.empty())); assertThat(PTransformMatchers.stateOrTimerParDo().matches(statefulApplication), is(true)); AppliedPTransform<?, ?, ?> splittableApplication = getAppliedTransform( ParDo.of(splittableDoFn).withOutputTags(new TupleTag<>(), TupleTagList.empty())); assertThat(PTransformMatchers.stateOrTimerParDo().matches(splittableApplication), is(false)); }