@Test public void shouldCreateLoggerServiceWhenEmailsAreDisabled() { TestConfiguration config = new TestConfiguration(); config.getEmail().setEnabled(false); EmailService email = new EmailServiceFactory(config, null).provide(); assertThat(email).isInstanceOf(LoggerEmailService.class); }
@Override public EmailService provide() { if (!config.getEmail().isEnabled() || config.getSendGrid() == null) { log.info("Email sending disabled, logging them to console instead."); return new LoggerEmailService(); } else { log.info("Email sending enabled with SendGrid username {}.", config.getSendGrid().getUsername()); return locator.getService(SendGridEmailService.class); } }
EmailServiceFactory implements Factory<EmailService> { @Override public EmailService provide() { if (!config.getEmail().isEnabled() || config.getSendGrid() == null) { log.info("Email sending disabled, logging them to console instead."); return new LoggerEmailService(); } else { log.info("Email sending enabled with SendGrid username {}.", config.getSendGrid().getUsername()); return locator.getService(SendGridEmailService.class); } } }
EmailServiceFactory implements Factory<EmailService> { @Override public EmailService provide() { if (!config.getEmail().isEnabled() || config.getSendGrid() == null) { log.info("Email sending disabled, logging them to console instead."); return new LoggerEmailService(); } else { log.info("Email sending enabled with SendGrid username {}.", config.getSendGrid().getUsername()); return locator.getService(SendGridEmailService.class); } } @Inject  EmailServiceFactory(HasSendGridConfiguration config, ServiceLocator locator); }
EmailServiceFactory implements Factory<EmailService> { @Override public EmailService provide() { if (!config.getEmail().isEnabled() || config.getSendGrid() == null) { log.info("Email sending disabled, logging them to console instead."); return new LoggerEmailService(); } else { log.info("Email sending enabled with SendGrid username {}.", config.getSendGrid().getUsername()); return locator.getService(SendGridEmailService.class); } } @Inject  EmailServiceFactory(HasSendGridConfiguration config, ServiceLocator locator); @Override EmailService provide(); @Override void dispose(EmailService instance); }
EmailServiceFactory implements Factory<EmailService> { @Override public EmailService provide() { if (!config.getEmail().isEnabled() || config.getSendGrid() == null) { log.info("Email sending disabled, logging them to console instead."); return new LoggerEmailService(); } else { log.info("Email sending enabled with SendGrid username {}.", config.getSendGrid().getUsername()); return locator.getService(SendGridEmailService.class); } } @Inject  EmailServiceFactory(HasSendGridConfiguration config, ServiceLocator locator); @Override EmailService provide(); @Override void dispose(EmailService instance);  }