use of org.graylog2.plugin.streams.StreamRule in project graylog2-server by Graylog2.
the class FieldPresenceMatcherTest method testBasicMatch.
@Test
public void testBasicMatch() throws Exception {
StreamRule rule = getSampleRule();
rule.setField("message");
rule.setType(StreamRuleType.PRESENCE);
rule.setInverted(false);
Message message = getSampleMessage();
StreamRuleMatcher matcher = getMatcher(rule);
Boolean result = matcher.match(message, rule);
assertTrue(result);
}
use of org.graylog2.plugin.streams.StreamRule in project graylog2-server by Graylog2.
the class FieldPresenceMatcherTest method testEmptyStringFieldNonMatch.
@Test
public void testEmptyStringFieldNonMatch() throws Exception {
String fieldName = "sampleField";
StreamRule rule = getSampleRule();
rule.setField(fieldName);
rule.setType(StreamRuleType.PRESENCE);
rule.setInverted(false);
Message message = getSampleMessage();
message.addField(fieldName, "");
StreamRuleMatcher matcher = getMatcher(rule);
Boolean result = matcher.match(message, rule);
assertFalse(result);
}
use of org.graylog2.plugin.streams.StreamRule in project graylog2-server by Graylog2.
the class FieldPresenceMatcherTest method testInvertedEmptyStringFieldMatch.
@Test
public void testInvertedEmptyStringFieldMatch() throws Exception {
String fieldName = "sampleField";
StreamRule rule = getSampleRule();
rule.setField(fieldName);
rule.setType(StreamRuleType.PRESENCE);
rule.setInverted(true);
Message message = getSampleMessage();
message.addField(fieldName, "");
StreamRuleMatcher matcher = getMatcher(rule);
Boolean result = matcher.match(message, rule);
assertTrue(result);
}
use of org.graylog2.plugin.streams.StreamRule in project graylog2-server by Graylog2.
the class FieldPresenceMatcherTest method testInvertedRandomNumberFieldMatch.
@Test
public void testInvertedRandomNumberFieldMatch() throws Exception {
String fieldName = "sampleField";
Integer randomNumber = 4;
StreamRule rule = getSampleRule();
rule.setField(fieldName);
rule.setType(StreamRuleType.PRESENCE);
rule.setInverted(true);
Message message = getSampleMessage();
message.addField(fieldName, randomNumber);
StreamRuleMatcher matcher = getMatcher(rule);
Boolean result = matcher.match(message, rule);
assertFalse(result);
}
use of org.graylog2.plugin.streams.StreamRule in project graylog2-server by Graylog2.
the class FieldPresenceMatcherTest method testInvertedNulledFieldMatch.
@Test
public void testInvertedNulledFieldMatch() throws Exception {
String fieldName = "sampleField";
StreamRule rule = getSampleRule();
rule.setField(fieldName);
rule.setType(StreamRuleType.PRESENCE);
rule.setInverted(true);
Message message = getSampleMessage();
message.addField(fieldName, null);
StreamRuleMatcher matcher = getMatcher(rule);
Boolean result = matcher.match(message, rule);
assertTrue(result);
}
Aggregations