use of com.urbanairship.connect.java8.Consumer in project components by Talend.
the class JDBCDatasetOracleTestIT method getSampleAction.
private void getSampleAction(JDBCDatasetProperties dataset) {
JDBCDatasetRuntime runtime = new JDBCDatasetRuntime();
runtime.initialize(null, dataset);
final IndexedRecord[] record = new IndexedRecord[1];
Consumer<IndexedRecord> storeTheRecords = new Consumer<IndexedRecord>() {
@Override
public void accept(IndexedRecord data) {
record[0] = data;
}
};
runtime.getSample(1, storeTheRecords);
Assert.assertEquals(new BigDecimal("1"), record[0].get(0));
Assert.assertEquals("wangwei", record[0].get(1));
}
use of com.urbanairship.connect.java8.Consumer in project components by Talend.
the class JdbcDatasetTestIT method getSampleAction.
private void getSampleAction(JDBCDatasetProperties dataset) {
JDBCDatasetRuntime runtime = new JDBCDatasetRuntime();
runtime.initialize(null, dataset);
final IndexedRecord[] record = new IndexedRecord[1];
Consumer<IndexedRecord> storeTheRecords = new Consumer<IndexedRecord>() {
@Override
public void accept(IndexedRecord data) {
record[0] = data;
}
};
runtime.getSample(1, storeTheRecords);
Assert.assertEquals("1", record[0].get(0));
Assert.assertEquals("wangwei", record[0].get(1));
}
use of com.urbanairship.connect.java8.Consumer in project components by Talend.
the class ReaderDataProviderTest method testReaderDataProviderWithLimitTo1.
@Test
public void testReaderDataProviderWithLimitTo1() throws IOException {
Reader<String> reader = spy(new OneTwoReader());
Consumer consumer = mock(Consumer.class);
ReaderDataProvider<String> readerDataProvider = new ReaderDataProvider<>(reader, 1, consumer);
readerDataProvider.retrieveData();
verify(consumer).accept("1");
verify(consumer, times(1)).accept(any());
verify(reader, times(1)).close();
}
use of com.urbanairship.connect.java8.Consumer in project components by Talend.
the class ReaderDataProviderTest method testReaderDataProviderWithRecords.
@Test
public void testReaderDataProviderWithRecords() throws IOException {
Reader<String> reader = spy(new OneTwoReader());
Consumer consumer = mock(Consumer.class);
ReaderDataProvider<String> readerDataProvider = new ReaderDataProvider<>(reader, 100, consumer);
readerDataProvider.retrieveData();
verify(consumer).accept("1");
verify(consumer).accept("2");
verify(consumer, times(2)).accept(any());
verify(reader, times(1)).close();
}
use of com.urbanairship.connect.java8.Consumer in project components by Talend.
the class ReaderDataProviderTest method testProviderEmptyReader.
@Test
public void testProviderEmptyReader() throws IOException {
Reader readerMock = mock(Reader.class);
when(readerMock.start()).thenReturn(false);
Consumer consumer = mock(Consumer.class);
ReaderDataProvider<Object> readerDataProvider = new ReaderDataProvider<>(readerMock, 100, consumer);
readerDataProvider.retrieveData();
verify(consumer, times(0)).accept(any());
verify(readerMock, times(1)).close();
}
Aggregations