private void doBuildContentRangeAndLengthTest(ByteRange range, long blobSize, String expectedContentRange,
      long expectedContentLength, boolean shouldSucceed) throws RestServiceException {
    if (shouldSucceed) {
      Pair<String, Long> rangeAndLength = RestUtils.buildContentRangeAndLength(range, blobSize, false);
      assertEquals(expectedContentRange, rangeAndLength.getFirst());
      assertEquals(expectedContentLength, (long) rangeAndLength.getSecond());
    } else {
      try {
        RestUtils.buildContentRangeAndLength(range, blobSize, false);
        fail("Should have encountered exception when building Content-Range");
      } catch (RestServiceException e) {
        assertEquals("Unexpected error code.", RestServiceErrorCode.RangeNotSatisfiable, e.getErrorCode());
      }
    }
  }
Test {@link RestUtils#buildContentRangeAndLength(ByteRange, long, boolean)} for a specific {@link ByteRange} and total blob
size.
@param range the {@link ByteRange} to test for.
@param blobSize the total blob size in bytes to test for.
@param expectedContentRange the expected Content-Range header string.
@param expectedContentLength the expected Content-Length in bytes.
@param shouldSucceed {@code true} if the call should succeed, {@code false} if an error is expected.
@throws RestServiceException
ambry-api/src/test/java/com/github/ambry/rest/RestUtilsTest.java