Search in sources :

Example 31 with StreamRule

use of org.graylog2.plugin.streams.StreamRule in project graylog2-server by Graylog2.

the class GreaterMatcherTest method testMissedDoubleMatchWithInvalidValue.

@Test
public void testMissedDoubleMatchWithInvalidValue() {
    StreamRule rule = getSampleRule();
    rule.setValue("LOL I AM NOT EVEN A NUMBER");
    Message msg = getSampleMessage();
    msg.addField("something", "90000.23");
    StreamRuleMatcher matcher = getMatcher(rule);
    assertFalse(matcher.match(msg, rule));
}
Also used : Message(org.graylog2.plugin.Message) StreamRule(org.graylog2.plugin.streams.StreamRule) Test(org.junit.Test)

Example 32 with StreamRule

use of org.graylog2.plugin.streams.StreamRule in project graylog2-server by Graylog2.

the class GreaterMatcherTest method testMissedMatch.

@Test
public void testMissedMatch() {
    StreamRule rule = getSampleRule();
    rule.setValue("25");
    Message msg = getSampleMessage();
    msg.addField("something", "12");
    StreamRuleMatcher matcher = getMatcher(rule);
    assertFalse(matcher.match(msg, rule));
}
Also used : Message(org.graylog2.plugin.Message) StreamRule(org.graylog2.plugin.streams.StreamRule) Test(org.junit.Test)

Example 33 with StreamRule

use of org.graylog2.plugin.streams.StreamRule in project graylog2-server by Graylog2.

the class GreaterMatcherTest method testSuccessfulDoubleMatch.

@Test
public void testSuccessfulDoubleMatch() {
    StreamRule rule = getSampleRule();
    rule.setValue("1.0");
    Message msg = getSampleMessage();
    msg.addField("something", "1.1");
    StreamRuleMatcher matcher = getMatcher(rule);
    assertTrue(matcher.match(msg, rule));
}
Also used : Message(org.graylog2.plugin.Message) StreamRule(org.graylog2.plugin.streams.StreamRule) Test(org.junit.Test)

Example 34 with StreamRule

use of org.graylog2.plugin.streams.StreamRule in project graylog2-server by Graylog2.

the class RegexMatcherTest method testInvertedNullFieldShouldMatch.

@Test
public void testInvertedNullFieldShouldMatch() throws Exception {
    final String fieldName = "nullfield";
    final StreamRule rule = getSampleRule();
    rule.setField(fieldName);
    rule.setValue("^foo");
    rule.setInverted(true);
    final Message msg = getSampleMessage();
    msg.addField(fieldName, null);
    final StreamRuleMatcher matcher = getMatcher(rule);
    assertTrue(matcher.match(msg, rule));
}
Also used : Message(org.graylog2.plugin.Message) StreamRule(org.graylog2.plugin.streams.StreamRule) Test(org.junit.Test)

Example 35 with StreamRule

use of org.graylog2.plugin.streams.StreamRule in project graylog2-server by Graylog2.

the class RegexMatcherTest method testSuccessfulMatch.

@Test
public void testSuccessfulMatch() {
    StreamRule rule = getSampleRule();
    rule.setValue("^foo");
    Message msg = getSampleMessage();
    msg.addField("something", "foobar");
    StreamRuleMatcher matcher = getMatcher(rule);
    assertTrue(matcher.match(msg, rule));
}
Also used : Message(org.graylog2.plugin.Message) StreamRule(org.graylog2.plugin.streams.StreamRule) Test(org.junit.Test)

Aggregations

StreamRule (org.graylog2.plugin.streams.StreamRule)85 Message (org.graylog2.plugin.Message)65 Test (org.junit.Test)64 Stream (org.graylog2.plugin.streams.Stream)13 Timed (com.codahale.metrics.annotation.Timed)7 ApiOperation (io.swagger.annotations.ApiOperation)7 ObjectId (org.bson.types.ObjectId)6 Produces (javax.ws.rs.Produces)5 BasicDBObject (com.mongodb.BasicDBObject)4 DBObject (com.mongodb.DBObject)4 ApiResponses (io.swagger.annotations.ApiResponses)4 Consumes (javax.ws.rs.Consumes)4 POST (javax.ws.rs.POST)4 Path (javax.ws.rs.Path)4 AuditEvent (org.graylog2.audit.jersey.AuditEvent)4 NotFoundException (org.graylog2.database.NotFoundException)4 URI (java.net.URI)3 Map (java.util.Map)3 BadRequestException (javax.ws.rs.BadRequestException)3 NoAuditEvent (org.graylog2.audit.jersey.NoAuditEvent)3