use of org.graylog.plugins.pipelineprocessor.parser.ParseException in project graylog2-server by Graylog2.
the class FunctionsSnippetsTest method dates.
@Test
public void dates() {
final InstantMillisProvider clock = new InstantMillisProvider(GRAYLOG_EPOCH);
DateTimeUtils.setCurrentMillisProvider(clock);
try {
final Rule rule;
try {
rule = parser.parseRule(ruleForTest(), false);
} catch (ParseException e) {
fail("Should not fail to parse", e);
return;
}
final Message message = evaluateRule(rule);
assertThat(actionsTriggered.get()).isTrue();
assertThat(message).isNotNull();
assertThat(message).isNotEmpty();
assertThat(message.hasField("year")).isTrue();
assertThat(message.getField("year")).isEqualTo(2010);
assertThat(message.getField("timezone")).isEqualTo("UTC");
// Date parsing locales
assertThat(message.getField("german_year")).isEqualTo(1983);
assertThat(message.getField("german_month")).isEqualTo(7);
assertThat(message.getField("german_day")).isEqualTo(24);
assertThat(message.getField("german_weekday")).isEqualTo(7);
assertThat(message.getField("english_year")).isEqualTo(1983);
assertThat(message.getField("english_month")).isEqualTo(7);
assertThat(message.getField("english_day")).isEqualTo(24);
assertThat(message.getField("french_year")).isEqualTo(1983);
assertThat(message.getField("french_month")).isEqualTo(7);
assertThat(message.getField("french_day")).isEqualTo(24);
assertThat(message.getField("ts_hour")).isEqualTo(16);
assertThat(message.getField("ts_minute")).isEqualTo(3);
assertThat(message.getField("ts_second")).isEqualTo(25);
} finally {
DateTimeUtils.setCurrentMillisSystem();
}
}
Aggregations