@Test public void whenSaveCalledThenExpectRepositoryToSaveItAndReturnSavedEmailAlertsConfig() { ConfigurationManager.saveConfig( eq(EmailAlertsType.class), anyObject(EmailAlertsType.class), eq(EMAIL_ALERTS_CONFIG_YAML_FILENAME)); expect( ConfigurationManager.loadConfig( eq(EmailAlertsType.class), eq(EMAIL_ALERTS_CONFIG_YAML_FILENAME))) .andReturn(adaptExternalToInternalConfig(someUpdatedEmailAlertsConfig())); PowerMock.replayAll(); final EmailAlertsConfigRepository emailAlertsConfigRepository = new EmailAlertsConfigYamlRepository(); final EmailAlertsConfig savedConfig = emailAlertsConfigRepository.save(someUpdatedEmailAlertsConfig()); assertThat(savedConfig.isEnabled()).isEqualTo(ENABLED); assertThat(savedConfig.getSmtpConfig().getHost()).isEqualTo(UPDATED_HOST); assertThat(savedConfig.getSmtpConfig().getTlsPort()).isEqualTo(UPDATED_PORT); assertThat(savedConfig.getSmtpConfig().getFromAddress()).isEqualTo(UPDATED_FROM_ADDRESS); assertThat(savedConfig.getSmtpConfig().getToAddress()).isEqualTo(UPDATED_TO_ADDRESS); assertThat(savedConfig.getSmtpConfig().getAccountUsername()) .isEqualTo(UPDATED_ACCOUNT_USERNAME); assertThat(savedConfig.getSmtpConfig().getAccountPassword()) .isEqualTo(UPDATED_ACCOUNT_PASSWORD); PowerMock.verifyAll(); }
@Override public EmailAlertsConfig save(EmailAlertsConfig config) { LOG.info(() -> "About to save EmailAlertsConfig: " + config); final EmailAlertsType emailAlertsType = new EmailAlertsType(); emailAlertsType.setEmailAlerts(config); ConfigurationManager.saveConfig( EmailAlertsType.class, emailAlertsType, EMAIL_ALERTS_CONFIG_YAML_FILENAME); return ConfigurationManager.loadConfig(EmailAlertsType.class, EMAIL_ALERTS_CONFIG_YAML_FILENAME) .getEmailAlerts(); }
EmailAlertsConfigYamlRepository implements EmailAlertsConfigRepository { @Override public EmailAlertsConfig save(EmailAlertsConfig config) { LOG.info(() -> "About to save EmailAlertsConfig: " + config); final EmailAlertsType emailAlertsType = new EmailAlertsType(); emailAlertsType.setEmailAlerts(config); ConfigurationManager.saveConfig( EmailAlertsType.class, emailAlertsType, EMAIL_ALERTS_CONFIG_YAML_FILENAME); return ConfigurationManager.loadConfig(EmailAlertsType.class, EMAIL_ALERTS_CONFIG_YAML_FILENAME) .getEmailAlerts(); } }
EmailAlertsConfigYamlRepository implements EmailAlertsConfigRepository { @Override public EmailAlertsConfig save(EmailAlertsConfig config) { LOG.info(() -> "About to save EmailAlertsConfig: " + config); final EmailAlertsType emailAlertsType = new EmailAlertsType(); emailAlertsType.setEmailAlerts(config); ConfigurationManager.saveConfig( EmailAlertsType.class, emailAlertsType, EMAIL_ALERTS_CONFIG_YAML_FILENAME); return ConfigurationManager.loadConfig(EmailAlertsType.class, EMAIL_ALERTS_CONFIG_YAML_FILENAME) .getEmailAlerts(); }  }
EmailAlertsConfigYamlRepository implements EmailAlertsConfigRepository { @Override public EmailAlertsConfig save(EmailAlertsConfig config) { LOG.info(() -> "About to save EmailAlertsConfig: " + config); final EmailAlertsType emailAlertsType = new EmailAlertsType(); emailAlertsType.setEmailAlerts(config); ConfigurationManager.saveConfig( EmailAlertsType.class, emailAlertsType, EMAIL_ALERTS_CONFIG_YAML_FILENAME); return ConfigurationManager.loadConfig(EmailAlertsType.class, EMAIL_ALERTS_CONFIG_YAML_FILENAME) .getEmailAlerts(); }  @Override EmailAlertsConfig get(); @Override EmailAlertsConfig save(EmailAlertsConfig config); }
EmailAlertsConfigYamlRepository implements EmailAlertsConfigRepository { @Override public EmailAlertsConfig save(EmailAlertsConfig config) { LOG.info(() -> "About to save EmailAlertsConfig: " + config); final EmailAlertsType emailAlertsType = new EmailAlertsType(); emailAlertsType.setEmailAlerts(config); ConfigurationManager.saveConfig( EmailAlertsType.class, emailAlertsType, EMAIL_ALERTS_CONFIG_YAML_FILENAME); return ConfigurationManager.loadConfig(EmailAlertsType.class, EMAIL_ALERTS_CONFIG_YAML_FILENAME) .getEmailAlerts(); }  @Override EmailAlertsConfig get(); @Override EmailAlertsConfig save(EmailAlertsConfig config);  }