Search in sources :

Example 1 with GrokPatternTestRequest

use of org.graylog2.rest.models.system.grokpattern.requests.GrokPatternTestRequest in project graylog2-server by Graylog2.

the class GrokResourceTest method testPatternWithSampleData.

@Test
public void testPatternWithSampleData() throws Exception {
    final String sampleData = "1.2.3.4";
    final GrokPattern grokPattern = GrokPattern.create("IP", "\\d.\\d.\\d.\\d");
    grokPatternService.save(grokPattern);
    final GrokPatternTestRequest grokPatternTestRequest = GrokPatternTestRequest.create(grokPattern, sampleData);
    final Map<String, Object> expectedReturn = Collections.singletonMap("IP", "1.2.3.4");
    final Response response = grokResource.testPattern(grokPatternTestRequest);
    assertThat(response.hasEntity()).isTrue();
    assertThat(response.getEntity()).isEqualTo(expectedReturn);
}
Also used : Response(javax.ws.rs.core.Response) GrokPattern(org.graylog2.grok.GrokPattern) GrokPatternTestRequest(org.graylog2.rest.models.system.grokpattern.requests.GrokPatternTestRequest) Test(org.junit.Test)

Aggregations

Response (javax.ws.rs.core.Response)1 GrokPattern (org.graylog2.grok.GrokPattern)1 GrokPatternTestRequest (org.graylog2.rest.models.system.grokpattern.requests.GrokPatternTestRequest)1 Test (org.junit.Test)1