Search in sources :

Example 1 with ExtractorException

use of org.graylog2.inputs.extractors.ExtractorException in project graylog2-server by Graylog2.

the class ExtractorTest method testExtractorsWithExceptions.

@Test
public void testExtractorsWithExceptions() throws Exception {
    final TestExtractor extractor = new TestExtractor.Builder().callback(new Callable<Result[]>() {

        @Override
        public Result[] call() throws Exception {
            throw new ExtractorException(new IOException("BARF"));
        }
    }).build();
    final Message msg = createMessage("message");
    extractor.runExtractor(msg);
    assertThat(msg.processingErrors()).hasSize(1);
    assertThat(msg.processingErrors().get(0)).satisfies(pe -> {
        assertThat(pe.getCause()).isEqualTo(ProcessingFailureCause.ExtractorException);
        assertThat(pe.getMessage()).isEqualTo("Could not apply extractor <test-title (test-id)>");
        assertThat(pe.getDetails()).isEqualTo("BARF.");
    });
}
Also used : Message(org.graylog2.plugin.Message) ExtractorException(org.graylog2.inputs.extractors.ExtractorException) IOException(java.io.IOException) Callable(java.util.concurrent.Callable) Result(org.graylog2.plugin.inputs.Extractor.Result) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)1 Callable (java.util.concurrent.Callable)1 ExtractorException (org.graylog2.inputs.extractors.ExtractorException)1 Message (org.graylog2.plugin.Message)1 Result (org.graylog2.plugin.inputs.Extractor.Result)1 Test (org.junit.Test)1