### Question:
ScreenCapturer { @Subscribe @AllowConcurrentEvents public void handleEvent(final AbstractBaseEvent event) { Class<? extends AbstractBaseEvent> clazz = event.getClass(); boolean errorCapture = captureScreenOnError(event); boolean eventConfigured = screenCaptureEvents.contains(clazz); if (eventConfigured || errorCapture) { String screenshotName = clazz.getSimpleName(); if (errorCapture) { screenshotName += "_error"; } captureAndArchiveScreen(screenshotName); } } @Inject  ScreenCapturer(@ModuleArchiveDir final Provider<File> moduleArchiveDirProvider,
			final Set<Class<? extends AbstractBaseEvent>> screenCaptureEvents, final Provider<MutableInt> counterProvider,
			@CaptureScreenOnError final boolean captureScreenOnError); static void captureScreen(final File file); static void captureScreenRect(final File file, final Rectangle rectangle); @Subscribe @AllowConcurrentEvents void handleEvent(final AbstractBaseEvent event); void captureAndArchiveScreen(final String screenshotName);  }### Answer:
@Test(dataProvider = "exception", groups = "excludeFromCI") public void testHandleEvent(final Exception ex) { testFileOrDir = new File(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()); MutableInt counter = new MutableInt(); Set<Class<? extends AbstractBaseEvent>> eventClasses = ImmutableSet.<Class<? extends AbstractBaseEvent>>of(BeforeModuleEvent.class); ScreenCapturer capturer = new ScreenCapturer(Providers.of(testFileOrDir), eventClasses, Providers.of(counter), ex != null); int c = counter.intValue(); EventBus eventBus = new EventBus(); eventBus.register(capturer); eventBus.post(new BeforeModuleEvent(new DummyModule())); eventBus.post(new AfterModuleEvent(new DummyModule(), ex)); assertThat(new File(testFileOrDir, String.format("screenshots/%04d_BeforeModuleEvent.png", c))).exists(); if (ex == null) { assertThat(new File(testFileOrDir, String.format("screenshots/%04d_AfterModuleEvent.png", ++c))).doesNotExist(); assertThat(new File(testFileOrDir, String.format("screenshots/%04d_AfterModuleEvent_error.png", ++c))).doesNotExist(); } else { assertThat(new File(testFileOrDir, String.format("screenshots/%04d_AfterModuleEvent_error.png", ++c))).exists(); } }