Search in sources :

Example 1 with StartupForm

use of org.motechproject.server.web.form.StartupForm 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 2 with StartupForm

use of org.motechproject.server.web.form.StartupForm 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 3 with StartupForm

use of org.motechproject.server.web.form.StartupForm in project motech by motech.

the class StartupControllerTest method startupForm.

private StartupForm startupForm() {
    StartupForm startupForm = new StartupForm();
    startupForm.setLanguage("en");
    startupForm.setSchedulerUrl("test_scheduler_url");
    startupForm.setAdminLogin("motech");
    startupForm.setAdminEmail("motech@motech.com");
    startupForm.setAdminPassword("motech");
    startupForm.setAdminConfirmPassword("motech");
    startupForm.setProviderName("Provider");
    startupForm.setProviderUrl("test_provider_url");
    return startupForm;
}
Also used : StartupForm(org.motechproject.server.web.form.StartupForm)

Example 4 with StartupForm

use of org.motechproject.server.web.form.StartupForm in project motech by motech.

the class StartupControllerTest method shouldNotAllowStartupPostAfterStartup.

@Test
public void shouldNotAllowStartupPostAfterStartup() throws IOException {
    StartupForm form = startupForm();
    form.setLoginMode(LoginMode.REPOSITORY.getName());
    when(startupManager.getDefaultSettings()).thenReturn(motechSettings);
    when(startupManager.canLaunchBundles()).thenReturn(true);
    List<String> result = startupController.submitForm(form);
    assertTrue(result.isEmpty());
    verify(userService, never()).registerMotechAdmin(anyString(), anyString(), anyString(), any(Locale.class));
    verify(startupManager, never()).startup();
}
Also used : Locale(java.util.Locale) StartupForm(org.motechproject.server.web.form.StartupForm) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 5 with StartupForm

use of org.motechproject.server.web.form.StartupForm in project motech by motech.

the class StartupControllerTest method shouldNotRegisterAdminUserIfActiveAdminUserAlreadyExists.

@Test
public void shouldNotRegisterAdminUserIfActiveAdminUserAlreadyExists() throws IOException {
    StartupForm startupForm = startupForm();
    startupForm.setLoginMode(LoginMode.REPOSITORY.getName());
    when(startupManager.getDefaultSettings()).thenReturn(motechSettings);
    when(startupManager.canLaunchBundles()).thenReturn(true);
    when(configurationService.getPlatformSettings()).thenReturn(motechSettings);
    when(userService.hasActiveMotechAdmin()).thenReturn(true);
    startupController.submitForm(startupForm);
    verify(userService, never()).registerMotechAdmin(anyString(), anyString(), anyString(), any(Locale.class));
}
Also used : Locale(java.util.Locale) StartupForm(org.motechproject.server.web.form.StartupForm) Test(org.junit.Test)

Aggregations

StartupForm (org.motechproject.server.web.form.StartupForm)21 Test (org.junit.Test)18 Locale (java.util.Locale)5 Matchers.anyString (org.mockito.Matchers.anyString)5 ArrayList (java.util.ArrayList)4 MotechSettings (org.motechproject.config.domain.MotechSettings)2 StartupViewData (org.motechproject.server.web.dto.StartupViewData)2 Properties (java.util.Properties)1 TreeMap (java.util.TreeMap)1 ConfigSource (org.motechproject.config.core.domain.ConfigSource)1 StartupSuggestionsForm (org.motechproject.server.web.form.StartupSuggestionsForm)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1