ConfigurationServiceImpl implements ConfigurationService { @Transactional @Auditable(actionType = AuditActionType.UPDATE) public void persistConfiguration(EhourConfig config) { LOGGER.debug("Persisting config"); persistConfig(ConfigurationItem.LOCALE_CURRENCY.getDbField(), LocaleUtil.toLanguageTag((config.getCurrency()))); if (config.getCompleteDayHours() != 0) { persistConfig(ConfigurationItem.COMPLETE_DAY_HOURS.getDbField(), config.getCompleteDayHours()); } persistConfig(ConfigurationItem.LOCALE_COUNTRY.getDbField(), LocaleUtil.toLanguageTag(config.getFormattingLocale())); persistConfig(ConfigurationItem.LOCALE_LANGUAGE.getDbField(), LocaleUtil.toLanguageTag(config.getLanguageLocale())); persistConfig(ConfigurationItem.DONT_FORCE_LANGUAGE.getDbField(), config.isDontForceLanguage()); persistConfig(ConfigurationItem.SHOW_TURNOVER.getDbField(), config.isShowTurnover()); persistConfig(ConfigurationItem.MAIL_FROM.getDbField(), config.getMailFrom()); persistConfig(ConfigurationItem.MAIL_SMTP.getDbField(), config.getMailSmtp()); persistConfig(ConfigurationItem.MAIL_SMTP_USERNAME.getDbField(), config.getSmtpUsername()); persistConfig(ConfigurationItem.MAIL_SMTP_PASSWORD.getDbField(), config.getSmtpPassword()); persistConfig(ConfigurationItem.MAIL_SMTP_PORT.getDbField(), config.getSmtpPort()); persistConfig(ConfigurationItem.INITIALIZED.getDbField(), config.isInitialized()); persistConfig(ConfigurationItem.FIRST_DAY_OF_WEEK.getDbField(), config.getFirstDayOfWeek()); persistConfig(ConfigurationItem.AUDIT_TYPE.getDbField(), getAuditType(config).getValue()); persistConfig(ConfigurationItem.PM_PRIVILEGE.getDbField(), getPmPrivilege(config).name()); persistConfig(ConfigurationItem.SPLIT_ADMIN_ROLE.getDbField(), config.isSplitAdminRole()); persistConfig(ConfigurationItem.REMINDER_BODY.getDbField(), config.getReminderBody()); persistConfig(ConfigurationItem.REMINDER_CC.getDbField(), config.getReminderCC()); persistConfig(ConfigurationItem.REMINDER_ENABLED.getDbField(), config.isReminderEnabled()); persistConfig(ConfigurationItem.REMINDER_MIN_HOURS.getDbField(), config.getReminderMinimalHours()); persistConfig(ConfigurationItem.REMINDER_SUBJECT.getDbField(), config.getReminderSubject()); persistConfig(ConfigurationItem.REMINDER_TIME.getDbField(), config.getReminderTime()); persistConfig(ConfigurationItem.TIMEZONE.getDbField(), config.getTimeZone()); }  @Transactional @Auditable(actionType = AuditActionType.UPDATE) void persistExcelLogo(ImageLogo logo); @NonAuditable @Transactional ImageLogo getExcelLogo(); @Transactional @NonAuditable EhourConfigStub getConfiguration(); @Override List<Configuration> findAllConfiguration(); @Transactional @Auditable(actionType = AuditActionType.UPDATE) void persistConfiguration(EhourConfig config); void setConfigDao(ConfigurationDao configDao); void setBinConfigDAO(BinaryConfigurationDao binaryConfigDAO); void setTranslationDiscovery(TranslationDiscovery translationDiscovery);  }
@Test public void shouldPersistConfiguration() { EhourConfigStub stub = new EhourConfigStub(); stub.setCompleteDayHours(8); stub.setLocaleFormatting(LocaleUtil.forLanguageTag("en-US")); stub.setDontForceLanguage(true); stub.setShowTurnover(true); stub.setMailFrom("re"); stub.setMailSmtp("ee"); stub.setAuditType(AuditType.WRITE); configurationService.persistConfiguration(stub); ArgumentCaptor<Configuration> configCapture = ArgumentCaptor.forClass(Configuration.class); verify(configDAO, times(23)).persist(configCapture.capture()); List<Configuration> configurations = configCapture.getAllValues(); assertThat(new Configuration("mailSmtp", "ee"), isIn(configurations)); }