VersionInfo { private VersionInfo(final VersionInfoProperties versionInfoProperties, final GitProperties gitProperties) { if (gitProperties != null) { this.commitId = gitProperties.getCommitId(); this.commitIdAbbrev = gitProperties.getShortCommitId(); this.branch = gitProperties.getBranch(); this.commitTime = gitProperties.get(COMMIT_TIME); this.userName = gitProperties.get(USER_NAME); this.userEmail = gitProperties.get(USER_EMAIL); this.messageShort = gitProperties.get(MESSAGE_SHORT); this.messageFull = gitProperties.get(MESSAGE_FULL); } else { this.commitId = versionInfoProperties.getCommitId(); this.commitIdAbbrev= versionInfoProperties.getCommitIdAbbrev(); this.commitTime = versionInfoProperties.getCommitTime(); this.userName = versionInfoProperties.getUserName(); this.userEmail = versionInfoProperties.getUserEmail(); this.messageShort = versionInfoProperties.getMessageShort(); this.messageFull = versionInfoProperties.getMessageFull(); this.branch = versionInfoProperties.getBranch(); } this.version = Objects.toString(versionInfoProperties.getVersion(), this.commitId); this.url = versionInfoProperties.getUrlTemplate().replace("{commit}", commitId).replace("{version}", version); } private  VersionInfo(final VersionInfoProperties versionInfoProperties, final GitProperties gitProperties); static VersionInfo versionInfo(final VersionInfoProperties versionInfoProperties); static VersionInfo versionInfo(final VersionInfoProperties versionInfoProperties,
                                          final GitProperties gitProperties); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); final String version; final String commitId; final String commitIdAbbrev; final String commitTime; final String userName; final String userEmail; final String messageShort; final String messageFull; final String branch; final String url; }
@Test public void shouldReplaceCommitHashInTemplate() { VersionInfo versionInfo = versionInfo(versionInfoProperties("42.0.1-RELEASE", "ab0816", "http: assertThat(versionInfo.url, is("http: }
@Test public void shouldReplaceVersionInTemplate() { VersionInfo versionInfo = versionInfo(versionInfoProperties("42.0.1-RELEASE", "ab0816", "http: assertThat(versionInfo.url, is("http: }
@Test public void shouldBuildVersionInfoFromGitProperties() { VersionInfo versionInfo = versionInfo( versionInfoProperties("42.0.1-RELEASE", "ignored", "http: gitProperties("abc4711")); assertThat(versionInfo.commitId, is("abc4711")); assertThat(versionInfo.version, is("42.0.1-RELEASE")); assertThat(versionInfo.url, is("http: }