EmailNotifier extends AuditNotifier { @Override protected boolean clearAdditionalNotification(NotificationContext context) { requireArgument(context != null, "Notification context cannot be null."); super.clearAdditionalNotification(context); boolean isSent = true; if (context.getNotification().isEnableClearNotification()) { Set<String> recipients = _getNotificationSubscriptions(context); EmailContext emailContext = getEmailContextForEmailNotifications(context, NotificationStatus.CLEARED, recipients); isSent = _mailService.sendMessage(emailContext); if (!isSent) { context.getHistory().appendMessageNUpdateHistory(MessageFormat.format("Not able to send email for cleared notification: `{0}.` to recipient {1}", context.getNotification().getName(), recipients), null, 0); } } return isSent; } @Inject  EmailNotifier(MetricService metricService, AnnotationService annotationService, AuditService auditService,
                         MailService mailService, SystemConfiguration config, Provider<EntityManager> emf); @Override String getName();  }
@Test public void clearAdditionalNotification_testDisabledClearNotification() { notificationContext.getNotification().setEnableClearNotification(false); boolean result = emailNotifier.clearAdditionalNotification(notificationContext); assertTrue(result); verify(mailServiceMock, never()).sendMessage(any()); }