use of org.apache.nifi.serialization.record.MockRecordWriter in project nifi by apache.
the class PutDruidRecordTest method setUp.
@Before
public void setUp() throws Exception {
runner = TestRunners.newTestRunner(PutDruidRecord.class);
druidTranquilityController = new MockDruidTranquilityController(2, 3);
recordReader = new MockRecordParser();
recordWriter = new MockRecordWriter(null, true, 2);
runner.addControllerService("reader", recordReader);
runner.enableControllerService(recordReader);
runner.addControllerService("writer", recordWriter);
runner.enableControllerService(recordWriter);
runner.addControllerService("tranquility", druidTranquilityController);
runner.setProperty(druidTranquilityController, DruidTranquilityController.DATASOURCE, "test");
runner.setProperty(druidTranquilityController, DruidTranquilityController.ZOOKEEPER_CONNECTION_STRING, "localhost:2181");
runner.setProperty(druidTranquilityController, DruidTranquilityController.AGGREGATOR_JSON, "[{\"type\": \"count\", \"name\": \"count\"}]");
runner.setProperty(druidTranquilityController, DruidTranquilityController.DIMENSIONS_LIST, "dim1,dim2");
runner.assertValid(druidTranquilityController);
runner.enableControllerService(druidTranquilityController);
runner.setProperty(PutDruidRecord.RECORD_READER_FACTORY, "reader");
runner.setProperty(PutDruidRecord.RECORD_WRITER_FACTORY, "writer");
runner.setProperty(PutDruidRecord.DRUID_TRANQUILITY_SERVICE, "tranquility");
}
use of org.apache.nifi.serialization.record.MockRecordWriter in project nifi by apache.
the class FetchParquetTest method configure.
private void configure(final FetchParquet fetchParquet) throws InitializationException {
testRunner = TestRunners.newTestRunner(fetchParquet);
testRunner.setProperty(FetchParquet.HADOOP_CONFIGURATION_RESOURCES, TEST_CONF_PATH);
final RecordSetWriterFactory writerFactory = new MockRecordWriter(RECORD_HEADER, false);
testRunner.addControllerService("mock-writer-factory", writerFactory);
testRunner.enableControllerService(writerFactory);
testRunner.setProperty(FetchParquet.RECORD_WRITER, "mock-writer-factory");
}
use of org.apache.nifi.serialization.record.MockRecordWriter in project nifi by apache.
the class TestConvertRecord method testReadFailure.
@Test
public void testReadFailure() throws InitializationException {
final MockRecordParser readerService = new MockRecordParser(2);
final MockRecordWriter writerService = new MockRecordWriter("header", false);
final TestRunner runner = TestRunners.newTestRunner(ConvertRecord.class);
runner.addControllerService("reader", readerService);
runner.enableControllerService(readerService);
runner.addControllerService("writer", writerService);
runner.enableControllerService(writerService);
runner.setProperty(ConvertRecord.RECORD_READER, "reader");
runner.setProperty(ConvertRecord.RECORD_WRITER, "writer");
readerService.addSchemaField("name", RecordFieldType.STRING);
readerService.addSchemaField("age", RecordFieldType.INT);
readerService.addRecord("John Doe", 48);
readerService.addRecord("Jane Doe", 47);
readerService.addRecord("Jimmy Doe", 14);
final MockFlowFile original = runner.enqueue("hello");
runner.run();
// Original FlowFile should be routed to 'failure' relationship without modification
runner.assertAllFlowFilesTransferred(ConvertRecord.REL_FAILURE, 1);
final MockFlowFile out = runner.getFlowFilesForRelationship(ConvertRecord.REL_FAILURE).get(0);
assertTrue(original == out);
}
use of org.apache.nifi.serialization.record.MockRecordWriter in project nifi by apache.
the class TestConvertRecord method testWriteFailure.
@Test
public void testWriteFailure() throws InitializationException {
final MockRecordParser readerService = new MockRecordParser();
final MockRecordWriter writerService = new MockRecordWriter("header", false, 2);
final TestRunner runner = TestRunners.newTestRunner(ConvertRecord.class);
runner.addControllerService("reader", readerService);
runner.enableControllerService(readerService);
runner.addControllerService("writer", writerService);
runner.enableControllerService(writerService);
runner.setProperty(ConvertRecord.RECORD_READER, "reader");
runner.setProperty(ConvertRecord.RECORD_WRITER, "writer");
readerService.addSchemaField("name", RecordFieldType.STRING);
readerService.addSchemaField("age", RecordFieldType.INT);
readerService.addRecord("John Doe", 48);
readerService.addRecord("Jane Doe", 47);
readerService.addRecord("Jimmy Doe", 14);
final MockFlowFile original = runner.enqueue("hello");
runner.run();
// Original FlowFile should be routed to 'failure' relationship without modification
runner.assertAllFlowFilesTransferred(ConvertRecord.REL_FAILURE, 1);
final MockFlowFile out = runner.getFlowFilesForRelationship(ConvertRecord.REL_FAILURE).get(0);
assertTrue(original == out);
}
use of org.apache.nifi.serialization.record.MockRecordWriter in project nifi by apache.
the class TestMergeRecord method setup.
@Before
public void setup() throws InitializationException {
runner = TestRunners.newTestRunner(new MergeRecord());
readerService = new CommaSeparatedRecordReader();
writerService = new MockRecordWriter("header", false);
runner.addControllerService("reader", readerService);
runner.enableControllerService(readerService);
runner.addControllerService("writer", writerService);
runner.enableControllerService(writerService);
runner.setProperty(MergeRecord.RECORD_READER, "reader");
runner.setProperty(MergeRecord.RECORD_WRITER, "writer");
}
Aggregations