@Test
public void encodeMessage() throws Exception {

  Event event = new Message<>(0, 1L, 2, 3L, mapper.createObjectNode());
  String raw = "";
  doReturn(raw).when(encoder).encode(event);
  doReturn(raw).when(metrics).record(eq(ENCODE), argThat(new ArgMatcher<Supplier<String>>() {}));
  String result = underTest.encodeEvent(event);
  assertThat(result, is(raw));
  verify(metrics).markMessage(raw.length());
  @SuppressWarnings("unchecked")
  ArgumentCaptor<Supplier<String>> captor = ArgumentCaptor.forClass(Supplier.class);
  verify(metrics).record(eq(ENCODE), captor.capture());
  assertThat(captor.getValue().get(), is(raw));
}