private void testByteRangeCreationOffsetRange(long startOffset, long endOffset, boolean expectSuccess)
      throws Exception {
    List<BiFunction<Long, Long, ByteRange>> factories =
        Arrays.asList(ByteRange::fromOffsetRange, ByteRanges::fromOffsetRange);
    for (BiFunction<Long, Long, ByteRange> factory : factories) {
      if (expectSuccess) {
        ByteRange byteRange = factory.apply(startOffset, endOffset);
        assertEquals("Wrong range type", ByteRange.ByteRangeType.OFFSET_RANGE, byteRange.getType());
        assertEquals("Wrong startOffset", startOffset, byteRange.getStartOffset());
        assertEquals("Wrong endOffset", endOffset, byteRange.getEndOffset());
        assertEquals("Wrong range size", endOffset - startOffset + 1, byteRange.getRangeSize());
        TestUtils.assertException(UnsupportedOperationException.class, byteRange::getLastNBytes, null);
      } else {
        TestUtils.assertException(IllegalArgumentException.class, () -> factory.apply(startOffset, endOffset), null);
      }
    }
  }
Test that {@link ByteRange} works as expected for byte ranges with a defined start and end offset.
@param startOffset the (inclusive) start byte offset to test.
@param endOffset the (inclusive) end byte offset to test.
@param expectSuccess {@code true} if the {@link ByteRange} creation should succeed.
@throws Exception
ambry-api/src/test/java/com/github/ambry/router/ByteRangeTest.java