Search in sources :

Example 81 with Result

use of org.graylog2.plugin.inputs.Extractor.Result in project graylog2-server by Graylog2.

the class FieldPresenceMatcherTest method testInvertedBasicMatch.

@Test
public void testInvertedBasicMatch() throws Exception {
    StreamRule rule = getSampleRule();
    rule.setField("message");
    rule.setType(StreamRuleType.PRESENCE);
    rule.setInverted(true);
    Message message = getSampleMessage();
    StreamRuleMatcher matcher = getMatcher(rule);
    Boolean result = matcher.match(message, rule);
    assertFalse(result);
}
Also used : Message(org.graylog2.plugin.Message) StreamRule(org.graylog2.plugin.streams.StreamRule) Test(org.junit.Test)

Example 82 with Result

use of org.graylog2.plugin.inputs.Extractor.Result in project graylog2-server by Graylog2.

the class FieldPresenceMatcherTest method testBasicNonMatch.

@Test
public void testBasicNonMatch() throws Exception {
    StreamRule rule = getSampleRule();
    rule.setField("nonexistentField");
    rule.setType(StreamRuleType.PRESENCE);
    rule.setInverted(false);
    Message message = getSampleMessage();
    StreamRuleMatcher matcher = getMatcher(rule);
    Boolean result = matcher.match(message, rule);
    assertFalse(result);
}
Also used : Message(org.graylog2.plugin.Message) StreamRule(org.graylog2.plugin.streams.StreamRule) Test(org.junit.Test)

Example 83 with Result

use of org.graylog2.plugin.inputs.Extractor.Result in project graylog2-server by Graylog2.

the class FieldPresenceMatcherTest method testNulledFieldNonMatch.

@Test
public void testNulledFieldNonMatch() throws Exception {
    String fieldName = "sampleField";
    StreamRule rule = getSampleRule();
    rule.setField(fieldName);
    rule.setType(StreamRuleType.PRESENCE);
    rule.setInverted(false);
    Message message = getSampleMessage();
    message.addField(fieldName, null);
    StreamRuleMatcher matcher = getMatcher(rule);
    Boolean result = matcher.match(message, rule);
    assertFalse(result);
}
Also used : Message(org.graylog2.plugin.Message) StreamRule(org.graylog2.plugin.streams.StreamRule) Test(org.junit.Test)

Example 84 with Result

use of org.graylog2.plugin.inputs.Extractor.Result in project graylog2-server by Graylog2.

the class FieldPresenceMatcherTest method testRandomNumberFieldNonMatch.

@Test
public void testRandomNumberFieldNonMatch() throws Exception {
    String fieldName = "sampleField";
    Integer randomNumber = 4;
    StreamRule rule = getSampleRule();
    rule.setField(fieldName);
    rule.setType(StreamRuleType.PRESENCE);
    rule.setInverted(false);
    Message message = getSampleMessage();
    message.addField(fieldName, randomNumber);
    StreamRuleMatcher matcher = getMatcher(rule);
    Boolean result = matcher.match(message, rule);
    assertTrue(result);
}
Also used : Message(org.graylog2.plugin.Message) StreamRule(org.graylog2.plugin.streams.StreamRule) Test(org.junit.Test)

Example 85 with Result

use of org.graylog2.plugin.inputs.Extractor.Result in project graylog2-server by Graylog2.

the class FieldPresenceMatcherTest method testInvertedBasicNonMatch.

@Test
public void testInvertedBasicNonMatch() throws Exception {
    StreamRule rule = getSampleRule();
    rule.setField("nonexistentField");
    rule.setType(StreamRuleType.PRESENCE);
    rule.setInverted(true);
    Message message = getSampleMessage();
    StreamRuleMatcher matcher = getMatcher(rule);
    Boolean result = matcher.match(message, rule);
    assertTrue(result);
}
Also used : Message(org.graylog2.plugin.Message) StreamRule(org.graylog2.plugin.streams.StreamRule) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)73 Message (org.graylog2.plugin.Message)51 Result (org.graylog2.plugin.inputs.Extractor.Result)27 Callable (java.util.concurrent.Callable)26 Stream (org.graylog2.plugin.streams.Stream)20 StreamRule (org.graylog2.plugin.streams.StreamRule)19 DateTime (org.joda.time.DateTime)18 Timed (com.codahale.metrics.annotation.Timed)13 ApiOperation (io.swagger.annotations.ApiOperation)13 AlertCondition (org.graylog2.plugin.alarms.AlertCondition)12 ApiResponses (io.swagger.annotations.ApiResponses)11 Produces (javax.ws.rs.Produces)9 AuditEvent (org.graylog2.audit.jersey.AuditEvent)9 Function (com.google.common.base.Function)8 UsingDataSet (com.lordofthejars.nosqlunit.annotation.UsingDataSet)8 ZonedDateTime (java.time.ZonedDateTime)8 AbstractAlertCondition (org.graylog2.alerts.AbstractAlertCondition)8 Sorting (org.graylog2.indexer.searches.Sorting)8 URI (java.net.URI)7 MessageSummary (org.graylog2.plugin.MessageSummary)7