use of org.apache.beam.sdk.runners.PTransformMatcher in project beam by apache.
the class PTransformMatchersTest method createViewWithViewFnDifferentViewFn.
@Test
public void createViewWithViewFnDifferentViewFn() {
PCollection<Integer> input = p.apply(Create.of(1));
PCollectionView<Iterable<Integer>> view = PCollectionViews.iterableView(input, input.getWindowingStrategy(), input.getCoder());
ViewFn<Iterable<WindowedValue<?>>, Iterable<Integer>> viewFn = new ViewFn<Iterable<WindowedValue<?>>, Iterable<Integer>>() {
@Override
public Materialization<Iterable<WindowedValue<?>>> getMaterialization() {
@SuppressWarnings({ "rawtypes", "unchecked" }) Materialization<Iterable<WindowedValue<?>>> materialization = (Materialization) Materializations.iterable();
return materialization;
}
@Override
public Iterable<Integer> apply(Iterable<WindowedValue<?>> contents) {
return Collections.emptyList();
}
};
CreatePCollectionView<?, ?> createView = CreatePCollectionView.of(view);
PTransformMatcher matcher = PTransformMatchers.createViewWithViewFn(viewFn.getClass());
assertThat(matcher.matches(getAppliedTransform(createView)), is(false));
}
use of org.apache.beam.sdk.runners.PTransformMatcher in project beam by apache.
the class PTransformMatchersTest method classEqualToDoesNotMatchUnrelatedClass.
@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));
}
use of org.apache.beam.sdk.runners.PTransformMatcher in project beam by apache.
the class PTransformMatchersTest method createViewWithViewFnNotCreatePCollectionView.
@Test
public void createViewWithViewFnNotCreatePCollectionView() {
PCollection<Integer> input = p.apply(Create.of(1));
PCollectionView<Iterable<Integer>> view = PCollectionViews.iterableView(input, input.getWindowingStrategy(), input.getCoder());
PTransformMatcher matcher = PTransformMatchers.createViewWithViewFn(view.getViewFn().getClass());
assertThat(matcher.matches(getAppliedTransform(View.asIterable())), is(false));
}
use of org.apache.beam.sdk.runners.PTransformMatcher in project beam by apache.
the class PTransformMatchersTest method createViewWithViewFn.
@Test
public void createViewWithViewFn() {
PCollection<Integer> input = p.apply(Create.of(1));
PCollectionView<Iterable<Integer>> view = PCollectionViews.iterableView(input, input.getWindowingStrategy(), input.getCoder());
ViewFn<Iterable<WindowedValue<?>>, Iterable<Integer>> viewFn = view.getViewFn();
CreatePCollectionView<?, ?> createView = CreatePCollectionView.of(view);
PTransformMatcher matcher = PTransformMatchers.createViewWithViewFn(viewFn.getClass());
assertThat(matcher.matches(getAppliedTransform(createView)), is(true));
}
use of org.apache.beam.sdk.runners.PTransformMatcher in project beam by apache.
the class PTransformMatchersTest method parDoWithFnTypeNotParDo.
@Test
public void parDoWithFnTypeNotParDo() {
AppliedPTransform<?, ?, ?> notParDo = getAppliedTransform(Create.empty(VoidCoder.of()));
PTransformMatcher matcher = PTransformMatchers.parDoWithFnType(doFnWithState.getClass());
assertThat(matcher.matches(notParDo), is(false));
}
Aggregations