@Test public void IsAvailable_WhenSomeValuesMissing_ReturnsFalse(){ PreferenceHelper pm = mock(PreferenceHelper.class); when(pm.getAutoEmailTargets()).thenReturn("aaaaaa"); when(pm.getSmtpServer()).thenReturn(""); when(pm.getSmtpPort()).thenReturn("bbbbbbb"); when(pm.getSmtpUsername()).thenReturn("bbbbbbb"); AutoEmailManager aem = new AutoEmailManager(pm); assertThat("Some values missing indicates invalid email settings", aem.isAvailable(), is(false)); }
@Override public boolean isAvailable() { return isValid( preferenceHelper.getSmtpServer(), preferenceHelper.getSmtpPort(), preferenceHelper.getSmtpUsername(), preferenceHelper.getSmtpPassword(), preferenceHelper.getAutoEmailTargets()); }
AutoEmailManager extends FileSender { @Override public boolean isAvailable() { return isValid( preferenceHelper.getSmtpServer(), preferenceHelper.getSmtpPort(), preferenceHelper.getSmtpUsername(), preferenceHelper.getSmtpPassword(), preferenceHelper.getAutoEmailTargets()); } }
AutoEmailManager extends FileSender { @Override public boolean isAvailable() { return isValid( preferenceHelper.getSmtpServer(), preferenceHelper.getSmtpPort(), preferenceHelper.getSmtpUsername(), preferenceHelper.getSmtpPassword(), preferenceHelper.getAutoEmailTargets()); } AutoEmailManager(PreferenceHelper helper); }
AutoEmailManager extends FileSender { @Override public boolean isAvailable() { return isValid( preferenceHelper.getSmtpServer(), preferenceHelper.getSmtpPort(), preferenceHelper.getSmtpUsername(), preferenceHelper.getSmtpPassword(), preferenceHelper.getAutoEmailTargets()); } AutoEmailManager(PreferenceHelper helper); @Override void uploadFile(List<File> files); @Override boolean isAvailable(); @Override boolean hasUserAllowedAutoSending(); void sendTestEmail(String smtpServer, String smtpPort,
                       String smtpUsername, String smtpPassword, boolean smtpUseSsl,
                       String emailTarget, String fromAddress); @Override boolean accept(File dir, String name); boolean isValid(String server, String port, String username, String password, String target); }
AutoEmailManager extends FileSender { @Override public boolean isAvailable() { return isValid( preferenceHelper.getSmtpServer(), preferenceHelper.getSmtpPort(), preferenceHelper.getSmtpUsername(), preferenceHelper.getSmtpPassword(), preferenceHelper.getAutoEmailTargets()); } AutoEmailManager(PreferenceHelper helper); @Override void uploadFile(List<File> files); @Override boolean isAvailable(); @Override boolean hasUserAllowedAutoSending(); void sendTestEmail(String smtpServer, String smtpPort,
                       String smtpUsername, String smtpPassword, boolean smtpUseSsl,
                       String emailTarget, String fromAddress); @Override boolean accept(File dir, String name); boolean isValid(String server, String port, String username, String password, String target);  }