use of org.graylog2.plugin.streams.StreamRule in project graylog2-server by Graylog2.
the class RegexMatcherTest method testInvertedMissingFieldShouldMatch.
@Test
public void testInvertedMissingFieldShouldMatch() throws Exception {
final StreamRule rule = getSampleRule();
rule.setField("nonexistingfield");
rule.setValue("^foo");
rule.setInverted(true);
final Message msg = getSampleMessage();
final StreamRuleMatcher matcher = getMatcher(rule);
assertTrue(matcher.match(msg, rule));
}
use of org.graylog2.plugin.streams.StreamRule in project graylog2-server by Graylog2.
the class RegexMatcherTest method getSampleRule.
@Override
protected StreamRule getSampleRule() {
StreamRule rule = super.getSampleRule();
rule.setType(StreamRuleType.REGEX);
return rule;
}
use of org.graylog2.plugin.streams.StreamRule in project graylog2-server by Graylog2.
the class RegexMatcherTest method testSuccessfulComplexRegexMatch.
@Test
public void testSuccessfulComplexRegexMatch() {
StreamRule rule = getSampleRule();
rule.setField("some_field");
rule.setValue("foo=^foo|bar\\d.+wat");
Message msg = getSampleMessage();
msg.addField("some_field", "bar1foowat");
StreamRuleMatcher matcher = getMatcher(rule);
assertTrue(matcher.match(msg, rule));
}
use of org.graylog2.plugin.streams.StreamRule in project graylog2-server by Graylog2.
the class RegexMatcherTest method testMissedInvertedMatch.
@Test
public void testMissedInvertedMatch() {
StreamRule rule = getSampleRule();
rule.setValue("^foo");
rule.setInverted(true);
Message msg = getSampleMessage();
msg.addField("something", "foobar");
StreamRuleMatcher matcher = getMatcher(rule);
assertFalse(matcher.match(msg, rule));
}
use of org.graylog2.plugin.streams.StreamRule in project graylog2-server by Graylog2.
the class RegexMatcherTest method testNullFieldShouldNotMatch.
@Test
public void testNullFieldShouldNotMatch() throws Exception {
final String fieldName = "nullfield";
final StreamRule rule = getSampleRule();
rule.setField(fieldName);
rule.setValue("^foo");
final Message msg = getSampleMessage();
msg.addField(fieldName, null);
final StreamRuleMatcher matcher = getMatcher(rule);
assertFalse(matcher.match(msg, rule));
}
Aggregations