@Test public void versionExtractionFromProperties() { String extractedVersion = Version.getPropertiesVersion(PROPERTIES_PATH, "batfish_version"); String extractedVersionBadKey = Version.getPropertiesVersion(PROPERTIES_PATH, "bogus"); String extractedVersionBadPath = Version.getPropertiesVersion("org.bogus", "batfish_version"); assertThat(extractedVersion, not(containsString("project.version"))); assertThat(extractedVersion, not(containsString(UNKNOWN_VERSION))); assertThat(extractedVersionBadPath, equalTo(UNKNOWN_VERSION)); assertThat(extractedVersionBadKey, equalTo(UNKNOWN_VERSION)); }
public static String getPropertiesVersion(String propertiesPath, String key) { try { Configuration config = new Configurations().properties(propertiesPath); String version = config.getString(key); if (version.contains("project.version")) { return UNKNOWN_VERSION; } return version; } catch (Exception e) { return UNKNOWN_VERSION; } }
Version { public static String getPropertiesVersion(String propertiesPath, String key) { try { Configuration config = new Configurations().properties(propertiesPath); String version = config.getString(key); if (version.contains("project.version")) { return UNKNOWN_VERSION; } return version; } catch (Exception e) { return UNKNOWN_VERSION; } } }
Version { public static String getPropertiesVersion(String propertiesPath, String key) { try { Configuration config = new Configurations().properties(propertiesPath); String version = config.getString(key); if (version.contains("project.version")) { return UNKNOWN_VERSION; } return version; } catch (Exception e) { return UNKNOWN_VERSION; } } private  Version(); }
Version { public static String getPropertiesVersion(String propertiesPath, String key) { try { Configuration config = new Configurations().properties(propertiesPath); String version = config.getString(key); if (version.contains("project.version")) { return UNKNOWN_VERSION; } return version; } catch (Exception e) { return UNKNOWN_VERSION; } } private  Version(); static String getPropertiesVersion(String propertiesPath, String key); }
Version { public static String getPropertiesVersion(String propertiesPath, String key) { try { Configuration config = new Configurations().properties(propertiesPath); String version = config.getString(key); if (version.contains("project.version")) { return UNKNOWN_VERSION; } return version; } catch (Exception e) { return UNKNOWN_VERSION; } } private  Version(); static String getPropertiesVersion(String propertiesPath, String key); static final String UNKNOWN_VERSION; }