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 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 InputMatcherTest method testUnsuccessfulMatchInverted.
@Test
public void testUnsuccessfulMatchInverted() {
StreamRule rule = getSampleRule();
rule.setValue("input-id-dead");
rule.setInverted(true);
Message msg = getSampleMessage();
msg.addField(Message.FIELD_GL2_SOURCE_INPUT, "input-id-beef");
StreamRuleMatcher matcher = getMatcher(rule);
assertTrue(matcher.match(msg, rule));
}
use of org.graylog2.plugin.streams.StreamRule in project graylog2-server by Graylog2.
the class InputMatcherTest method getSampleRule.
@Override
protected StreamRule getSampleRule() {
StreamRule rule = super.getSampleRule();
rule.setType(StreamRuleType.MATCH_INPUT);
return rule;
}
use of org.graylog2.plugin.streams.StreamRule in project graylog2-server by Graylog2.
the class InputMatcherTest method testUnsuccessfulMatch.
@Test
public void testUnsuccessfulMatch() {
StreamRule rule = getSampleRule();
rule.setValue("input-id-dead");
Message msg = getSampleMessage();
msg.addField(Message.FIELD_GL2_SOURCE_INPUT, "input-id-beef");
StreamRuleMatcher matcher = getMatcher(rule);
assertFalse(matcher.match(msg, rule));
}
Aggregations