ConfigurationLocator { @SuppressWarnings({"PMD.OnlyOneReturn"}) public String getConfigurationDirectory() { for (String directoryPath : getDirectoriesToSearch()) { if (directoryExists(directoryPath)) { LOGGER.info("ConfigurationLocator found configuration directory: " + directoryPath); return directoryPath; } } return forceConfDirectoryCreation(); } ConfigurationLocator(); @SuppressWarnings("PMD") // TODO It may be clearer if this returned an URI or URL instead of a String? String getCustomFilePath(String filename); String getFilePath(String filename); @SuppressWarnings({"PMD.OnlyOneReturn"}) String getConfigurationDirectory(); Resource getResource(String configurationName); Resource getUploadedMifosLogo(); void setConfigurationLocatorHelper(ConfigurationLocatorHelper fileFactory); void setDefaultConfigPath(String path); String resolvePath(String fileName); String getLogoDirectory(); String getLogoName(); static final String LOCATOR_ENVIRONMENT_PROPERTY_NAME; }
@Test public void testGetConfigurationDirectory() { when(file.exists()).thenReturn(true); when(configurationLocatorHelper.getFile(EXPECTED_PATH)).thenReturn(file); when(configurationLocatorHelper.getHomeProperty("user.home")).thenReturn("/Users/caitie"); String configurationDirectory = configurationLocator.getConfigurationDirectory(); Assert.assertNotNull(configurationDirectory); Assert.assertEquals(EXPECTED_PATH, configurationDirectory); }