@Test public void createSender() { Map<String, String> settings = Maps.newHashMap(); settings.put(SystemSettingsStore.MAIL_HOST_NAME, "host"); settings.put(SystemSettingsStore.MAIL_HOST_PORT, "25"); when(systemSettingsStore.getSettings()).thenReturn(settings); JavaMailSender sender = mailSenderFactory.createSender(); assertEquals("host", Whitebox.getInternalState(sender, "host")); assertEquals(25, (int) ((Integer) Whitebox.getInternalState(sender, "port"))); settings.remove(SystemSettingsStore.MAIL_HOST_NAME); assertNull(mailSenderFactory.createSender()); }
JavaMailSender createSender() { Map<String, String> settings = systemSettingsStore.getSettings(); String host = settings.get(SystemSettingsStore.MAIL_HOST_NAME); int port = Integer.parseInt(settings.get(SystemSettingsStore.MAIL_HOST_PORT)); if (StringUtils.isNotBlank(host)) { JavaMailSenderImpl sender = new JavaMailSenderImpl(); sender.setHost(host); sender.setPort(port); return sender; } else { return null; } }
MailSenderFactory { JavaMailSender createSender() { Map<String, String> settings = systemSettingsStore.getSettings(); String host = settings.get(SystemSettingsStore.MAIL_HOST_NAME); int port = Integer.parseInt(settings.get(SystemSettingsStore.MAIL_HOST_PORT)); if (StringUtils.isNotBlank(host)) { JavaMailSenderImpl sender = new JavaMailSenderImpl(); sender.setHost(host); sender.setPort(port); return sender; } else { return null; } } }
MailSenderFactory { JavaMailSender createSender() { Map<String, String> settings = systemSettingsStore.getSettings(); String host = settings.get(SystemSettingsStore.MAIL_HOST_NAME); int port = Integer.parseInt(settings.get(SystemSettingsStore.MAIL_HOST_PORT)); if (StringUtils.isNotBlank(host)) { JavaMailSenderImpl sender = new JavaMailSenderImpl(); sender.setHost(host); sender.setPort(port); return sender; } else { return null; } }  }
MailSenderFactory { JavaMailSender createSender() { Map<String, String> settings = systemSettingsStore.getSettings(); String host = settings.get(SystemSettingsStore.MAIL_HOST_NAME); int port = Integer.parseInt(settings.get(SystemSettingsStore.MAIL_HOST_PORT)); if (StringUtils.isNotBlank(host)) { JavaMailSenderImpl sender = new JavaMailSenderImpl(); sender.setHost(host); sender.setPort(port); return sender; } else { return null; } }   }
MailSenderFactory { JavaMailSender createSender() { Map<String, String> settings = systemSettingsStore.getSettings(); String host = settings.get(SystemSettingsStore.MAIL_HOST_NAME); int port = Integer.parseInt(settings.get(SystemSettingsStore.MAIL_HOST_PORT)); if (StringUtils.isNotBlank(host)) { JavaMailSenderImpl sender = new JavaMailSenderImpl(); sender.setHost(host); sender.setPort(port); return sender; } else { return null; } }    }