diff --git a/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/CsvProcessor.java b/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/CsvProcessor.java index 98e71b955a4c1..07ab92d258155 100644 --- a/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/CsvProcessor.java +++ b/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/CsvProcessor.java @@ -45,13 +45,14 @@ public final class CsvProcessor extends AbstractProcessor { public static final String TYPE = "csv"; - private final String field; - private final String[] headers; - private final boolean trim; - private final char quote; - private final char separator; - private final boolean ignoreMissing; - private final Object emptyValue; + //visible for testing + final String field; + final String[] headers; + final boolean trim; + final char quote; + final char separator; + final boolean ignoreMissing; + final Object emptyValue; CsvProcessor(String tag, String field, String[] headers, boolean trim, char separator, char quote, boolean ignoreMissing, Object emptyValue) { @@ -101,7 +102,7 @@ public CsvProcessor create(Map properties = new HashMap<>(); + properties.put("field", "field"); + properties.put("target_fields", Collections.singletonList("target")); + properties.put("quote", "|"); + properties.put("separator", "/"); + properties.put("empty_value", "empty"); + properties.put("trim", true); + properties.put("ignore_missing", true); + CsvProcessor csv = factory.create(null, "csv", properties); + assertThat(csv, notNullValue()); + assertThat(csv.field, equalTo("field")); + assertThat(csv.headers, equalTo(new String[]{"target"})); + assertThat(csv.quote, equalTo('|')); + assertThat(csv.separator, equalTo('/')); + assertThat(csv.emptyValue, equalTo("empty")); + assertThat(csv.trim, equalTo(true)); + assertThat(csv.ignoreMissing, equalTo(true)); + assertThat(properties, is(emptyMap())); + } +}