use of org.graylog2.plugin.streams.StreamRule in project graylog2-server by Graylog2.
the class StreamRouterEngineTest method testOrMatchingShouldNotMatch.
@Test
public void testOrMatchingShouldNotMatch() {
final String dummyField = "dummyField";
final String dummyValue = "dummyValue";
final Stream stream = mock(Stream.class);
when(stream.getMatchingType()).thenReturn(Stream.MatchingType.OR);
final StreamRule streamRule1 = getStreamRuleMock("StreamRule1Id", StreamRuleType.EXACT, dummyField, "not" + dummyValue);
final StreamRule streamRule2 = getStreamRuleMock("StreamRule2Id", StreamRuleType.EXACT, dummyField, "alsoNot" + dummyValue);
when(stream.getStreamRules()).thenReturn(Lists.newArrayList(streamRule1, streamRule2));
final Message message = mock(Message.class);
when(message.getField(eq(dummyField))).thenReturn(dummyValue);
final StreamRouterEngine engine = newEngine(Lists.newArrayList(stream));
final List<Stream> result = engine.match(message);
assertThat(result).isEmpty();
}
use of org.graylog2.plugin.streams.StreamRule in project graylog2-server by Graylog2.
the class ExactMatcherTest method testSuccessfulMatch.
@Test
public void testSuccessfulMatch() {
StreamRule rule = getSampleRule();
Message msg = getSampleMessage();
msg.addField("something", "foo");
StreamRuleMatcher matcher = getMatcher(rule);
assertTrue(matcher.match(msg, rule));
}
use of org.graylog2.plugin.streams.StreamRule in project graylog2-server by Graylog2.
the class ExactMatcherTest method testNonExistantField.
@Test
public void testNonExistantField() {
StreamRule rule = getSampleRule();
Message msg = getSampleMessage();
msg.addField("someother", "foo");
StreamRuleMatcher matcher = getMatcher(rule);
assertFalse(matcher.match(msg, rule));
}
use of org.graylog2.plugin.streams.StreamRule in project graylog2-server by Graylog2.
the class ExactMatcherTest method testMissedMatch.
@Test
public void testMissedMatch() {
StreamRule rule = getSampleRule();
Message msg = getSampleMessage();
msg.addField("something", "nonono");
StreamRuleMatcher matcher = getMatcher(rule);
assertFalse(matcher.match(msg, rule));
}
use of org.graylog2.plugin.streams.StreamRule in project graylog2-server by Graylog2.
the class ExactMatcherTest method testInvertedNullFieldShouldMatch.
@Test
public void testInvertedNullFieldShouldMatch() {
final String fieldName = "nullfield";
final StreamRule rule = getSampleRule();
rule.setField(fieldName);
rule.setInverted(true);
final Message msg = getSampleMessage();
msg.addField(fieldName, null);
final StreamRuleMatcher matcher = getMatcher(rule);
assertTrue(matcher.match(msg, rule));
}
Aggregations