@Test(expected = InvalidVersionException.class) public void testEmptyVersionQuery() throws Exception { String testVersionName = ""; Version returnedVersion = versionUtil.getVersion(testVersionName); fail("expected exception (InvalidVersionException) did not get thrown"); }
public Version getVersion(String version) throws InvalidVersionException { if (version != null && version.trim() != "") { for (Version v : getVersions()) { if (v.getVersion().equals(version)) { return v; } } } else { throw new InvalidVersionException("'' is not a valid version."); } throw new InvalidVersionException("'" + version + "' is not a valid version."); }
VersionUtil { public Version getVersion(String version) throws InvalidVersionException { if (version != null && version.trim() != "") { for (Version v : getVersions()) { if (v.getVersion().equals(version)) { return v; } } } else { throw new InvalidVersionException("'' is not a valid version."); } throw new InvalidVersionException("'" + version + "' is not a valid version."); } }
VersionUtil { public Version getVersion(String version) throws InvalidVersionException { if (version != null && version.trim() != "") { for (Version v : getVersions()) { if (v.getVersion().equals(version)) { return v; } } } else { throw new InvalidVersionException("'' is not a valid version."); } throw new InvalidVersionException("'" + version + "' is not a valid version."); }  }
VersionUtil { public Version getVersion(String version) throws InvalidVersionException { if (version != null && version.trim() != "") { for (Version v : getVersions()) { if (v.getVersion().equals(version)) { return v; } } } else { throw new InvalidVersionException("'' is not a valid version."); } throw new InvalidVersionException("'" + version + "' is not a valid version."); }  List<Version> getVersions(); Version getVersion(String version); Version getDefaultVersion(); }
VersionUtil { public Version getVersion(String version) throws InvalidVersionException { if (version != null && version.trim() != "") { for (Version v : getVersions()) { if (v.getVersion().equals(version)) { return v; } } } else { throw new InvalidVersionException("'' is not a valid version."); } throw new InvalidVersionException("'" + version + "' is not a valid version."); }  List<Version> getVersions(); Version getVersion(String version); Version getDefaultVersion(); static final String DEFAULT_VERSION; }