Search in sources :

Example 1 with DataPrepper

use of com.amazon.dataprepper.DataPrepper in project data-prepper by opensearch-project.

the class DataPrepperServerConfigurationTest method testGivenValidInputWithAuthenticatorThenServerListContextCreated.

@Test
public void testGivenValidInputWithAuthenticatorThenServerListContextCreated() {
    final DataPrepper dataPrepper = mock(DataPrepper.class);
    final ListPipelinesHandler handler = serverConfiguration.listPipelinesHandler(dataPrepper);
    assertThat(handler, isA(ListPipelinesHandler.class));
}
Also used : DataPrepper(com.amazon.dataprepper.DataPrepper) ListPipelinesHandler(com.amazon.dataprepper.pipeline.server.ListPipelinesHandler) Test(org.junit.jupiter.api.Test)

Example 2 with DataPrepper

use of com.amazon.dataprepper.DataPrepper in project data-prepper by opensearch-project.

the class DataPrepperServerConfigurationTest method testShutdownHandlerIsCreated.

@Test
public void testShutdownHandlerIsCreated() {
    final DataPrepper dataPrepper = mock(DataPrepper.class);
    final ShutdownHandler handler = serverConfiguration.shutdownHandler(dataPrepper);
    assertThat(handler, isA(ShutdownHandler.class));
}
Also used : DataPrepper(com.amazon.dataprepper.DataPrepper) ShutdownHandler(com.amazon.dataprepper.pipeline.server.ShutdownHandler) Test(org.junit.jupiter.api.Test)

Example 3 with DataPrepper

use of com.amazon.dataprepper.DataPrepper in project data-prepper by opensearch-project.

the class ListPipelinesHandlerTest method testGivenNoPipelinesThenResponseWritten.

@Test
public void testGivenNoPipelinesThenResponseWritten() throws IOException {
    final DataPrepper dataPrepper = mock(DataPrepper.class);
    final HttpExchange httpExchange = mock(HttpExchange.class);
    final Headers headers = mock(Headers.class);
    final OutputStream outputStream = mock(OutputStream.class);
    final Map<String, Pipeline> transformationPipelines = new HashMap<>();
    when(dataPrepper.getTransformationPipelines()).thenReturn(transformationPipelines);
    when(httpExchange.getResponseHeaders()).thenReturn(headers);
    when(httpExchange.getResponseBody()).thenReturn(outputStream);
    final ListPipelinesHandler handler = new ListPipelinesHandler(dataPrepper);
    handler.handle(httpExchange);
    verify(headers).add(eq("Content-Type"), eq("text/plain; charset=UTF-8"));
    verify(httpExchange).sendResponseHeaders(eq(HttpURLConnection.HTTP_OK), anyLong());
    verify(outputStream).write(any(byte[].class));
    verify(outputStream).close();
}
Also used : DataPrepper(com.amazon.dataprepper.DataPrepper) HashMap(java.util.HashMap) Headers(com.sun.net.httpserver.Headers) OutputStream(java.io.OutputStream) HttpExchange(com.sun.net.httpserver.HttpExchange) Pipeline(com.amazon.dataprepper.pipeline.Pipeline) Test(org.junit.jupiter.api.Test)

Example 4 with DataPrepper

use of com.amazon.dataprepper.DataPrepper in project data-prepper by opensearch-project.

the class ListPipelinesHandlerTest method testGivenPipelinesThenResponseWritten.

@Test
public void testGivenPipelinesThenResponseWritten() throws IOException {
    final DataPrepper dataPrepper = mock(DataPrepper.class);
    final HttpExchange httpExchange = mock(HttpExchange.class);
    final Headers headers = mock(Headers.class);
    final OutputStream outputStream = mock(OutputStream.class);
    final Pipeline pipeline = mock(Pipeline.class);
    final Map<String, Pipeline> transformationPipelines = new HashMap<>();
    transformationPipelines.put("Pipeline A", pipeline);
    transformationPipelines.put("Pipeline B", pipeline);
    transformationPipelines.put("Pipeline C", pipeline);
    when(dataPrepper.getTransformationPipelines()).thenReturn(transformationPipelines);
    when(httpExchange.getResponseHeaders()).thenReturn(headers);
    when(httpExchange.getResponseBody()).thenReturn(outputStream);
    final ListPipelinesHandler handler = new ListPipelinesHandler(dataPrepper);
    handler.handle(httpExchange);
    verify(headers).add(eq("Content-Type"), eq("text/plain; charset=UTF-8"));
    verify(httpExchange).sendResponseHeaders(eq(HttpURLConnection.HTTP_OK), anyLong());
    verify(outputStream).write(any(byte[].class));
    verify(outputStream).close();
}
Also used : DataPrepper(com.amazon.dataprepper.DataPrepper) HashMap(java.util.HashMap) Headers(com.sun.net.httpserver.Headers) OutputStream(java.io.OutputStream) HttpExchange(com.sun.net.httpserver.HttpExchange) Pipeline(com.amazon.dataprepper.pipeline.Pipeline) Test(org.junit.jupiter.api.Test)

Example 5 with DataPrepper

use of com.amazon.dataprepper.DataPrepper in project data-prepper by opensearch-project.

the class DataPrepperServerConfigurationTest method testGivenValidInputWithNoAuthenticatorThenServerListContextCreated.

@Test
public void testGivenValidInputWithNoAuthenticatorThenServerListContextCreated() {
    final DataPrepper dataPrepper = mock(DataPrepper.class);
    final ListPipelinesHandler handler = serverConfiguration.listPipelinesHandler(dataPrepper);
    assertThat(handler, isA(ListPipelinesHandler.class));
}
Also used : DataPrepper(com.amazon.dataprepper.DataPrepper) ListPipelinesHandler(com.amazon.dataprepper.pipeline.server.ListPipelinesHandler) Test(org.junit.jupiter.api.Test)

Aggregations

DataPrepper (com.amazon.dataprepper.DataPrepper)5 Test (org.junit.jupiter.api.Test)5 Pipeline (com.amazon.dataprepper.pipeline.Pipeline)2 ListPipelinesHandler (com.amazon.dataprepper.pipeline.server.ListPipelinesHandler)2 Headers (com.sun.net.httpserver.Headers)2 HttpExchange (com.sun.net.httpserver.HttpExchange)2 OutputStream (java.io.OutputStream)2 HashMap (java.util.HashMap)2 ShutdownHandler (com.amazon.dataprepper.pipeline.server.ShutdownHandler)1