Version { public String get() { InputStream resource = Version.class.getResourceAsStream(source); if (resource == null) { return UNKNOWN_VERSION; } try (BufferedReader reader = new BufferedReader(new InputStreamReader(resource, UTF_8))) { String version = reader.readLine(); return version != null ? version : UNKNOWN_VERSION; } catch (IOException e) { LOGGER.warn("Error while trying to read current maven-color version.", e); return UNKNOWN_VERSION; } } Version(String classpathResource); static Version current(); String get();  }
@Test public void should_read_version_from_existing_resource() { Version version = new Version("/version-test"); assertThat(version.get()).isEqualTo("1.0.0"); }
@Test public void should_return_unknown_version_when_resource_does_not_exist() { Version version = new Version("/does-not-exist"); assertThat(version.get()).isEqualTo("unknown-version"); }
@Test public void should_return_unknown_version_when_resource_is_empty() { Version version = new Version("/version-test-empty"); assertThat(version.get()).isEqualTo("unknown-version"); }