diff --git a/plugins/ingest/src/test/java/org/elasticsearch/ingest/processor/date/DateProcessorFactoryTests.java b/plugins/ingest/src/test/java/org/elasticsearch/ingest/processor/date/DateProcessorFactoryTests.java index a852c597d86..62f726cf0cd 100644 --- a/plugins/ingest/src/test/java/org/elasticsearch/ingest/processor/date/DateProcessorFactoryTests.java +++ b/plugins/ingest/src/test/java/org/elasticsearch/ingest/processor/date/DateProcessorFactoryTests.java @@ -94,13 +94,21 @@ public class DateProcessorFactoryTests extends ESTestCase { String sourceField = randomAsciiOfLengthBetween(1, 10); config.put("match_field", sourceField); config.put("match_formats", Collections.singletonList("dd/MM/yyyyy")); - DateTimeZone timeZone = DateTimeZone.forTimeZone(randomTimeZone(random())); - config.put("timezone", timeZone.getID()); + DateTimeZone timezone = randomTimezone(); + config.put("timezone", timezone.getID()); DateProcessor processor = factory.create(config); - assertThat(processor.getTimezone(), equalTo(timeZone)); + assertThat(processor.getTimezone(), equalTo(timezone)); } + //we generate a timezone out of the available ones in joda, some available in the jdk are not available in joda by default + private static DateTimeZone randomTimezone() { + List ids = new ArrayList<>(DateTimeZone.getAvailableIDs()); + Collections.sort(ids); + return DateTimeZone.forID(randomFrom(ids)); + } + + public void testParseMatchFormats() throws Exception { DateProcessor.Factory factory = new DateProcessor.Factory(); Map config = new HashMap<>();