EmailNotifier implements Notifier { @Override public void notifyAdmins(String subject, String message) { checkInitialized(); log.debug("Sending email to " + adminEmails.size() + " administrators with subject: [" + subject + "] and message: [" + message + "]"); emailer.send(subject, message, adminEmails.toArray(new String[adminEmails.size()])); }  @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 testNotifyAdmins() { String admin1 = "admin1"; String admin2 = "admin2"; List<String> adminEmails = new ArrayList<String>(); adminEmails.add(admin1); adminEmails.add(admin2); String[] adminEmailArray = {admin1, admin2}; Emailer emailer = EasyMock.createMock(Emailer.class); emailer.send(subject, message, adminEmailArray); EasyMock.expectLastCall().times(1); EasyMock.replay(emailer); EmailNotifier notifier = new EmailNotifier(); notifier.setEmailer(emailer); notifier.setAdminEmails(adminEmails); notifier.notifyAdmins(subject, message); EasyMock.verify(emailer); }