use of org.apache.beam.sdk.transforms.Materialization 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));
}
Aggregations