use of org.graylog2.streams.StreamRouterEngine in project graylog2-server by Graylog2.
the class StreamRouterEngineTest method testRegexMatch.
@Test
public void testRegexMatch() throws Exception {
final StreamMock stream = getStreamMock("test");
final StreamRuleMock rule = new StreamRuleMock(ImmutableMap.of("_id", new ObjectId(), "field", "testfield", "value", "^test", "type", StreamRuleType.REGEX.toInteger(), "stream_id", stream.getId()));
stream.setStreamRules(Lists.newArrayList(rule));
final StreamRouterEngine engine = newEngine(Lists.newArrayList(stream));
final Message message = getMessage();
// With non-matching value.
message.addField("testfield", "notestvalue");
assertTrue(engine.match(message).isEmpty());
// With matching value.
message.addField("testfield", "testvalue");
assertEquals(Lists.newArrayList(stream), engine.match(message));
}
Aggregations