Search in sources :

Example 71 with StreamRule

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

the class GreaterMatcherTest method testSuccessfulDoubleMatchWithNegativeValue.

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

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

the class GreaterMatcherTest method testMissedInvertedMatch.

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

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

the class GreaterMatcherTest 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 74 with StreamRule

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

the class GreaterMatcherTest method testMissedDoubleMatchWithEqualValues.

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

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

the class GreaterMatcherTest method testMissedInvertedMatchMissingField.

@Test
public void testMissedInvertedMatchMissingField() {
    StreamRule rule = getSampleRule();
    rule.setValue("42");
    rule.setInverted(true);
    Message msg = getSampleMessage();
    msg.addField("someother", "30");
    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)98 Message (org.graylog2.plugin.Message)73 Test (org.junit.Test)71 Stream (org.graylog2.plugin.streams.Stream)16 ObjectId (org.bson.types.ObjectId)11 Timed (com.codahale.metrics.annotation.Timed)10 ApiOperation (io.swagger.annotations.ApiOperation)10 Output (org.graylog2.plugin.streams.Output)9 Produces (javax.ws.rs.Produces)8 AuditEvent (org.graylog2.audit.jersey.AuditEvent)8 ApiResponses (io.swagger.annotations.ApiResponses)7 Consumes (javax.ws.rs.Consumes)7 POST (javax.ws.rs.POST)7 Path (javax.ws.rs.Path)7 NotFoundException (org.graylog2.database.NotFoundException)7 URI (java.net.URI)6 Map (java.util.Map)6 AlarmCallbackConfiguration (org.graylog2.alarmcallbacks.AlarmCallbackConfiguration)6 NoAuditEvent (org.graylog2.audit.jersey.NoAuditEvent)6 AlertCondition (org.graylog2.plugin.alarms.AlertCondition)6