@Test(expected = MotechConfigurationException.class) public void shouldThrowExceptionWhenInvalidConfigLocationIsGiven() throws MalformedURLException { ConfigLocation configLocation = new ConfigLocationStub(File.separatorChar + "location"); configLocation.toResource(); }
public Resource toResource() { if (configLocation.startsWith(File.separator) || new File(configLocation).isAbsolute()) { try { return getUrlResource(); } catch (MalformedURLException e) { throw new MotechConfigurationException(String.format("Invalid config location %s.", configLocation), e); } } else { return new ClassPathResource(configLocation); } }
ConfigLocation { public Resource toResource() { if (configLocation.startsWith(File.separator) || new File(configLocation).isAbsolute()) { try { return getUrlResource(); } catch (MalformedURLException e) { throw new MotechConfigurationException(String.format("Invalid config location %s.", configLocation), e); } } else { return new ClassPathResource(configLocation); } } }
ConfigLocation { public Resource toResource() { if (configLocation.startsWith(File.separator) || new File(configLocation).isAbsolute()) { try { return getUrlResource(); } catch (MalformedURLException e) { throw new MotechConfigurationException(String.format("Invalid config location %s.", configLocation), e); } } else { return new ClassPathResource(configLocation); } } ConfigLocation(String configLocation); }
ConfigLocation { public Resource toResource() { if (configLocation.startsWith(File.separator) || new File(configLocation).isAbsolute()) { try { return getUrlResource(); } catch (MalformedURLException e) { throw new MotechConfigurationException(String.format("Invalid config location %s.", configLocation), e); } } else { return new ClassPathResource(configLocation); } } ConfigLocation(String configLocation); Resource toResource(); String getLocation(); UrlResource getUrlResource(); File getFile(String fileName, FileAccessType accessType); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); List<File> getExistingConfigFiles(); boolean hasPlatformConfigurationFile(); }
ConfigLocation { public Resource toResource() { if (configLocation.startsWith(File.separator) || new File(configLocation).isAbsolute()) { try { return getUrlResource(); } catch (MalformedURLException e) { throw new MotechConfigurationException(String.format("Invalid config location %s.", configLocation), e); } } else { return new ClassPathResource(configLocation); } } ConfigLocation(String configLocation); Resource toResource(); String getLocation(); UrlResource getUrlResource(); File getFile(String fileName, FileAccessType accessType); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); List<File> getExistingConfigFiles(); boolean hasPlatformConfigurationFile();  }