use of com.amazon.dataprepper.model.record.Record in project data-prepper by opensearch-project.
the class StringPrepperTests method testStringPrepperLowerCase.
@Test
public void testStringPrepperLowerCase() {
configuration.setUpperCase(false);
final StringPrepper stringPrepper = createObjectUnderTest();
final List<Record<Event>> modifiedRecords = (List<Record<Event>>) stringPrepper.execute(TEST_RECORDS);
stringPrepper.shutdown();
final List<Event> modifiedRecordEvents = modifiedRecords.stream().map(Record::getData).collect(Collectors.toList());
assertThat(modifiedRecordEvents.size(), equalTo(2));
final Event firstEvent = modifiedRecordEvents.get(0);
final Event secondEvent = modifiedRecordEvents.get(1);
assertTrue(firstEvent.containsKey(TEST_KEY));
assertThat(firstEvent.getMetadata().getEventType(), equalTo(TEST_EVENT_TYPE));
assertThat(firstEvent.get(TEST_KEY, String.class), equalTo(UPPERCASE_TEST_STRING));
assertTrue(secondEvent.containsKey(TEST_KEY));
assertThat(secondEvent.getMetadata().getEventType(), equalTo(TEST_EVENT_TYPE));
assertThat(secondEvent.get(TEST_KEY, String.class), equalTo(LOWERCASE_TEST_STRING.toLowerCase()));
}
use of com.amazon.dataprepper.model.record.Record in project data-prepper by opensearch-project.
the class BlockingBufferTests method testBufferIsNotEmpty.
@Test
public void testBufferIsNotEmpty() throws Exception {
final PluginSetting completePluginSetting = completePluginSettingForBlockingBuffer();
final BlockingBuffer<Record<String>> blockingBuffer = new BlockingBuffer<>(completePluginSetting);
Record<String> record = new Record<>("TEST");
blockingBuffer.write(record, TEST_WRITE_TIMEOUT);
assertFalse(blockingBuffer.isEmpty());
}
use of com.amazon.dataprepper.model.record.Record in project data-prepper by opensearch-project.
the class BlockingBufferTests method testCreationUsingPluginSetting.
@Test
public void testCreationUsingPluginSetting() {
final PluginSetting completePluginSetting = completePluginSettingForBlockingBuffer();
final BlockingBuffer<Record<String>> blockingBuffer = new BlockingBuffer<>(completePluginSetting);
assertThat(blockingBuffer, notNullValue());
}
use of com.amazon.dataprepper.model.record.Record in project data-prepper by opensearch-project.
the class PipelineTests method testGetSource.
@Test
public void testGetSource() {
final Source<Record<String>> testSource = new TestSource();
final TestSink testSink = new TestSink();
final Pipeline testPipeline = new Pipeline(TEST_PIPELINE_NAME, testSource, new BlockingBuffer(TEST_PIPELINE_NAME), Collections.emptyList(), Collections.singletonList(testSink), TEST_PROCESSOR_THREADS, TEST_READ_BATCH_TIMEOUT);
assertEquals(testSource, testPipeline.getSource());
}
use of com.amazon.dataprepper.model.record.Record in project data-prepper by opensearch-project.
the class PipelineTests method testExecuteFailingSource.
@Test
public void testExecuteFailingSource() {
final Source<Record<String>> testSource = new TestSource(true);
final TestSink testSink = new TestSink();
try {
final Pipeline testPipeline = new Pipeline(TEST_PIPELINE_NAME, testSource, new BlockingBuffer(TEST_PIPELINE_NAME), Collections.emptyList(), Collections.singletonList(testSink), TEST_PROCESSOR_THREADS, TEST_READ_BATCH_TIMEOUT);
testPipeline.execute();
} catch (Exception ex) {
assertThat("Incorrect exception message", ex.getMessage().contains("Source is expected to fail"));
assertThat("Exception while starting the source should have pipeline.isStopRequested to false", !testPipeline.isStopRequested());
}
}
Aggregations