EmailNotificationService implements NotificationService { @Override public boolean notify(Notification notification) { if (notification == null) { return false; } NotificationEmail notificationAsEmail = notification.getNotificationAsEmail(); if (notificationAsEmail == null) { return false; } final String subject = notificationAsEmail.getSubject(); final String body = notificationAsEmail.getBody(); Set<String> recipients = notificationAsEmail.getFullyQualifiedRecipientsEmail(); return sendEmail(recipients, subject, body); } EmailNotificationService(EmailProvider emailProvider); @Override boolean notify(Notification notification);  }
@Test public void testNotifyNull() { EmailProvider emailProvider = mock(EmailProvider.class); EmailNotificationService svc = new EmailNotificationService(emailProvider); boolean status = svc.notify(null); assertFalse(status); }