use of org.apache.camel.component.flink.annotations.AnnotatedDataSetCallback in project camel by apache.
the class FlinkProducerTest method shouldExecuteAnnotatedCallback.
@Test
public void shouldExecuteAnnotatedCallback() {
DataSetCallback dataSetCallback = new AnnotatedDataSetCallback(new Object() {
@org.apache.camel.component.flink.annotations.DataSetCallback
Long countLines(DataSet<String> textFile) {
try {
return textFile.count();
} catch (Exception e) {
return null;
}
}
});
long pomLinesCount = template.requestBodyAndHeader(flinkDataSetUri, null, FlinkConstants.FLINK_DATASET_CALLBACK_HEADER, dataSetCallback, Long.class);
Truth.assertThat(pomLinesCount).isEqualTo(19);
}
use of org.apache.camel.component.flink.annotations.AnnotatedDataSetCallback in project camel by apache.
the class FlinkProducerTest method shouldExecuteAnnotatedVoidCallback.
@Test
public void shouldExecuteAnnotatedVoidCallback() throws IOException {
final File output = File.createTempFile("camel", "flink");
output.delete();
DataSetCallback dataSetCallback = new AnnotatedDataSetCallback(new Object() {
@org.apache.camel.component.flink.annotations.DataSetCallback
void countLines(DataSet<String> textFile) {
textFile.writeAsText(output.getAbsolutePath());
}
});
template.sendBodyAndHeader(flinkDataSetUri, null, FlinkConstants.FLINK_DATASET_CALLBACK_HEADER, dataSetCallback);
Truth.assertThat(output.length()).isAtLeast(0L);
}
use of org.apache.camel.component.flink.annotations.AnnotatedDataSetCallback in project camel by apache.
the class FlinkProducerTest method shouldExecuteAnnotatedCallbackWithParameters.
@Test
public void shouldExecuteAnnotatedCallbackWithParameters() {
DataSetCallback dataSetCallback = new AnnotatedDataSetCallback(new Object() {
@org.apache.camel.component.flink.annotations.DataSetCallback
Long countLines(DataSet<String> textFile, int first, int second) {
try {
return textFile.count() * first * second;
} catch (Exception e) {
return null;
}
}
});
long pomLinesCount = template.requestBodyAndHeader(flinkDataSetUri, Arrays.<Integer>asList(10, 10), FlinkConstants.FLINK_DATASET_CALLBACK_HEADER, dataSetCallback, Long.class);
Truth.assertThat(pomLinesCount).isEqualTo(numberOfLinesInTestFile * 10 * 10);
}
Aggregations