ConfigLoader { public List<File> findExistingConfigs() throws IOException { final ConfigLocation currentConfigLocation = coreConfigurationService.getConfigLocation(); return currentConfigLocation.getExistingConfigFiles(); }  SettingsRecord loadMotechSettings(); List<File> findExistingConfigs(); SettingsRecord loadDefaultConfig(); @Autowired void setResourceLoader(ResourceLoader resourceLoader); @Autowired void setCoreConfigurationService(CoreConfigurationService coreConfigurationService);  }
@Test public void shouldLoadSupportedFilesFromGivenConfigLocation() throws IOException { final String dirPath = FileHelper.getResourceFile("config").getAbsolutePath(); final File file1 = new File(dirPath, "motech-settings.properties"); final File file2 = new File(dirPath, "org.motechproject.motech-module1/somemodule.properties"); final File file3 = new File(dirPath, "org.motechproject.motech-module2/raw/somemodule.json"); final List<File> expectedFiles = Arrays.asList(file1, file2, file3); final ConfigLocation configLocation = new ConfigLocation(dirPath); when(coreConfigurationService.getConfigLocation()).thenReturn(configLocation); final List<File> actualFiles = configLoader.findExistingConfigs(); assertEquals(expectedFiles.size(), actualFiles.size()); assertTrue(actualFiles.containsAll(expectedFiles)); }
@Test public void shouldReturnFilesInConfigLocation() throws IOException { ConfigLocation configLocation = mock(ConfigLocation.class); File file = mock(File.class); List<File> files = Arrays.asList(file); when(configLocation.getExistingConfigFiles()).thenReturn(files); when(coreConfigurationService.getConfigLocation()).thenReturn(configLocation); List<File> existingConfigs = configLoader.findExistingConfigs(); assertSame(files, existingConfigs); }