@@ -26,15 +26,15 @@ public class DotExpanderProcessorTests extends ESTestCase {
2626 public void testEscapeFields () throws Exception {
2727 Map <String , Object > source = new HashMap <>();
2828 source .put ("foo.bar" , "baz1" );
29- IngestDocument document = TestIngestDocument .ofSourceAndMetadata (source );
29+ IngestDocument document = TestIngestDocument .withDefaultVersion (source );
3030 DotExpanderProcessor processor = new DotExpanderProcessor ("_tag" , null , null , "foo.bar" );
3131 processor .execute (document );
3232 assertThat (document .getFieldValue ("foo" , Map .class ).size (), equalTo (1 ));
3333 assertThat (document .getFieldValue ("foo.bar" , String .class ), equalTo ("baz1" ));
3434
3535 source = new HashMap <>();
3636 source .put ("foo.bar.baz" , "value" );
37- document = TestIngestDocument .ofSourceAndMetadata (source );
37+ document = TestIngestDocument .withDefaultVersion (source );
3838 processor = new DotExpanderProcessor ("_tag" , null , null , "foo.bar.baz" );
3939 processor .execute (document );
4040 assertThat (document .getFieldValue ("foo" , Map .class ).size (), equalTo (1 ));
@@ -44,21 +44,23 @@ public void testEscapeFields() throws Exception {
4444 source = new HashMap <>();
4545 source .put ("foo.bar" , "baz1" );
4646 source .put ("foo" , new HashMap <>(Collections .singletonMap ("bar" , "baz2" )));
47- document = TestIngestDocument .ofSourceAndMetadata (source );
47+ document = TestIngestDocument .withDefaultVersion (source );
4848 processor = new DotExpanderProcessor ("_tag" , null , null , "foo.bar" );
4949 processor .execute (document );
50- assertThat (document .getSourceAndMetadata ().size (), equalTo (1 ));
50+ assertThat (document .getSource ().size (), equalTo (1 ));
51+ assertThat (document .getMetadata ().size (), equalTo (1 )); // the default version
5152 assertThat (document .getFieldValue ("foo.bar" , List .class ).size (), equalTo (2 ));
5253 assertThat (document .getFieldValue ("foo.bar.0" , String .class ), equalTo ("baz2" ));
5354 assertThat (document .getFieldValue ("foo.bar.1" , String .class ), equalTo ("baz1" ));
5455
5556 source = new HashMap <>();
5657 source .put ("foo.bar" , "2" );
5758 source .put ("foo" , new HashMap <>(Collections .singletonMap ("bar" , 1 )));
58- document = TestIngestDocument .ofSourceAndMetadata (source );
59+ document = TestIngestDocument .withDefaultVersion (source );
5960 processor = new DotExpanderProcessor ("_tag" , null , null , "foo.bar" );
6061 processor .execute (document );
61- assertThat (document .getSourceAndMetadata ().size (), equalTo (1 ));
62+ assertThat (document .getSource ().size (), equalTo (1 ));
63+ assertThat (document .getMetadata ().size (), equalTo (1 )); // the default version
6264 assertThat (document .getFieldValue ("foo.bar" , List .class ).size (), equalTo (2 ));
6365 assertThat (document .getFieldValue ("foo.bar.0" , Integer .class ), equalTo (1 ));
6466 assertThat (document .getFieldValue ("foo.bar.1" , String .class ), equalTo ("2" ));
@@ -68,15 +70,15 @@ public void testEscapeFields_valueField() throws Exception {
6870 Map <String , Object > source = new HashMap <>();
6971 source .put ("foo.bar" , "baz1" );
7072 source .put ("foo" , "baz2" );
71- IngestDocument document1 = TestIngestDocument .ofSourceAndMetadata (source );
73+ IngestDocument document1 = TestIngestDocument .withDefaultVersion (source );
7274 Processor processor1 = new DotExpanderProcessor ("_tag" , null , null , "foo.bar" );
7375 // foo already exists and if a leaf field and therefor can't be replaced by a map field:
7476 Exception e = expectThrows (IllegalArgumentException .class , () -> processor1 .execute (document1 ));
7577 assertThat (e .getMessage (), equalTo ("cannot expand [foo.bar], because [foo] is not an object field, but a value field" ));
7678
7779 // so because foo is no branch field but a value field the `foo.bar` field can't be expanded
7880 // into [foo].[bar], so foo should be renamed first into `[foo].[bar]:
79- IngestDocument document = TestIngestDocument .ofSourceAndMetadata (source );
81+ IngestDocument document = TestIngestDocument .withDefaultVersion (source );
8082 Processor processor = new RenameProcessor (
8183 "_tag" ,
8284 null ,
@@ -93,7 +95,7 @@ public void testEscapeFields_valueField() throws Exception {
9395
9496 source = new HashMap <>();
9597 source .put ("foo.bar" , "baz1" );
96- document = TestIngestDocument .ofSourceAndMetadata (source );
98+ document = TestIngestDocument .withDefaultVersion (source );
9799 processor = new DotExpanderProcessor ("_tag" , null , null , "foo.bar" );
98100 processor .execute (document );
99101 assertThat (document .getFieldValue ("foo" , Map .class ).size (), equalTo (1 ));
@@ -102,7 +104,7 @@ public void testEscapeFields_valueField() throws Exception {
102104 source = new HashMap <>();
103105 source .put ("foo.bar.baz" , "baz1" );
104106 source .put ("foo" , new HashMap <>(Collections .singletonMap ("bar" , new HashMap <>())));
105- document = TestIngestDocument .ofSourceAndMetadata (source );
107+ document = TestIngestDocument .withDefaultVersion (source );
106108 processor = new DotExpanderProcessor ("_tag" , null , null , "foo.bar.baz" );
107109 processor .execute (document );
108110 assertThat (document .getFieldValue ("foo" , Map .class ).size (), equalTo (1 ));
@@ -112,7 +114,7 @@ public void testEscapeFields_valueField() throws Exception {
112114 source = new HashMap <>();
113115 source .put ("foo.bar.baz" , "baz1" );
114116 source .put ("foo" , new HashMap <>(Collections .singletonMap ("bar" , "baz2" )));
115- IngestDocument document2 = TestIngestDocument .ofSourceAndMetadata (source );
117+ IngestDocument document2 = TestIngestDocument .withDefaultVersion (source );
116118 Processor processor2 = new DotExpanderProcessor ("_tag" , null , null , "foo.bar.baz" );
117119 e = expectThrows (IllegalArgumentException .class , () -> processor2 .execute (document2 ));
118120 assertThat (e .getMessage (), equalTo ("cannot expand [foo.bar.baz], because [foo.bar] is not an object field, but a value field" ));
@@ -121,7 +123,7 @@ public void testEscapeFields_valueField() throws Exception {
121123 public void testEscapeFields_path () throws Exception {
122124 Map <String , Object > source = new HashMap <>();
123125 source .put ("foo" , new HashMap <>(Collections .singletonMap ("bar.baz" , "value" )));
124- IngestDocument document = TestIngestDocument .ofSourceAndMetadata (source );
126+ IngestDocument document = TestIngestDocument .withDefaultVersion (source );
125127 DotExpanderProcessor processor = new DotExpanderProcessor ("_tag" , null , "foo" , "bar.baz" );
126128 processor .execute (document );
127129 assertThat (document .getFieldValue ("foo" , Map .class ).size (), equalTo (1 ));
@@ -130,7 +132,7 @@ public void testEscapeFields_path() throws Exception {
130132
131133 source = new HashMap <>();
132134 source .put ("field" , new HashMap <>(Collections .singletonMap ("foo.bar.baz" , "value" )));
133- document = TestIngestDocument .ofSourceAndMetadata (source );
135+ document = TestIngestDocument .withDefaultVersion (source );
134136 processor = new DotExpanderProcessor ("_tag" , null , "field" , "foo.bar.baz" );
135137 processor .execute (document );
136138 assertThat (document .getFieldValue ("field.foo" , Map .class ).size (), equalTo (1 ));
@@ -142,7 +144,7 @@ public void testEscapeFields_doNothingIfFieldNotInSourceDoc() throws Exception {
142144 // asking to expand a (literal) field that is not present in the source document
143145 Map <String , Object > source = new HashMap <>();
144146 source .put ("foo.bar" , "baz1" );
145- IngestDocument document = TestIngestDocument .ofSourceAndMetadata (source );
147+ IngestDocument document = TestIngestDocument .withDefaultVersion (source );
146148 // abc.def does not exist in source, so don't mutate document
147149 DotExpanderProcessor processor = new DotExpanderProcessor ("_tag" , null , null , "abc.def" );
148150 processor .execute (document );
@@ -160,7 +162,7 @@ public void testEscapeFields_doNothingIfFieldNotInSourceDoc() throws Exception {
160162 Map <String , Object > inner = new HashMap <>();
161163 inner .put ("bar" , "baz1" );
162164 source .put ("foo" , inner );
163- document = TestIngestDocument .ofSourceAndMetadata (source );
165+ document = TestIngestDocument .withDefaultVersion (source );
164166 // foo.bar, the literal value (as opposed to nested value) does not exist in source, so don't mutate document
165167 processor = new DotExpanderProcessor ("_tag" , null , null , "foo.bar" );
166168 processor .execute (document );
@@ -178,7 +180,7 @@ public void testOverride() throws Exception {
178180 inner .put ("qux" , "quux" );
179181 source .put ("foo" , inner );
180182 source .put ("foo.bar" , "baz2" );
181- IngestDocument document = TestIngestDocument .ofSourceAndMetadata (source );
183+ IngestDocument document = TestIngestDocument .withDefaultVersion (source );
182184 DotExpanderProcessor processor = new DotExpanderProcessor ("_tag" , null , null , "foo.bar" , true );
183185 processor .execute (document );
184186 assertThat (document .getFieldValue ("foo" , Map .class ).size (), equalTo (2 ));
@@ -190,7 +192,7 @@ public void testWildcard() throws Exception {
190192 Map <String , Object > source = new HashMap <>();
191193 source .put ("foo.bar" , "baz" );
192194 source .put ("qux.quux" , "corge" );
193- IngestDocument document = TestIngestDocument .ofSourceAndMetadata (source );
195+ IngestDocument document = TestIngestDocument .withDefaultVersion (source );
194196 DotExpanderProcessor processor = new DotExpanderProcessor ("_tag" , null , null , "*" );
195197 processor .execute (document );
196198 assertThat (document .getFieldValue ("foo" , Map .class ).size (), equalTo (1 ));
@@ -202,7 +204,7 @@ public void testWildcard() throws Exception {
202204 Map <String , Object > inner = new HashMap <>();
203205 inner .put ("bar.baz" , "qux" );
204206 source .put ("foo" , inner );
205- document = TestIngestDocument .ofSourceAndMetadata (source );
207+ document = TestIngestDocument .withDefaultVersion (source );
206208 processor = new DotExpanderProcessor ("_tag" , null , "foo" , "*" );
207209 processor .execute (document );
208210 assertThat (document .getFieldValue ("foo" , Map .class ).size (), equalTo (1 ));
@@ -213,7 +215,7 @@ public void testWildcard() throws Exception {
213215 inner = new HashMap <>();
214216 inner .put ("bar.baz" , "qux" );
215217 source .put ("foo" , inner );
216- document = TestIngestDocument .ofSourceAndMetadata (source );
218+ document = TestIngestDocument .withDefaultVersion (source );
217219 processor = new DotExpanderProcessor ("_tag" , null , null , "*" );
218220 processor .execute (document );
219221 assertThat (document .getFieldValue ("foo" , Map .class ).size (), equalTo (1 ));
0 commit comments