Search in sources :

Example 1 with MotechSettings

use of org.motechproject.config.domain.MotechSettings in project motech by motech.

the class ConfigurationServiceBundleIT method shouldGetProperlyPlatformSettings.

@Test
public void shouldGetProperlyPlatformSettings() {
    prepareDbSettingsRecord();
    MotechSettings settingsRecord = configurationService.getPlatformSettings();
    assertEquals(SERVER_URL_TEST, settingsRecord.getServerUrl());
    assertEquals(Integer.valueOf(80), settingsRecord.getSessionTimeout());
    assertEquals(true, settingsRecord.getEmailRequired());
}
Also used : MotechSettings(org.motechproject.config.domain.MotechSettings) Test(org.junit.Test)

Example 2 with MotechSettings

use of org.motechproject.config.domain.MotechSettings in project motech by motech.

the class StartupControllerTest method testSubmitFormOpenId.

@Test
public void testSubmitFormOpenId() throws IOException {
    StartupForm startupForm = startupForm();
    startupForm.setProviderUrl("https://www.example.com/accounts/id");
    startupForm.setLoginMode(LoginMode.OPEN_ID.getName());
    when(startupManager.getDefaultSettings()).thenReturn(motechSettings);
    when(configurationService.getPlatformSettings()).thenReturn(motechSettings);
    List<String> result = startupController.submitForm(startupForm);
    assertTrue(result.isEmpty());
    verify(configurationService).savePlatformSettings(any(MotechSettings.class));
    verify(startupManager).startup();
    verify(userService, never()).registerMotechAdmin(anyString(), anyString(), anyString(), any(Locale.class));
}
Also used : Locale(java.util.Locale) MotechSettings(org.motechproject.config.domain.MotechSettings) StartupForm(org.motechproject.server.web.form.StartupForm) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 3 with MotechSettings

use of org.motechproject.config.domain.MotechSettings in project motech by motech.

the class StartupControllerTest method testSubmitFormStart.

@Test
public void testSubmitFormStart() throws IOException {
    StartupForm startupForm = startupForm();
    startupForm.setLoginMode(LoginMode.REPOSITORY.getName());
    when(startupManager.getDefaultSettings()).thenReturn(motechSettings);
    when(configurationService.getPlatformSettings()).thenReturn(motechSettings);
    List<String> result = startupController.submitForm(startupForm);
    assertTrue(result.isEmpty());
    verify(configurationService).savePlatformSettings(any(MotechSettings.class));
    verify(startupManager).startup();
    verifyUserRegistration();
}
Also used : MotechSettings(org.motechproject.config.domain.MotechSettings) StartupForm(org.motechproject.server.web.form.StartupForm) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 4 with MotechSettings

use of org.motechproject.config.domain.MotechSettings in project motech by motech.

the class SettingServiceImpl method getNumberOfDaysForReminder.

@Override
public int getNumberOfDaysForReminder() {
    MotechSettings motechSettings = configurationService.getPlatformSettings();
    Integer days = motechSettings.getNumberOfDaysForReminder();
    return days == null ? 0 : days;
}
Also used : MotechSettings(org.motechproject.config.domain.MotechSettings)

Example 5 with MotechSettings

use of org.motechproject.config.domain.MotechSettings in project motech by motech.

the class SettingServiceImpl method getNumberOfDaysToChangePassword.

@Override
public int getNumberOfDaysToChangePassword() {
    MotechSettings motechSettings = configurationService.getPlatformSettings();
    Integer days = motechSettings.getNumberOfDaysToChangePassword();
    return days == null ? 0 : days;
}
Also used : MotechSettings(org.motechproject.config.domain.MotechSettings)

Aggregations

MotechSettings (org.motechproject.config.domain.MotechSettings)13 Test (org.junit.Test)5 Matchers.anyString (org.mockito.Matchers.anyString)2 StartupForm (org.motechproject.server.web.form.StartupForm)2 ArrayList (java.util.ArrayList)1 Locale (java.util.Locale)1 AdminSettings (org.motechproject.admin.settings.AdminSettings)1 Settings (org.motechproject.admin.settings.Settings)1 SettingsOption (org.motechproject.admin.settings.SettingsOption)1 ConfigLocation (org.motechproject.config.core.domain.ConfigLocation)1 ConfigSource (org.motechproject.config.core.domain.ConfigSource)1 PasswordRecovery (org.motechproject.security.domain.PasswordRecovery)1 PasswordValidator (org.motechproject.security.validator.PasswordValidator)1 MinLengthValidatorDecorator (org.motechproject.security.validator.impl.MinLengthValidatorDecorator)1 StartupFormValidator (org.motechproject.server.web.validator.StartupFormValidator)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1