use of org.motechproject.admin.settings.SettingsOption in project motech by motech.
the class SettingsServiceTest method shouldSaveNullSettingAsNullValue.
@Test
public void shouldSaveNullSettingAsNullValue() {
SettingsOption option = new SettingsOption(OPTION_KEY, null);
Settings settings = new Settings("section", singletonList(option));
settingsService.savePlatformSettings(settings);
verify(configurationService).setPlatformSetting(OPTION_KEY, null);
}
use of org.motechproject.admin.settings.SettingsOption in project motech by motech.
the class SettingsServiceImpl method savePlatformSettings.
@Override
public void savePlatformSettings(Settings settings) {
for (SettingsOption option : settings.getSettings()) {
Object val = option.getValue();
configurationService.setPlatformSetting(option.getKey(), val == null ? null : String.valueOf(val));
}
Map<String, Object> params = new HashMap<>();
params.put(ConfigurationConstants.SETTINGS, settings);
MotechEvent platformSettingsChangedEvent = new MotechEvent(ConfigurationConstants.BUNDLE_SETTINGS_CHANGED_EVENT_SUBJECT, params);
eventRelay.sendEventMessage(platformSettingsChangedEvent);
}
use of org.motechproject.admin.settings.SettingsOption in project motech by motech.
the class SettingsControllerTest method testGetPlatformSettings.
@Test
public void testGetPlatformSettings() {
SettingsOption option = new SettingsOption(new AbstractMap.SimpleEntry<Object, Object>(ConfigurationConstants.LANGUAGE, "en"));
List<Settings> pSettingsList = new ArrayList<>();
pSettingsList.add(platformSettings);
AdminSettings adminSettings = new AdminSettings(pSettingsList, false);
when(settingsService.getSettings()).thenReturn(adminSettings);
when(platformSettings.getSettings()).thenReturn(Arrays.asList(option));
List<Settings> result = controller.getPlatformSettings().getSettingsList();
assertEquals(option.getKey(), result.get(0).getSettings().get(0).getKey());
assertEquals(option.getValue(), result.get(0).getSettings().get(0).getValue());
verify(settingsService).getSettings();
}
use of org.motechproject.admin.settings.SettingsOption in project motech by motech.
the class SettingsServiceTest method testGetBundleSettings.
@Test
public void testGetBundleSettings() throws IOException {
List<Settings> bundleSettingsList = settingsService.getBundleSettings(BUNDLE_ID);
assertEquals(1, bundleSettingsList.size());
Settings bundleSettings = bundleSettingsList.get(0);
assertEquals(BUNDLE_FILENAME, bundleSettings.getSection());
List<SettingsOption> settingsOptions = bundleSettings.getSettings();
assertEquals(1, settingsOptions.size());
assertEquals(OPTION_KEY, settingsOptions.get(0).getKey());
assertEquals(OPTION_VALUE, settingsOptions.get(0).getValue());
}
use of org.motechproject.admin.settings.SettingsOption in project motech by motech.
the class SettingsServiceTest method testSaveBundleSettings.
@Test
public void testSaveBundleSettings() throws IOException {
SettingsOption option = new SettingsOption(OPTION_KEY, OPTION_VALUE);
Settings settings = new Settings(BUNDLE_FILENAME, singletonList(option));
settingsService.saveBundleSettings(settings, BUNDLE_ID);
verify(configurationService).addOrUpdateProperties(BUNDLE_SYMBOLIC_NAME, "", BUNDLE_FILENAME, bundleProperty, null);
}
Aggregations