Search in sources :

Example 1 with TestingEmbulk

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)));
}
Also used : Path(java.nio.file.Path) ConfigSource(org.embulk.config.ConfigSource) TestingEmbulk(org.embulk.test.TestingEmbulk) PreviewResult(org.embulk.exec.PreviewResult)

Example 2 with TestingEmbulk

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)));
}
Also used : Path(java.nio.file.Path) ConfigSource(org.embulk.config.ConfigSource) TestingEmbulk(org.embulk.test.TestingEmbulk)

Aggregations

Path (java.nio.file.Path)2 ConfigSource (org.embulk.config.ConfigSource)2 TestingEmbulk (org.embulk.test.TestingEmbulk)2 PreviewResult (org.embulk.exec.PreviewResult)1