StartupController { @RequestMapping(value = "/startup", method = RequestMethod.GET) public ModelAndView startup() { ModelAndView view = new ModelAndView("startup"); if (startupManager.canLaunchBundles()) { view.setViewName(REDIRECT_HOME); } return view; }  @RequestMapping(value = "/startupviewdata", method = RequestMethod.GET) @ResponseBody StartupViewData getStartupViewData(final HttpServletRequest request); @RequestMapping(value = "/startup", method = RequestMethod.GET) ModelAndView startup(); @RequestMapping(value = "/startup", method = RequestMethod.POST) @ResponseBody List<String> submitForm(@RequestBody StartupForm startupSettings); void setStartupFormValidatorFactory(StartupFormValidatorFactory validatorFactory);  }
@Test public void testStartup() { Properties properties = new Properties(); properties.put("host", "localhost"); properties.put("port", "12345"); NavigableMap<String, String> map = new TreeMap<>(); when(startupManager.canLaunchBundles()).thenReturn(false); when(startupManager.getDefaultSettings()).thenReturn(motechSettings); when(localeService.getUserLocale(httpServletRequest)).thenReturn(new Locale("en")); when(localeService.getSupportedLanguages()).thenReturn(map); when(configurationService.getPlatformSettings()).thenReturn(motechSettings); StartupViewData result = startupController.getStartupViewData(httpServletRequest); verify(startupManager).canLaunchBundles(); verify(localeService).getSupportedLanguages(); verify(localeService).getUserLocale(httpServletRequest); assertThat(result.getRedirectHome(), Is.is(false)); StartupSuggestionsForm startupSuggestionsForm = result.getSuggestions(); assertTrue(startupSuggestionsForm.getDatabaseUrls().isEmpty()); assertTrue(startupSuggestionsForm.getQueueUrls().isEmpty()); assertTrue(startupSuggestionsForm.getSchedulerUrls().isEmpty()); StartupForm startupSettings = result.getStartupSettings(); Boolean requiresConfigFiles = result.getRequireConfigFiles(); Assert.assertFalse(requiresConfigFiles); assertEquals("en", startupSettings.getLanguage()); }
@Test public void testStartupRedirectToHome() { when(startupManager.canLaunchBundles()).thenReturn(true); ModelAndView result = startupController.startup(); assertEquals("redirect:home", result.getViewName()); }