use of org.apache.flink.connector.base.source.reader.mocks.MockSplitEnumerator in project flink by apache.
the class HybridSourceTest method testBuilderWithEnumeratorSuperclass.
@Test
public void testBuilderWithEnumeratorSuperclass() {
HybridSource.SourceFactory<Integer, Source<Integer, ?, ?>, MockSplitEnumerator> sourceFactory = (HybridSource.SourceFactory<Integer, Source<Integer, ?, ?>, MockSplitEnumerator>) context -> {
MockSplitEnumerator enumerator = context.getPreviousEnumerator();
return new MockBaseSource(1, 1, Boundedness.BOUNDED);
};
HybridSource<Integer> source = new HybridSource.HybridSourceBuilder<Integer, MockSplitEnumerator>().<ExtendedMockSplitEnumerator, Source<Integer, ?, ?>>addSource(new MockBaseSource(1, 1, Boundedness.BOUNDED)).addSource(sourceFactory, Boundedness.BOUNDED).build();
assertNotNull(source);
}
use of org.apache.flink.connector.base.source.reader.mocks.MockSplitEnumerator in project flink by apache.
the class HybridSourceSplitEnumeratorTest method testRestoreEnumerator.
@Test
public void testRestoreEnumerator() throws Exception {
setupEnumeratorAndTriggerSourceSwitch();
enumerator = (HybridSourceSplitEnumerator) source.createEnumerator(context);
enumerator.start();
HybridSourceEnumeratorState enumeratorState = enumerator.snapshotState(0);
MockSplitEnumerator underlyingEnumerator = getCurrentEnumerator(enumerator);
Assert.assertThat((List<MockSourceSplit>) Whitebox.getInternalState(underlyingEnumerator, "splits"), Matchers.iterableWithSize(1));
enumerator = (HybridSourceSplitEnumerator) source.restoreEnumerator(context, enumeratorState);
enumerator.start();
underlyingEnumerator = getCurrentEnumerator(enumerator);
Assert.assertThat((List<MockSourceSplit>) Whitebox.getInternalState(underlyingEnumerator, "splits"), Matchers.iterableWithSize(1));
}
use of org.apache.flink.connector.base.source.reader.mocks.MockSplitEnumerator in project flink by apache.
the class HybridSourceTest method testBuilderWithSourceFactory.
@Test
public void testBuilderWithSourceFactory() {
HybridSource.SourceFactory<Integer, Source<Integer, ?, ?>, MockSplitEnumerator> sourceFactory = new HybridSource.SourceFactory<Integer, Source<Integer, ?, ?>, MockSplitEnumerator>() {
@Override
public Source<Integer, ?, ?> create(HybridSource.SourceSwitchContext<MockSplitEnumerator> context) {
MockSplitEnumerator enumerator = context.getPreviousEnumerator();
return new MockBaseSource(1, 1, Boundedness.BOUNDED);
}
};
HybridSource<Integer> source = new HybridSource.HybridSourceBuilder<Integer, MockSplitEnumerator>().<MockSplitEnumerator, Source<Integer, ?, ?>>addSource(new MockBaseSource(1, 1, Boundedness.BOUNDED)).addSource(sourceFactory, Boundedness.BOUNDED).build();
assertNotNull(source);
}
Aggregations