fixed compiler warnining and removed unused imports
This commit is contained in:
parent
81112508ea
commit
7b36a72ccb
|
@ -23,18 +23,13 @@ import org.elasticsearch.ingest.AbstractProcessor;
|
||||||
import org.elasticsearch.ingest.ConfigurationUtils;
|
import org.elasticsearch.ingest.ConfigurationUtils;
|
||||||
import org.elasticsearch.ingest.IngestDocument;
|
import org.elasticsearch.ingest.IngestDocument;
|
||||||
import org.elasticsearch.ingest.Processor;
|
import org.elasticsearch.ingest.Processor;
|
||||||
import org.elasticsearch.ingest.Processor;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.elasticsearch.ingest.ConfigurationUtils.newConfigurationException;
|
import static org.elasticsearch.ingest.ConfigurationUtils.newConfigurationException;
|
||||||
import static org.elasticsearch.ingest.ConfigurationUtils.readList;
|
|
||||||
import static org.elasticsearch.ingest.ConfigurationUtils.readMap;
|
import static org.elasticsearch.ingest.ConfigurationUtils.readMap;
|
||||||
import static org.elasticsearch.ingest.ConfigurationUtils.readStringProperty;
|
import static org.elasticsearch.ingest.ConfigurationUtils.readStringProperty;
|
||||||
|
|
||||||
|
@ -59,7 +54,7 @@ public final class ForEachProcessor extends AbstractProcessor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(IngestDocument ingestDocument) throws Exception {
|
public void execute(IngestDocument ingestDocument) throws Exception {
|
||||||
List<Object> values = ingestDocument.getFieldValue(field, List.class);
|
List values = ingestDocument.getFieldValue(field, List.class);
|
||||||
List<Object> newValues = new ArrayList<>(values.size());
|
List<Object> newValues = new ArrayList<>(values.size());
|
||||||
for (Object value : values) {
|
for (Object value : values) {
|
||||||
Object previousValue = ingestDocument.getIngestMetadata().put("_value", value);
|
Object previousValue = ingestDocument.getIngestMetadata().put("_value", value);
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class ForEachProcessorTests extends ESTestCase {
|
||||||
);
|
);
|
||||||
processor.execute(ingestDocument);
|
processor.execute(ingestDocument);
|
||||||
|
|
||||||
List<String> result = ingestDocument.getFieldValue("values", List.class);
|
List result = ingestDocument.getFieldValue("values", List.class);
|
||||||
assertThat(result.get(0), equalTo("FOO"));
|
assertThat(result.get(0), equalTo("FOO"));
|
||||||
assertThat(result.get(1), equalTo("BAR"));
|
assertThat(result.get(1), equalTo("BAR"));
|
||||||
assertThat(result.get(2), equalTo("BAZ"));
|
assertThat(result.get(2), equalTo("BAZ"));
|
||||||
|
@ -176,9 +176,9 @@ public class ForEachProcessorTests extends ESTestCase {
|
||||||
|
|
||||||
ForEachProcessor processor = new ForEachProcessor("_tag", "values", innerProcessor);
|
ForEachProcessor processor = new ForEachProcessor("_tag", "values", innerProcessor);
|
||||||
processor.execute(ingestDocument);
|
processor.execute(ingestDocument);
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
List<String> result = ingestDocument.getFieldValue("values", List.class);
|
List<String> result = ingestDocument.getFieldValue("values", List.class);
|
||||||
assertThat(result.size(), equalTo(numValues));
|
assertThat(result.size(), equalTo(numValues));
|
||||||
|
|
||||||
for (String r : result) {
|
for (String r : result) {
|
||||||
assertThat(r, equalTo("."));
|
assertThat(r, equalTo("."));
|
||||||
}
|
}
|
||||||
|
@ -203,12 +203,12 @@ public class ForEachProcessorTests extends ESTestCase {
|
||||||
));
|
));
|
||||||
processor.execute(ingestDocument);
|
processor.execute(ingestDocument);
|
||||||
|
|
||||||
List<Object> result = ingestDocument.getFieldValue("values", List.class);
|
List result = ingestDocument.getFieldValue("values", List.class);
|
||||||
assertThat(result.get(0), equalTo("STRING"));
|
assertThat(result.get(0), equalTo("STRING"));
|
||||||
assertThat(result.get(1), equalTo(1));
|
assertThat(result.get(1), equalTo(1));
|
||||||
assertThat(result.get(2), equalTo(null));
|
assertThat(result.get(2), equalTo(null));
|
||||||
|
|
||||||
List<String> errors = ingestDocument.getFieldValue("errors", List.class);
|
List errors = ingestDocument.getFieldValue("errors", List.class);
|
||||||
assertThat(errors.size(), equalTo(2));
|
assertThat(errors.size(), equalTo(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ public class ForEachProcessorTests extends ESTestCase {
|
||||||
ForEachProcessor forEachProcessor = new ForEachProcessor("_tag", "values", processor);
|
ForEachProcessor forEachProcessor = new ForEachProcessor("_tag", "values", processor);
|
||||||
forEachProcessor.execute(ingestDocument);
|
forEachProcessor.execute(ingestDocument);
|
||||||
|
|
||||||
List<String> result = ingestDocument.getFieldValue("values", List.class);
|
List result = ingestDocument.getFieldValue("values", List.class);
|
||||||
assertThat(result.get(0), equalTo("new_value"));
|
assertThat(result.get(0), equalTo("new_value"));
|
||||||
assertThat(result.get(1), equalTo("new_value"));
|
assertThat(result.get(1), equalTo("new_value"));
|
||||||
assertThat(result.get(2), equalTo("new_value"));
|
assertThat(result.get(2), equalTo("new_value"));
|
||||||
|
@ -262,7 +262,7 @@ public class ForEachProcessorTests extends ESTestCase {
|
||||||
"_tag", "values1", new ForEachProcessor("_tag", "_ingest._value.values2", testProcessor));
|
"_tag", "values1", new ForEachProcessor("_tag", "_ingest._value.values2", testProcessor));
|
||||||
processor.execute(ingestDocument);
|
processor.execute(ingestDocument);
|
||||||
|
|
||||||
List<String> result = ingestDocument.getFieldValue("values1.0.values2", List.class);
|
List result = ingestDocument.getFieldValue("values1.0.values2", List.class);
|
||||||
assertThat(result.get(0), equalTo("ABC"));
|
assertThat(result.get(0), equalTo("ABC"));
|
||||||
assertThat(result.get(1), equalTo("DEF"));
|
assertThat(result.get(1), equalTo("DEF"));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue