Search in sources :

Example 11 with ConfigSource

use of org.embulk.config.ConfigSource in project embulk by embulk.

the class TestRenameFilterPlugin method checkRuleUpperToLowerRule.

@Test
public void checkRuleUpperToLowerRule() {
    final String[] original = { "_C0", "_C1", "_c2" };
    final String[] expected = { "_c0", "_c1", "_c2" };
    ConfigSource config = Exec.newConfigSource().set("rules", ImmutableList.of(ImmutableMap.of("rule", "upper_to_lower")));
    renameAndCheckSchema(config, original, expected);
}
Also used : ConfigSource(org.embulk.config.ConfigSource) Test(org.junit.Test)

Example 12 with ConfigSource

use of org.embulk.config.ConfigSource in project embulk by embulk.

the class TestRenameFilterPlugin method checkConfigExceptionIfUnknownRenamingOperatorName.

@Test
public void checkConfigExceptionIfUnknownRenamingOperatorName() {
    ConfigSource pluginConfig = Exec.newConfigSource().set("rules", ImmutableList.of(ImmutableMap.of("rule", "some_unknown_renaming_operator")));
    try {
        filter.transaction(pluginConfig, SCHEMA, new FilterPlugin.Control() {

            public void run(TaskSource task, Schema schema) {
            }
        });
        fail();
    } catch (Throwable t) {
        assertTrue(t instanceof ConfigException);
    }
}
Also used : ConfigSource(org.embulk.config.ConfigSource) FilterPlugin(org.embulk.spi.FilterPlugin) Schema(org.embulk.spi.Schema) ConfigException(org.embulk.config.ConfigException) SchemaConfigException(org.embulk.spi.SchemaConfigException) TaskSource(org.embulk.config.TaskSource) Test(org.junit.Test)

Example 13 with ConfigSource

use of org.embulk.config.ConfigSource in project embulk by embulk.

the class TestRenameFilterPlugin method checkFirstCharacterTypesRuleReplaceInternal.

private void checkFirstCharacterTypesRuleReplaceInternal(final String[] original, final String[] expected, final String replace, final String[] pass_types, final String pass_characters) {
    HashMap<String, Object> parameters = new HashMap<>();
    parameters.put("rule", "first_character_types");
    if (pass_types.length > 0) {
        parameters.put("pass_types", Arrays.asList(pass_types));
    }
    if (!pass_characters.equals(DEFAULT)) {
        parameters.put("pass_characters", pass_characters);
    }
    if (!replace.equals(DEFAULT)) {
        parameters.put("replace", replace);
    }
    ConfigSource config = Exec.newConfigSource().set("rules", ImmutableList.of(ImmutableMap.copyOf(parameters)));
    renameAndCheckSchema(config, original, expected);
}
Also used : ConfigSource(org.embulk.config.ConfigSource) HashMap(java.util.HashMap)

Example 14 with ConfigSource

use of org.embulk.config.ConfigSource in project embulk by embulk.

the class TestRenameFilterPlugin method throwSchemaConfigExceptionIfColumnNotFound.

@Test
public void throwSchemaConfigExceptionIfColumnNotFound() {
    ConfigSource pluginConfig = Exec.newConfigSource().set("columns", ImmutableMap.of("not_found", "any_name"));
    try {
        filter.transaction(pluginConfig, SCHEMA, new FilterPlugin.Control() {

            public void run(TaskSource task, Schema schema) {
            }
        });
        fail();
    } catch (Throwable t) {
        assertTrue(t instanceof SchemaConfigException);
    }
}
Also used : ConfigSource(org.embulk.config.ConfigSource) FilterPlugin(org.embulk.spi.FilterPlugin) Schema(org.embulk.spi.Schema) TaskSource(org.embulk.config.TaskSource) SchemaConfigException(org.embulk.spi.SchemaConfigException) Test(org.junit.Test)

Example 15 with ConfigSource

use of org.embulk.config.ConfigSource in project embulk by embulk.

the class TestRenameFilterPlugin method checkConfigExceptionIfUnknownListTypeOfRenamingOperator.

@Test
public void checkConfigExceptionIfUnknownListTypeOfRenamingOperator() {
    // A list [] shouldn't come as a renaming rule.
    ConfigSource pluginConfig = Exec.newConfigSource().set("rules", ImmutableList.of(ImmutableList.of("listed_operator1", "listed_operator2")));
    try {
        filter.transaction(pluginConfig, SCHEMA, new FilterPlugin.Control() {

            public void run(TaskSource task, Schema schema) {
            }
        });
        fail();
    } catch (Throwable t) {
        assertTrue(t instanceof ConfigException);
    }
}
Also used : ConfigSource(org.embulk.config.ConfigSource) FilterPlugin(org.embulk.spi.FilterPlugin) Schema(org.embulk.spi.Schema) ConfigException(org.embulk.config.ConfigException) SchemaConfigException(org.embulk.spi.SchemaConfigException) TaskSource(org.embulk.config.TaskSource) Test(org.junit.Test)

Aggregations

ConfigSource (org.embulk.config.ConfigSource)50 Test (org.junit.Test)33 TaskSource (org.embulk.config.TaskSource)12 Schema (org.embulk.spi.Schema)9 HashMap (java.util.HashMap)8 ArrayList (java.util.ArrayList)6 List (java.util.List)6 ConfigDiff (org.embulk.config.ConfigDiff)6 FilterPlugin (org.embulk.spi.FilterPlugin)6 ImmutableList (com.google.common.collect.ImmutableList)5 SchemaConfigException (org.embulk.spi.SchemaConfigException)4 ConfigException (org.embulk.config.ConfigException)3 Column (org.embulk.spi.Column)3 InputPlugin (org.embulk.spi.InputPlugin)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 IOException (java.io.IOException)2 Path (java.nio.file.Path)2 LinkedList (java.util.LinkedList)2 DataSource (org.embulk.config.DataSource)2 TaskReport (org.embulk.config.TaskReport)2