use of org.graylog2.plugin.Message in project graylog2-server by Graylog2.
the class FunctionsSnippetsTest method split.
@Test
public void split() {
final Rule rule = parser.parseRule(ruleForTest(), false);
final Message message = evaluateRule(rule);
assertThat(actionsTriggered.get()).isTrue();
assertThat(message).isNotNull();
assertThat(message.getField("limit_0")).asList().isNotEmpty().containsExactly("foo", "bar", "baz");
assertThat(message.getField("limit_1")).asList().isNotEmpty().containsExactly("foo:bar:baz");
assertThat(message.getField("limit_2")).asList().isNotEmpty().containsExactly("foo", "bar|baz");
}
use of org.graylog2.plugin.Message in project graylog2-server by Graylog2.
the class PipelineRuleParserTest method messageRef.
@Test
public void messageRef() throws Exception {
final Rule rule = parseRuleWithOptionalCodegen();
Message message = new Message("hello test", "source", DateTime.now(DateTimeZone.UTC));
message.addField("responseCode", 500);
final Message processedMsg = evaluateRule(rule, message);
assertNotNull(processedMsg);
assertEquals("server_error", processedMsg.getField("response_category"));
}
use of org.graylog2.plugin.Message in project graylog2-server by Graylog2.
the class PipelineRuleParserTest method indexedAccess.
@Test
public void indexedAccess() {
final Rule rule = parseRuleWithOptionalCodegen();
evaluateRule(rule, new Message("hallo", "test", DateTime.now(DateTimeZone.UTC)));
assertTrue("condition should be true", actionsTriggered.get());
}
use of org.graylog2.plugin.Message in project graylog2-server by Graylog2.
the class PipelineRuleParserTest method nestedFieldAccess.
@Test
public void nestedFieldAccess() throws Exception {
final Rule rule = parseRuleWithOptionalCodegen();
evaluateRule(rule, new Message("hello", "world", DateTime.now(DateTimeZone.UTC)));
assertTrue("condition should be true", actionsTriggered.get());
}
use of org.graylog2.plugin.Message in project graylog2-server by Graylog2.
the class PipelineInterpreterTest method messageInDefaultStream.
private Message messageInDefaultStream(String message, String source) {
final Message msg = new Message(message, source, Tools.nowUTC());
final Stream mockedStream = mock(Stream.class);
when(mockedStream.getId()).thenReturn(DEFAULT_STREAM_ID);
msg.addStream(mockedStream);
return msg;
}
Aggregations