### Question:
TagVersionFinder { public Version findLatestTaggedVersion(List<Tag> tags) { Version latestVersion = Unidentified_Version; for (Tag tag : tags) { String versionString = tag.name.replace("v", ""); if (Version.isParseable(versionString)) { Version version = new Version(versionString); if (version.isLargerThan(latestVersion)) { latestVersion = version; } } } return latestVersion; }  Version findLatestTaggedVersion(List<Tag> tags); static final Version Unidentified_Version; }### Answer:
@Test public void returnsVersionFromTag() throws Exception { TagVersionFinder finder = new TagVersionFinder(); Tag tag = createTag("v4.1.0"); List<Tag> tags = newArrayList(tag); Version version = finder.findLatestTaggedVersion(tags); assertThat(version.compareTo(new Version(4, 1, 0)), is(0)); }
@Test public void returnsLatestVersionFromTag() throws Exception { TagVersionFinder finder = new TagVersionFinder(); Tag tag410 = createTag("v4.1.0"); Tag tag411 = createTag("v4.1.1"); List<Tag> tags = newArrayList(tag410, tag411); Version version = finder.findLatestTaggedVersion(tags); assertThat(version.compareTo(new Version(4, 1, 1)), is(0)); }
@Test public void ignoresNonVersionTags() throws Exception { TagVersionFinder finder = new TagVersionFinder(); Tag tag410 = createTag("v4.1.0"); Tag tag411 = createTag("v4.1.1"); Tag tagIllegible = createTag("vwvvv"); List<Tag> tags = newArrayList(tag410, tag411, tagIllegible); Version version = finder.findLatestTaggedVersion(tags); assertThat(version.compareTo(new Version(4, 1, 1)), is(0)); }