Skip to content

Commit 3579dfb

Browse files
committed
Add another test
1 parent 5017c7f commit 3579dfb

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
import org.elasticsearch.ingest.TestIngestDocument;
1414
import org.elasticsearch.test.ESTestCase;
1515

16+
import java.util.Collections;
1617
import java.util.Map;
1718

1819
import static java.util.Map.entry;
20+
import static org.hamcrest.Matchers.anEmptyMap;
1921
import static org.hamcrest.Matchers.is;
2022

2123
/**
@@ -101,6 +103,23 @@ public void testError() throws Exception {
101103
}
102104
}
103105

106+
public void testIgnoreMissing() throws Exception {
107+
{
108+
var processor = new RegisteredDomainProcessor(null, null, "domain", "", false);
109+
IngestDocument document = TestIngestDocument.withDefaultVersion(Map.of());
110+
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> processor.execute(document));
111+
assertThat(e.getMessage(), is("field [domain] not present as part of path [domain]"));
112+
assertThat(document.getSource(), is(anEmptyMap()));
113+
}
114+
115+
{
116+
var processor = new RegisteredDomainProcessor(null, null, "domain", "", true);
117+
IngestDocument document = TestIngestDocument.withDefaultVersion(Collections.singletonMap("domain", null));
118+
processor.execute(document);
119+
assertThat(document.getSource(), is(Collections.singletonMap("domain", null)));
120+
}
121+
}
122+
104123
private void testRegisteredDomainProcessor(
105124
Map<String, Object> source,
106125
String expectedDomain,

0 commit comments

Comments
 (0)