EmailNotifier implements Notifier { @Override public void notify(String subject, String message, String... emailAddrs) { checkInitialized(); log.debug("Sending email to " + Arrays.toString(emailAddrs) + " with subject: [" + subject + "] and message: [" + message + "]"); emailer.send(subject, message, emailAddrs); }  @Override void initialize(NotificationConfig notificationConfig); @Override NotificationType getNotificationType(); @Override void notify(String subject, String message, String... emailAddrs); @Override void notifyAdmins(String subject, String message);  }
@Test public void testInitialized() { try { new EmailNotifier().notify(subject, message, emailAddresses); fail("Notify should fail when notifier is not initialized"); } catch (RuntimeException e) { assertNotNull(e); } }
@Test public void testNotify() { Emailer emailer = EasyMock.createMock(Emailer.class); emailer.send(subject, message, emailAddresses); EasyMock.expectLastCall().times(1); EasyMock.replay(emailer); EmailNotifier notifier = new EmailNotifier(); notifier.setEmailer(emailer); notifier.notify(subject, message, emailAddresses); EasyMock.verify(emailer); }