@Test public void shouldInformViewThatConfigFilesNotRequiredWhenConfigSourceIsFileAndConfigFilesExist() throws IOException { when(configurationService.requiresConfigurationFiles()).thenReturn(true); when(localeService.getUserLocale(httpServletRequest)).thenReturn(new Locale("en")); BootstrapConfig bootstrapConfig = mock(BootstrapConfig.class); when(bootstrapConfig.getConfigSource()).thenReturn(ConfigSource.FILE); when(configurationService.loadBootstrapConfig()).thenReturn(bootstrapConfig); when(configurationService.requiresConfigurationFiles()).thenReturn(false); StartupViewData startupViewData = startupController.getStartupViewData(httpServletRequest); assertThat((startupViewData.getRequireConfigFiles()), Is.is(false)); verify(configurationService).requiresConfigurationFiles(); }
@RequestMapping(value = "/startupviewdata", method = RequestMethod.GET) @ResponseBody public StartupViewData getStartupViewData(final HttpServletRequest request) { StartupViewData viewData = new StartupViewData(); if (startupManager.canLaunchBundles()) { viewData.setRedirectHome(true); return viewData; } else { Locale userLocale = localeService.getUserLocale(request); ConfigSource configSource = (configurationService.loadBootstrapConfig() != null) ? configurationService.loadBootstrapConfig().getConfigSource() : ConfigSource.UI; boolean requiresConfigFiles = configSource.isFile() && configurationService.requiresConfigurationFiles(); StartupForm startupSettings = new StartupForm(); startupSettings.setLanguage(userLocale.getLanguage()); viewData.setRequireConfigFiles(requiresConfigFiles); viewData.setSuggestions(createSuggestions()); viewData.setStartupSettings(startupSettings); viewData.setLanguages(localeService.getSupportedLanguages()); viewData.setPageLang(userLocale); viewData.setIsFileMode(ConfigSource.FILE.equals(configSource)); viewData.setIsAdminRegistered(userService.hasActiveMotechAdmin()); viewData.setRedirectHome(false); } return viewData; }
StartupController { @RequestMapping(value = "/startupviewdata", method = RequestMethod.GET) @ResponseBody public StartupViewData getStartupViewData(final HttpServletRequest request) { StartupViewData viewData = new StartupViewData(); if (startupManager.canLaunchBundles()) { viewData.setRedirectHome(true); return viewData; } else { Locale userLocale = localeService.getUserLocale(request); ConfigSource configSource = (configurationService.loadBootstrapConfig() != null) ? configurationService.loadBootstrapConfig().getConfigSource() : ConfigSource.UI; boolean requiresConfigFiles = configSource.isFile() && configurationService.requiresConfigurationFiles(); StartupForm startupSettings = new StartupForm(); startupSettings.setLanguage(userLocale.getLanguage()); viewData.setRequireConfigFiles(requiresConfigFiles); viewData.setSuggestions(createSuggestions()); viewData.setStartupSettings(startupSettings); viewData.setLanguages(localeService.getSupportedLanguages()); viewData.setPageLang(userLocale); viewData.setIsFileMode(ConfigSource.FILE.equals(configSource)); viewData.setIsAdminRegistered(userService.hasActiveMotechAdmin()); viewData.setRedirectHome(false); } return viewData; } }
StartupController { @RequestMapping(value = "/startupviewdata", method = RequestMethod.GET) @ResponseBody public StartupViewData getStartupViewData(final HttpServletRequest request) { StartupViewData viewData = new StartupViewData(); if (startupManager.canLaunchBundles()) { viewData.setRedirectHome(true); return viewData; } else { Locale userLocale = localeService.getUserLocale(request); ConfigSource configSource = (configurationService.loadBootstrapConfig() != null) ? configurationService.loadBootstrapConfig().getConfigSource() : ConfigSource.UI; boolean requiresConfigFiles = configSource.isFile() && configurationService.requiresConfigurationFiles(); StartupForm startupSettings = new StartupForm(); startupSettings.setLanguage(userLocale.getLanguage()); viewData.setRequireConfigFiles(requiresConfigFiles); viewData.setSuggestions(createSuggestions()); viewData.setStartupSettings(startupSettings); viewData.setLanguages(localeService.getSupportedLanguages()); viewData.setPageLang(userLocale); viewData.setIsFileMode(ConfigSource.FILE.equals(configSource)); viewData.setIsAdminRegistered(userService.hasActiveMotechAdmin()); viewData.setRedirectHome(false); } return viewData; }  }
StartupController { @RequestMapping(value = "/startupviewdata", method = RequestMethod.GET) @ResponseBody public StartupViewData getStartupViewData(final HttpServletRequest request) { StartupViewData viewData = new StartupViewData(); if (startupManager.canLaunchBundles()) { viewData.setRedirectHome(true); return viewData; } else { Locale userLocale = localeService.getUserLocale(request); ConfigSource configSource = (configurationService.loadBootstrapConfig() != null) ? configurationService.loadBootstrapConfig().getConfigSource() : ConfigSource.UI; boolean requiresConfigFiles = configSource.isFile() && configurationService.requiresConfigurationFiles(); StartupForm startupSettings = new StartupForm(); startupSettings.setLanguage(userLocale.getLanguage()); viewData.setRequireConfigFiles(requiresConfigFiles); viewData.setSuggestions(createSuggestions()); viewData.setStartupSettings(startupSettings); viewData.setLanguages(localeService.getSupportedLanguages()); viewData.setPageLang(userLocale); viewData.setIsFileMode(ConfigSource.FILE.equals(configSource)); viewData.setIsAdminRegistered(userService.hasActiveMotechAdmin()); viewData.setRedirectHome(false); } return viewData; }  @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); }
StartupController { @RequestMapping(value = "/startupviewdata", method = RequestMethod.GET) @ResponseBody public StartupViewData getStartupViewData(final HttpServletRequest request) { StartupViewData viewData = new StartupViewData(); if (startupManager.canLaunchBundles()) { viewData.setRedirectHome(true); return viewData; } else { Locale userLocale = localeService.getUserLocale(request); ConfigSource configSource = (configurationService.loadBootstrapConfig() != null) ? configurationService.loadBootstrapConfig().getConfigSource() : ConfigSource.UI; boolean requiresConfigFiles = configSource.isFile() && configurationService.requiresConfigurationFiles(); StartupForm startupSettings = new StartupForm(); startupSettings.setLanguage(userLocale.getLanguage()); viewData.setRequireConfigFiles(requiresConfigFiles); viewData.setSuggestions(createSuggestions()); viewData.setStartupSettings(startupSettings); viewData.setLanguages(localeService.getSupportedLanguages()); viewData.setPageLang(userLocale); viewData.setIsFileMode(ConfigSource.FILE.equals(configSource)); viewData.setIsAdminRegistered(userService.hasActiveMotechAdmin()); viewData.setRedirectHome(false); } return viewData; }  @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);  }