VersionInfo { public static String findVersionInfo() { return findVersionInfo(artifactId, true).orElse("Current Version"); }  static String findVersionInfo(); static Optional<String> findVersionInfo(final String applicationName, final boolean includeBuildTime); static final String artifactId; }
@Test void shouldFindTheDefaultVersionInfo() throws IOException { final List<String> lines = Arrays.asList("Implementation-Title: gazeplay", "Implementation-Version: 1.7", "Build-Time: 1234"); createMockManifest(lines); final String result = VersionInfo.findVersionInfo(); assertEquals("1.7 (1234)", result); }
@Test void shouldReturnCurrentVersion() throws IOException { final List<String> lines = Arrays.asList("Implementation-Title: wrong-game", "Implementation-Version: 1.7", "Build-Time: 1234"); createMockManifest(lines); final String result = VersionInfo.findVersionInfo(); assertEquals("Current Version", result); }
@Test void shouldFindVersionWithoutBuildTime() throws IOException { final List<String> lines = Arrays.asList("Implementation-Title: gazeplay", "Implementation-Version: 1.7"); createMockManifest(lines); final String result = VersionInfo.findVersionInfo("gazeplay", false).get(); assertEquals("1.7", result); }
@Test void shouldReturnEmptyWithIncorrectManifest() throws IOException { final List<String> lines = Arrays.asList("Implementation-Title: wrong-game", "Implementation-Version: 1.7"); createMockManifest(lines); final Optional<String> result = VersionInfo.findVersionInfo("gazeplay", false); assertTrue(result.isEmpty()); }