VersionParser { @VisibleForTesting Version parse(String version) { Preconditions.checkNotNull(version); return supportedVersions.stream() .filter(jmapVersion -> jmapVersion.asString().equalsIgnoreCase(version)) .findFirst() .orElseThrow(() -> new IllegalArgumentException(version + " is not a supported version")); } @Inject  VersionParser(Set<Version> supportedVersions);   }
@Test void parseShouldReturnCorrectValue() { String version = "rfc-8621"; assertThat(versionParser.parse(version)).isEqualTo(Version.RFC8621); }
@Test void parseShouldThrowWhenVersionNotKnown() { String version = "unknown"; assertThatThrownBy(() -> versionParser.parse(version)) .isInstanceOf(IllegalArgumentException.class); }
@Test void parseShouldThrowWhenVersionIsNull() { assertThatThrownBy(() -> versionParser.parse(null)) .isInstanceOf(NullPointerException.class); }
@Test void parseShouldThrowWhenVersionIsEmpty() { String version = ""; assertThatThrownBy(() -> versionParser.parse(version)) .isInstanceOf(IllegalArgumentException.class); }