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));
}
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));
}
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();
}
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();
}
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));
}
Aggregations