ExceptionWitnessResponderButton extends Button { @Subscribe public void onExceptionClearedEvent(ExceptionClearedEvent event) { if (getScene() == null || getScene().getRoot() == null) { return; } if (event.getOrigin().equals(origin)) { Platform.runLater(() -> { getPopover().hide(); setVisible(false); }); } } @Inject  ExceptionWitnessResponderButton(@Assisted Object origin, @Assisted String popOverTitle); @Subscribe void onExceptionEvent(ExceptionEvent event); @Subscribe void onExceptionClearedEvent(ExceptionClearedEvent event);  }
@Test public void testOnExceptionClearedEvent() throws Exception { flagNewException(); witness.clearException(); WaitForAsyncUtils.waitFor(2, TimeUnit.SECONDS, () -> NodeMatchers.isInvisible().matches(lookup("." + ExceptionWitnessResponderButton .STYLE_CLASS).query())); }