initMocks(this);
BytesReference bytesReference = mock(BytesReference.class);
BytesStream bytesStream = mock(BytesStream.class);
when(nameBuilder.getIndexName(any(Event.class))).thenReturn(INDEX_NAME);
when(bytesReference.toBytesArray()).thenReturn(new BytesArray(MESSAGE_CONTENT));
when(bytesStream.bytes()).thenReturn(bytesReference);
when(serializer.getContentBuilder(any(Event.class))).thenReturn(bytesStream);
fixture = new ElasticSearchRestClient(HOSTS, serializer, httpClient);
}