Search in sources :

Example 36 with StreamRule

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

the class SmallerMatcherTest method testMissedMatchWithMissingField.

@Test
public void testMissedMatchWithMissingField() {
    StreamRule rule = getSampleRule();
    rule.setValue("42");
    Message msg = getSampleMessage();
    msg.addField("someother", "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 37 with StreamRule

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

the class SmallerMatcherTest method testSuccessfulMatchWithNegativeValue.

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

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

the class SmallerMatcherTest method testMissedMatchWithEqualValues.

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

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

the class SmallerMatcherTest method testMissedDoubleMatchWithInvalidValue.

@Test
public void testMissedDoubleMatchWithInvalidValue() {
    StreamRule rule = getSampleRule();
    rule.setValue("LOL I AM NOT EVEN A NUMBER");
    Message msg = getSampleMessage();
    msg.addField("something", "-9001.42");
    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 40 with StreamRule

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

the class SmallerMatcherTest method testMissedMatch.

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