Search in sources :

Example 1 with Settings

use of org.motechproject.admin.settings.Settings 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);
}
Also used : SettingsOption(org.motechproject.admin.settings.SettingsOption) AdminSettings(org.motechproject.admin.settings.AdminSettings) Settings(org.motechproject.admin.settings.Settings) MotechSettings(org.motechproject.config.domain.MotechSettings) Test(org.junit.Test)

Example 2 with Settings

use of org.motechproject.admin.settings.Settings 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();
}
Also used : AbstractMap(java.util.AbstractMap) ArrayList(java.util.ArrayList) SettingsOption(org.motechproject.admin.settings.SettingsOption) AdminSettings(org.motechproject.admin.settings.AdminSettings) Settings(org.motechproject.admin.settings.Settings) AdminSettings(org.motechproject.admin.settings.AdminSettings) Test(org.junit.Test)

Example 3 with Settings

use of org.motechproject.admin.settings.Settings 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());
}
Also used : AdminSettings(org.motechproject.admin.settings.AdminSettings) Settings(org.motechproject.admin.settings.Settings) MotechSettings(org.motechproject.config.domain.MotechSettings) SettingsOption(org.motechproject.admin.settings.SettingsOption) Test(org.junit.Test)

Example 4 with Settings

use of org.motechproject.admin.settings.Settings 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);
}
Also used : SettingsOption(org.motechproject.admin.settings.SettingsOption) AdminSettings(org.motechproject.admin.settings.AdminSettings) Settings(org.motechproject.admin.settings.Settings) MotechSettings(org.motechproject.config.domain.MotechSettings) Test(org.junit.Test)

Example 5 with Settings

use of org.motechproject.admin.settings.Settings in project motech by motech.

the class SettingsServiceTest method testGetSettings.

@Test
public void testGetSettings() {
    AdminSettings adminSettings = settingsService.getSettings();
    assertNotNull(adminSettings);
    List<Settings> platformSettingsList = adminSettings.getSettingsList();
    assertEquals(false, adminSettings.isReadOnly());
    assertEquals(3, platformSettingsList.size());
    SettingsOption option = platformSettingsList.get(0).getSettings().get(0);
    assertEquals(LANGUAGE, option.getKey());
    assertEquals(LANGUAGE_VALUE, option.getValue());
    verify(configurationService).getPlatformSettings();
}
Also used : AdminSettings(org.motechproject.admin.settings.AdminSettings) Settings(org.motechproject.admin.settings.Settings) MotechSettings(org.motechproject.config.domain.MotechSettings) SettingsOption(org.motechproject.admin.settings.SettingsOption) AdminSettings(org.motechproject.admin.settings.AdminSettings) Test(org.junit.Test)

Aggregations

AdminSettings (org.motechproject.admin.settings.AdminSettings)8 Settings (org.motechproject.admin.settings.Settings)8 SettingsOption (org.motechproject.admin.settings.SettingsOption)7 MotechSettings (org.motechproject.config.domain.MotechSettings)7 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 AbstractMap (java.util.AbstractMap)1 Map (java.util.Map)1 Properties (java.util.Properties)1 MotechEvent (org.motechproject.event.MotechEvent)1