ConfigurationServiceImpl implements ConfigurationService { @Transactional @NonAuditable public EhourConfigStub getConfiguration() { List<Configuration> configs = configDao.findAll(); EhourConfigStub config = new EhourConfigStub(); List<String> translations = translationDiscovery.getTranslations(); if (translations != null) { config.setAvailableTranslations(translations.toArray(new String[translations.size()])); } for (Configuration configuration : configs) { String key = configuration.getConfigKey(); String value = configuration.getConfigValue(); if (key.equalsIgnoreCase(ConfigurationItem.COMPLETE_DAY_HOURS.getDbField())) { config.setCompleteDayHours(Float.parseFloat(value)); } else if (key.equalsIgnoreCase(ConfigurationItem.LOCALE_CURRENCY.getDbField())) { config.setCurrency(LocaleUtil.forLanguageTag(value)); } else if (key.equalsIgnoreCase(ConfigurationItem.LOCALE_LANGUAGE.getDbField())) { config.setLocaleLanguage(LocaleUtil.forLanguageTag(value)); } else if (key.equalsIgnoreCase(ConfigurationItem.LOCALE_COUNTRY.getDbField())) { config.setLocaleFormatting(LocaleUtil.forLanguageTag(value)); } else if (key.equalsIgnoreCase(ConfigurationItem.SHOW_TURNOVER.getDbField())) { config.setShowTurnover(Boolean.parseBoolean(value)); } else if (key.equalsIgnoreCase(ConfigurationItem.TIMEZONE.getDbField())) { config.setTimeZone(value); } else if (key.equalsIgnoreCase(ConfigurationItem.MAIL_FROM.getDbField())) { config.setMailFrom(value); } else if (key.equalsIgnoreCase(ConfigurationItem.MAIL_SMTP.getDbField())) { config.setMailSmtp(value); } else if (key.equalsIgnoreCase(ConfigurationItem.MAIL_SMTP_USERNAME.getDbField())) { config.setSmtpUsername(value); } else if (key.equalsIgnoreCase(ConfigurationItem.MAIL_SMTP_PASSWORD.getDbField())) { config.setSmtpPassword(value); } else if (key.equalsIgnoreCase(ConfigurationItem.MAIL_SMTP_PORT.getDbField())) { config.setSmtpPort(value); } else if (key.equalsIgnoreCase(ConfigurationItem.DEMO_MODE.getDbField())) { config.setDemoMode(Boolean.parseBoolean(value)); } else if (key.equalsIgnoreCase((ConfigurationItem.INITIALIZED.getDbField()))) { config.setInitialized(Boolean.parseBoolean(value)); } else if (key.equalsIgnoreCase((ConfigurationItem.FIRST_DAY_OF_WEEK.getDbField()))) { config.setFirstDayOfWeek((int) (Float.parseFloat(value))); } else if (key.equalsIgnoreCase((ConfigurationItem.AUDIT_TYPE.getDbField()))) { config.setAuditType(AuditType.fromString(value)); } else if (key.equalsIgnoreCase((ConfigurationItem.VERSION.getDbField()))) { config.setVersion(value); } else if (key.equalsIgnoreCase(ConfigurationItem.PM_PRIVILEGE.getDbField())) { config.setPmPrivilege(PmPrivilege.valueOf(value)); } else if (key.equalsIgnoreCase(ConfigurationItem.SPLIT_ADMIN_ROLE.getDbField())) { config.setSplitAdminRole(Boolean.parseBoolean(value)); } else if (key.equalsIgnoreCase(ConfigurationItem.REMINDER_ENABLED.getDbField())) { config.setReminderEnabled(Boolean.parseBoolean(value)); } else if (key.equalsIgnoreCase(ConfigurationItem.REMINDER_CC.getDbField())) { config.setReminderCC(value); } else if (key.equalsIgnoreCase(ConfigurationItem.REMINDER_BODY.getDbField())) { config.setReminderBody(value); } else if (key.equalsIgnoreCase(ConfigurationItem.REMINDER_MIN_HOURS.getDbField())) { config.setReminderMinimalHours((int) Float.parseFloat(value)); } else if (key.equalsIgnoreCase(ConfigurationItem.REMINDER_SUBJECT.getDbField())) { config.setReminderSubject(value); } else if (key.equalsIgnoreCase(ConfigurationItem.REMINDER_TIME.getDbField())) { config.setReminderTime(value); } } return config; }  @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 shouldGetConfiguration() { List<Configuration> configs = Arrays.asList(new Configuration("availableTranslations", "en,nl"), new Configuration("completeDayHours", "8"), new Configuration("localeCurrency", "nlNl"), new Configuration("localeLanguage", "nlNl"), new Configuration("localeCountry", "nlNl"), new Configuration("showTurnOver", "true"), new Configuration("timeZone", "CET"), new Configuration("mailFrom", "ik@jij.net"), new Configuration("mailSmtp", "localhost"), new Configuration("demoMode", "false"), new Configuration("splitAdminRole", "true")); when(configDAO.findAll()).thenReturn(configs); EhourConfigStub configuration = configurationService.getConfiguration(); assertTrue(configuration.isShowTurnover()); assertTrue(configuration.isSplitAdminRole()); }