Search in sources :

Example 11 with LookupTable

use of org.graylog2.lookup.LookupTable in project graylog2-server by Graylog2.

the class FunctionsSnippetsTest method lookupRemoveStringList.

@Test
public void lookupRemoveStringList() {
    final ImmutableList<String> testList = ImmutableList.of("foo", "bar");
    final ImmutableList<String> result = ImmutableList.of("bonk");
    doReturn(LookupResult.withoutTTL().stringListValue(result).build()).when(lookupTable).removeStringList(any(), any());
    final Rule rule = parser.parseRule(ruleForTest(), true);
    final Message message = evaluateRule(rule);
    verify(lookupTable).removeStringList("key", testList);
    verifyNoMoreInteractions(lookupTable);
    assertThat(message.getField("new_value")).isEqualTo(result);
}
Also used : CreateMessage(org.graylog.plugins.pipelineprocessor.functions.messages.CreateMessage) CloneMessage(org.graylog.plugins.pipelineprocessor.functions.messages.CloneMessage) DropMessage(org.graylog.plugins.pipelineprocessor.functions.messages.DropMessage) Message(org.graylog2.plugin.Message) IsString(org.graylog.plugins.pipelineprocessor.functions.conversion.IsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) MockitoRule(org.mockito.junit.MockitoRule) Rule(org.graylog.plugins.pipelineprocessor.ast.Rule) BaseParserTest(org.graylog.plugins.pipelineprocessor.BaseParserTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 CloneMessage (org.graylog.plugins.pipelineprocessor.functions.messages.CloneMessage)5 CreateMessage (org.graylog.plugins.pipelineprocessor.functions.messages.CreateMessage)5 DropMessage (org.graylog.plugins.pipelineprocessor.functions.messages.DropMessage)5 Message (org.graylog2.plugin.Message)5 BaseParserTest (org.graylog.plugins.pipelineprocessor.BaseParserTest)4 Rule (org.graylog.plugins.pipelineprocessor.ast.Rule)4 IsString (org.graylog.plugins.pipelineprocessor.functions.conversion.IsString)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 MockitoRule (org.mockito.junit.MockitoRule)4 LookupTableEntity (org.graylog2.contentpacks.model.entities.LookupTableEntity)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 MongoDBFixtures (org.graylog.testing.mongodb.MongoDBFixtures)2 EntityDescriptor (org.graylog2.contentpacks.model.entities.EntityDescriptor)2 GrokPatternService (org.graylog2.grok.GrokPatternService)2 Input (org.graylog2.inputs.Input)2 FakeHttpMessageInput (org.graylog2.inputs.random.FakeHttpMessageInput)2 RawUDPInput (org.graylog2.inputs.raw.udp.RawUDPInput)2 LookupTableService (org.graylog2.lookup.LookupTableService)2