Skip to content

Commit 2e74f27

Browse files
committed
Add a simple test
1 parent 5ff03a1 commit 2e74f27

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/AppendProcessorTests.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,23 @@ public void testAppendingToListWithDuplicatesDisallowed() throws Exception {
180180
assertThat(fieldValue, containsInAnyOrder(expectedValues.toArray()));
181181
}
182182

183+
public void testCopyFromOtherFieldSimple() throws Exception {
184+
IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random());
185+
ingestDocument.setFieldValue("foo", 1);
186+
ingestDocument.setFieldValue("bar", 2);
187+
ingestDocument.setFieldValue("baz", new ArrayList<>(List.of(3)));
188+
189+
createAppendProcessor("bar", null, "foo", false).execute(ingestDocument);
190+
createAppendProcessor("baz", null, "bar", false).execute(ingestDocument);
191+
createAppendProcessor("quux", null, "baz", false).execute(ingestDocument);
192+
193+
Map<String, Object> result = ingestDocument.getCtxMap().getSource();
194+
assertThat(result.get("foo"), equalTo(1));
195+
assertThat(result.get("bar"), equalTo(List.of(2, 1)));
196+
assertThat(result.get("baz"), equalTo(List.of(3, 2, 1)));
197+
assertThat(result.get("quux"), equalTo(List.of(3, 2, 1)));
198+
}
199+
183200
public void testCopyFromOtherField() throws Exception {
184201
IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random());
185202

0 commit comments

Comments
 (0)