@Before
public void setUp() throws IOException {
initMocks(this);
BytesReference bytesReference = mock(BytesReference.class);
BytesStream bytesStream = mock(BytesStream.class);
when(nameBuilder.getIndexName(any(Event.class))).thenReturn("foo_index");
when(bytesReference.toBytes()).thenReturn("{\"body\":\"test\"}".getBytes());
when(bytesStream.bytes()).thenReturn(bytesReference);
when(serializer.getContentBuilder(any(Event.class)))
.thenReturn(bytesStream);
when(elasticSearchClient.prepareIndex(anyString(), anyString()))
.thenReturn(indexRequestBuilder);
when(indexRequestBuilder.setSource(bytesReference)).thenReturn(