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);
}
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);
}
}
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);
}
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);
}
}
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);
}
}
Aggregations