Search in sources :

Example 26 with StreamRule

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

the class GreaterMatcherTest method testSuccessfulMatch.

@Test
public void testSuccessfulMatch() {
    StreamRule rule = getSampleRule();
    rule.setValue("3");
    Message msg = getSampleMessage();
    msg.addField("something", "4");
    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 27 with StreamRule

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

the class GreaterMatcherTest method testSuccessfullInvertedMatchWithEqualValues.

@Test
public void testSuccessfullInvertedMatchWithEqualValues() {
    StreamRule rule = getSampleRule();
    rule.setValue("-9001");
    rule.setInverted(true);
    Message msg = getSampleMessage();
    msg.addField("something", "-9001");
    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 28 with StreamRule

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

the class GreaterMatcherTest method getSampleRule.

@Override
protected StreamRule getSampleRule() {
    StreamRule rule = super.getSampleRule();
    rule.setType(StreamRuleType.GREATER);
    return rule;
}
Also used : StreamRule(org.graylog2.plugin.streams.StreamRule)

Example 29 with StreamRule

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

the class GreaterMatcherTest method testSuccessfulMatchWithNegativeValue.

@Test
public void testSuccessfulMatchWithNegativeValue() {
    StreamRule rule = getSampleRule();
    rule.setValue("-54354");
    Message msg = getSampleMessage();
    msg.addField("something", "4");
    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 30 with StreamRule

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

the class GreaterMatcherTest method testMissedDoubleMatch.

@Test
public void testMissedDoubleMatch() {
    StreamRule rule = getSampleRule();
    rule.setValue("25");
    Message msg = getSampleMessage();
    msg.addField("something", "12.4");
    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)

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