### Question:
NotificationsController { @EventListener public void onTaskCompleted(@SuppressWarnings("unused") TaskExecutionCompletedEvent e) { long usages = service.getTotalUsage(); if ((usages % TIMES_BEFORE_ENTERPRISE_NOTICE) == 0 && userContext.isDonationNotification()) { if ((random.nextInt() % 2) == 0) { addDonationNotification(usages); } else { addShareNotification(usages); } } } @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 onTaskCompleteAndNoProDisplay() { when(service.getTotalUsage()).thenReturn(1L); victim.onTaskCompleted(new TaskExecutionCompletedEvent(1, null)); when(service.getTotalUsage()).thenReturn(6L); victim.onTaskCompleted(new TaskExecutionCompletedEvent(1, null)); verify(container, never()).addStickyNotification(anyString(), any()); }
@Test public void onTaskCompleteAndProDisplay() { when(service.getTotalUsage()).thenReturn(5L); victim.onTaskCompleted(new TaskExecutionCompletedEvent(1, null)); verify(container).addStickyNotification(anyString(), any()); }
@Test public void onTaskCompleteDontDisplaySettingIsOn() { when(context.isDonationNotification()).thenReturn(false); when(service.getTotalUsage()).thenReturn(5L); victim.onTaskCompleted(new TaskExecutionCompletedEvent(1, null)); verify(container, never()).addStickyNotification(anyString(), any()); }