### Question:
HttpRangeHeaderParamConverter implements ParamConverter<RangeHeader> { @Override public RangeHeader fromString(String value) { if (value == null || value.isEmpty()) { return null; } final Matcher matcher = RANGE_REGEX.matcher(value); if (matcher.matches()) { final RangeHeader rangeHeader = new RangeHeader(); rangeHeader.setUnit(matcher.group(1)); rangeHeader.setStart(Long.parseLong(matcher.group(2))); if (matcher.group(3) != null) { rangeHeader.setEnd(Long.parseLong(matcher.group(3))); } return rangeHeader; } throw new WebApplicationException(String.format(RANGE_MSG_FORMATTER, value), Response.Status.BAD_REQUEST); } HttpRangeHeaderParamConverter(); @Override RangeHeader fromString(String value); @Override String toString(RangeHeader value);  }### Answer:
@Test void testEmptyRequest() { assertNull(converter.fromString(""), "Should not have range request"); assertNull(converter.fromString(null), "Should not have range request"); }
@Test void testCompletelyBogus() { final String bogusRequest = "this is not real, not at all."; final WebApplicationException exception = assertThrows(WebApplicationException.class, () -> converter.fromString(bogusRequest)); assertAll(() -> assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), exception.getResponse().getStatus(), "Should be a bad request"), () -> assertEquals(String.format(RANGE_MSG_FORMATTER, bogusRequest), exception.getMessage(), "Should have correct error message")); }
@Test void testOnlyStart() { final String bogusRequest = "bytes=0"; assertThrows(WebApplicationException.class, () -> converter.fromString(bogusRequest)); final WebApplicationException exception = assertThrows(WebApplicationException.class, () -> converter.fromString(bogusRequest)); assertAll(() -> assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), exception.getResponse().getStatus(), "Should be a bad request"), () -> assertEquals(String.format(RANGE_MSG_FORMATTER, bogusRequest), exception.getMessage(), "Should have correct error message")); }
@Test void testSpacing() { final String bogusRequest = "bytes = 0"; final WebApplicationException exception = assertThrows(WebApplicationException.class, () -> converter.fromString(bogusRequest)); assertAll(() -> assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), exception.getResponse().getStatus(), "Should be a bad request"), () -> assertEquals(String.format(RANGE_MSG_FORMATTER, bogusRequest), exception.getMessage(), "Should have correct error message")); }