### Question:
VersionExtractor { public static String extractVersion(final String payload) { if (payload == null || "".equals(payload)) { return String.valueOf(System.currentTimeMillis()); } final Matcher matcher = VERSION_PATTERN.matcher(payload); if (matcher.find()) { return matcher.group(1); } throw new RuntimeException("Could not find a version in payload [" + payload + "]"); } private  VersionExtractor(); static String extractVersion(final String payload);  }### Answer:
@Test public void extractVersion() { assertThat(VersionExtractor.extractVersion("version=1"), equalTo("1")); assertThat(VersionExtractor.extractVersion("version= 2"), equalTo("2")); assertThat(VersionExtractor.extractVersion("version =3"), equalTo("3")); assertThat(VersionExtractor.extractVersion(" version=10"), equalTo("10")); assertThat(VersionExtractor.extractVersion(" version= 11"), equalTo("11")); assertThat(VersionExtractor.extractVersion(" version = 12 "), equalTo("12")); }
@Test public void noVersion() { assertThat(VersionExtractor.extractVersion(""), is(notNullValue())); assertThat(VersionExtractor.extractVersion(null), is(notNullValue())); }
@Test (expected = RuntimeException.class) public void invalidVersionPropertyName() { VersionExtractor.extractVersion("vorsion=12"); }
@Test (expected = RuntimeException.class) public void invalidVersion() { VersionExtractor.extractVersion("version="); }