|
13 | 13 | import org.elasticsearch.ingest.TestIngestDocument; |
14 | 14 | import org.elasticsearch.test.ESTestCase; |
15 | 15 |
|
| 16 | +import java.util.Collections; |
16 | 17 | import java.util.Map; |
17 | 18 |
|
18 | 19 | import static java.util.Map.entry; |
| 20 | +import static org.hamcrest.Matchers.anEmptyMap; |
19 | 21 | import static org.hamcrest.Matchers.is; |
20 | 22 |
|
21 | 23 | /** |
@@ -101,6 +103,23 @@ public void testError() throws Exception { |
101 | 103 | } |
102 | 104 | } |
103 | 105 |
|
| 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 | + |
104 | 123 | private void testRegisteredDomainProcessor( |
105 | 124 | Map<String, Object> source, |
106 | 125 | String expectedDomain, |
|
0 commit comments