1010package org .elasticsearch .ingest .common ;
1111
1212import org .elasticsearch .ElasticsearchParseException ;
13+ import org .elasticsearch .ingest .IngestDocument ;
14+ import org .elasticsearch .ingest .RandomDocumentPicks ;
1315import org .elasticsearch .ingest .TestTemplateService ;
1416import org .elasticsearch .test .ESTestCase ;
1517import org .junit .Before ;
1618
1719import java .time .ZoneId ;
20+ import java .time .ZoneOffset ;
1821import java .util .HashMap ;
1922import java .util .List ;
2023import java .util .Locale ;
@@ -43,8 +46,8 @@ public void testBuildDefaults() throws Exception {
4346 assertThat (processor .getField (), equalTo (sourceField ));
4447 assertThat (processor .getTargetField (), equalTo (DateProcessor .DEFAULT_TARGET_FIELD ));
4548 assertThat (processor .getFormats (), equalTo (List .of ("dd/MM/yyyyy" )));
46- assertNull (processor .getLocale ( ));
47- assertNull (processor .getTimezone ( ));
49+ assertThat (processor .getTimezone ( null ), equalTo ( ZoneOffset . UTC ));
50+ assertThat (processor .getLocale ( null ), equalTo ( Locale . ENGLISH ));
4851 }
4952
5053 public void testMatchFieldIsMandatory () throws Exception {
@@ -85,7 +88,8 @@ public void testParseLocale() throws Exception {
8588 config .put ("locale" , locale .toLanguageTag ());
8689
8790 DateProcessor processor = factory .create (null , null , null , config , null );
88- assertThat (processor .getLocale ().newInstance (Map .of ()).execute (), equalTo (locale .toLanguageTag ()));
91+ IngestDocument document = RandomDocumentPicks .randomIngestDocument (random (), Map .of ());
92+ assertThat (processor .getLocale (document ), equalTo (locale ));
8993 }
9094
9195 public void testParseTimezone () throws Exception {
@@ -97,7 +101,8 @@ public void testParseTimezone() throws Exception {
97101 ZoneId timezone = randomZone ();
98102 config .put ("timezone" , timezone .getId ());
99103 DateProcessor processor = factory .create (null , null , null , config , null );
100- assertThat (processor .getTimezone ().newInstance (Map .of ()).execute (), equalTo (timezone .getId ()));
104+ IngestDocument document = RandomDocumentPicks .randomIngestDocument (random (), Map .of ());
105+ assertThat (processor .getTimezone (document ), equalTo (timezone ));
101106 }
102107
103108 public void testParseMatchFormats () throws Exception {
0 commit comments