### Question:
PiggymetricsEventListenerProvider implements EventListenerProvider { @Override public void onEvent(Event event) { if (EventType.REGISTER.equals(event.getType())) { UserRegisteredEvent uce = UserRegisteredEvent.newBuilder() .setUserId(event.getUserId()) .setUserName(event.getDetails().get(USERNAME_KEY)) .setEmail(event.getDetails().get(EMAIL_KEY)) .build(); ProducerRecord<String, UserRegisteredEvent> record = new ProducerRecord<>(topic, event.getUserId(), uce); producer.send(record, ((metadata, exception) -> { if (metadata != null) { logger.info("Message on registration of user '" + record.key() + "' sent"); } else { logger.error("Failed to send message on registration of user '" + record.key() + "'", exception); } })); } }  @Override void onEvent(Event event); @Override void onEvent(AdminEvent event, boolean includeRepresentation); @Override void close();  }### Answer:
@Test void shouldSendEvent() { when(producer.send(captor.capture(), any(Callback.class))).thenReturn(CompletableFuture.completedFuture(null)); Event event = new Event(); event.setType(EventType.REGISTER); event.setUserId(USER_ID); event.setDetails(ImmutableMap.of(USERNAME_KEY, USERNAME, EMAIL_KEY, EMAIL)); provider.onEvent(event); ProducerRecord<String, UserRegisteredEvent> record = captor.getValue(); assertThat(record.topic()).isEqualTo(TOPIC); assertThat(record.key()).isEqualTo(USER_ID); assertThat(record.value().getUserId()).isEqualTo(USER_ID); assertThat(record.value().getUserName()).isEqualTo(USERNAME); assertThat(record.value().getEmail()).isEqualTo(EMAIL); }