@Test public void testWithInvalidBuildCommit() { Manifest manifest = mock(Manifest.class); Attributes attributes = mock(Attributes.class); when(manifest.getMainAttributes()).thenReturn(attributes); when(attributes.getValue("Implementation-Version")).thenReturn("0.1.2-SNAPSHOT"); when(attributes.getValue("Build-Commit")).thenReturn("tooshort"); when(attributes.getValue("Build-Time")).thenReturn("xyz"); String version = Version.getVersion(manifest); assertThat(version).isEqualTo("0.1.2-SNAPSHOT, built xyz"); }
public static String getVersion(Class<?> baseClass) { Manifest manifest; try { manifest = getManifest(baseClass); } catch (IOException e) { logger.error(e.getMessage(), e); return UNKNOWN_VERSION; } return getVersion(manifest); }
Version { public static String getVersion(Class<?> baseClass) { Manifest manifest; try { manifest = getManifest(baseClass); } catch (IOException e) { logger.error(e.getMessage(), e); return UNKNOWN_VERSION; } return getVersion(manifest); } }
Version { public static String getVersion(Class<?> baseClass) { Manifest manifest; try { manifest = getManifest(baseClass); } catch (IOException e) { logger.error(e.getMessage(), e); return UNKNOWN_VERSION; } return getVersion(manifest); } private  Version(); }
Version { public static String getVersion(Class<?> baseClass) { Manifest manifest; try { manifest = getManifest(baseClass); } catch (IOException e) { logger.error(e.getMessage(), e); return UNKNOWN_VERSION; } return getVersion(manifest); } private  Version(); static String getVersion(Class<?> baseClass); }
Version { public static String getVersion(Class<?> baseClass) { Manifest manifest; try { manifest = getManifest(baseClass); } catch (IOException e) { logger.error(e.getMessage(), e); return UNKNOWN_VERSION; } return getVersion(manifest); } private  Version(); static String getVersion(Class<?> baseClass); static final String UNKNOWN_VERSION; }