BuildService extends AbstractService { public void addListener(final DangerousConsumer<BuildSummary> listener) { this.listeners.add(listener); }  void addListener(final DangerousConsumer<BuildSummary> listener); void save(final BuildDetails buildDetails); Optional<BuildDetails> get(final String uuid); List<BuildSummary> list(final String from, final int requestSize);  }
@Test @SuppressWarnings({"unchecked", "unsafe"}) public void testAddListener() throws Exception { final DangerousConsumer<BuildSummary> listener = mock(DangerousConsumer.class); buildService.addListener(listener); buildService.save(new BuildDetails()); verify(listener).accept(any(BuildSummary.class)); }