### Question:
NotificationsController { @EventListener public void onTaskFailed(TaskExecutionFailedEvent e) { if (e.getFailingCause() instanceof InvalidTaskParametersException) { container.addNotification(DefaultI18nContext.getInstance().i18n("Invalid parameters"), buildLabel( DefaultI18nContext.getInstance() .i18n("Input parameters are invalid, open the application messages for details."), NotificationType.ERROR)); } Throwable root = ExceptionUtils.getRootCause(e.getFailingCause()); if (root instanceof AccessDeniedException) { container.addNotification(DefaultI18nContext.getInstance().i18n("Access denied"), buildLabel(DefaultI18nContext.getInstance().i18n( "Unable to access \"{0}\", please make sure you have write permissions or open the application messages for details.", ((AccessDeniedException) root).getFile()), NotificationType.ERROR)); } } @Inject  NotificationsController(NotificationsContainer container, UsageService service, Pdfsam pdfsam,
            UserContext userContext); @EventListener void onAddRequest(AddNotificationRequestEvent event); @EventListener void onTaskFailed(TaskExecutionFailedEvent e); @EventListener void onTaskCompleted(@SuppressWarnings("unused") TaskExecutionCompletedEvent e); @EventListener void onRemoveRequest(RemoveNotificationRequestEvent event); @EventListener void onUpdateAvailable(UpdateAvailableEvent event); @EventListener void onNoUpdateAvailable(NoUpdateAvailable event); @EventListener void onNewImportantNews(NewImportantNewsEvent event);  }### Answer:
@Test public void onTaskFailed() { TaskExecutionFailedEvent event = new TaskExecutionFailedEvent(new Exception("some exception"), null); victim.onTaskFailed(event); verify(container, never()).addNotification(anyString(), any()); }
@Test public void onInvalidParameters() { TaskExecutionFailedEvent event = new TaskExecutionFailedEvent( new InvalidTaskParametersException("", Collections.emptyList()), null); victim.onTaskFailed(event); verify(container).addNotification(anyString(), any()); }
@Test public void onAccessDenied() { TaskExecutionFailedEvent event = new TaskExecutionFailedEvent( new TaskIOException(new AccessDeniedException("the file")), null); victim.onTaskFailed(event); verify(container).addNotification(anyString(), any()); }