@SuppressWarnings("unchecked")
@Test
public void sendEncodedEvent_UpdateMetrics_Failure() throws InvalidKeyException {

  RecordMetadata metadata = null;
  Exception exception = new Exception();
  when(kafkaProducer.send(any(ProducerRecord.class), any(Callback.class))).thenAnswer(invocation -> {
    ((Callback) invocation.getArgument(1)).onCompletion(metadata, exception);
    return future;
  });
  underTest.sendEncodedEvent(new Event<>(null, null), null);
  verify(metrics).markFailureMetrics(ROAD_NAME);
}