use of org.embulk.test.TestingEmbulk in project embulk by embulk.
the class TestFilePreview method assertPreviewedRecords.
private static void assertPreviewedRecords(TestingEmbulk embulk, String loadYamlResourceName, String execYamlResourceName, String sourceCsvResourceName, String resultCsvResourceName) throws IOException {
Path inputPath = embulk.createTempFile("csv");
Path outputPath = embulk.createTempFile("csv");
// in: config
copyResource(RESOURCE_NAME_PREFIX + sourceCsvResourceName, inputPath);
ConfigSource load = embulk.loadYamlResource(RESOURCE_NAME_PREFIX + loadYamlResourceName).set("path_prefix", inputPath.toAbsolutePath().toString());
// exec: config
final TestingEmbulk.InputBuilder builder = embulk.inputBuilder();
if (execYamlResourceName != null) {
final ConfigSource execConfig = embulk.loadYamlResource(RESOURCE_NAME_PREFIX + execYamlResourceName);
builder.exec(execConfig);
}
// execute preview
final PreviewResult result = builder.in(load).outputPath(outputPath).preview();
assertThat(readFile(outputPath), is(readResource(RESOURCE_NAME_PREFIX + resultCsvResourceName)));
}
use of org.embulk.test.TestingEmbulk in project embulk by embulk.
the class TestRemoveColumnsFilterPlugin method assertRecordsByResource.
static void assertRecordsByResource(TestingEmbulk embulk, String inConfigYamlResourceName, String filterConfigYamlResourceName, String sourceCsvResourceName, String resultCsvResourceName) throws IOException {
Path inputPath = embulk.createTempFile("csv");
Path outputPath = embulk.createTempFile("csv");
// in: config
copyResource(RESOURCE_NAME_PREFIX + sourceCsvResourceName, inputPath);
ConfigSource inConfig = embulk.loadYamlResource(RESOURCE_NAME_PREFIX + inConfigYamlResourceName).set("path_prefix", inputPath.toAbsolutePath().toString());
// remove_columns filter config
ConfigSource filterConfig = embulk.loadYamlResource(RESOURCE_NAME_PREFIX + filterConfigYamlResourceName);
TestingEmbulk.RunResult result = embulk.inputBuilder().in(inConfig).filters(ImmutableList.of(filterConfig)).outputPath(outputPath).run();
assertThat(readSortedFile(outputPath), is(readResource(RESOURCE_NAME_PREFIX + resultCsvResourceName)));
}
Aggregations