use of org.embulk.config.ConfigSource in project embulk by embulk.
the class TestRenameFilterPlugin method checkFirstCharacterTypesRuleNeitherReplacePrefix.
@Test
public void checkFirstCharacterTypesRuleNeitherReplacePrefix() {
HashMap<String, Object> parameters = new HashMap<>();
parameters.put("rule", "first_character_types");
ConfigSource config = Exec.newConfigSource().set("rules", ImmutableList.of(ImmutableMap.copyOf(parameters)));
exception.expect(ConfigException.class);
// TODO(dmikurube): Except "Caused by": exception.expectCause(instanceOf(JsonMappingException.class));
// Needs to import org.hamcrest.Matchers... in addition to org.junit...
renameAndCheckSchema(config, new String[0], new String[0]);
}
use of org.embulk.config.ConfigSource in project embulk by embulk.
the class TestRenameFilterPlugin method checkRenaming.
@Test
public void checkRenaming() {
ConfigSource pluginConfig = Exec.newConfigSource().set("columns", ImmutableMap.of("_c0", "_c0_new"));
filter.transaction(pluginConfig, SCHEMA, new FilterPlugin.Control() {
@Override
public void run(TaskSource task, Schema newSchema) {
// _c0 -> _c0_new
Column old0 = SCHEMA.getColumn(0);
Column new0 = newSchema.getColumn(0);
assertEquals("_c0_new", new0.getName());
assertEquals(old0.getType(), new0.getType());
// _c1 is not changed
Column old1 = SCHEMA.getColumn(1);
Column new1 = newSchema.getColumn(1);
assertEquals("_c1", new1.getName());
assertEquals(old1.getType(), new1.getType());
}
});
}
use of org.embulk.config.ConfigSource in project embulk by embulk.
the class TestRenameFilterPlugin method checkFirstCharacterTypesRulePrefixInternal.
private void checkFirstCharacterTypesRulePrefixInternal(final String[] original, final String[] expected, final String prefix, 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 (!prefix.equals(DEFAULT)) {
parameters.put("prefix", prefix);
}
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 checkTruncateRuleNegative.
@Test
public void checkTruncateRuleNegative() {
final String[] original = { "foo" };
ConfigSource config = Exec.newConfigSource().set("rules", ImmutableList.of(ImmutableMap.of("rule", "truncate", "max_length", -1)));
exception.expect(TaskValidationException.class);
// TODO(dmikurube): Except "Caused by": exception.expectCause(instanceOf(JsonMappingException.class));
// Needs to import org.hamcrest.Matchers... in addition to org.junit...
renameAndCheckSchema(config, original, original);
}
use of org.embulk.config.ConfigSource in project embulk by embulk.
the class TestRenameFilterPlugin method checkFirstCharacterTypesRuleBothReplacePrefix.
@Test
public void checkFirstCharacterTypesRuleBothReplacePrefix() {
HashMap<String, Object> parameters = new HashMap<>();
parameters.put("rule", "first_character_types");
parameters.put("replace", "_");
parameters.put("prefix", "_");
ConfigSource config = Exec.newConfigSource().set("rules", ImmutableList.of(ImmutableMap.copyOf(parameters)));
exception.expect(ConfigException.class);
// TODO(dmikurube): Except "Caused by": exception.expectCause(instanceOf(JsonMappingException.class));
// Needs to import org.hamcrest.Matchers... in addition to org.junit...
renameAndCheckSchema(config, new String[0], new String[0]);
}
Aggregations