RangeHelper { public long getTotalLength(final List<Range> ranges) { int totalLength = 0; for (Range range : ranges) { totalLength += getRangeLength(range); } return totalLength; }  long getRangeLength(final Range range); boolean isRangeValid(final Range range); long getTotalLength(final List<Range> ranges); boolean isSatisfiable(final Iterable<Range> ranges, final long streamLength);  }
@Test public void shouldComputeTotalLength() { List<Range> ranges = new ArrayList<>(); ranges.add(new Range(0, 0)); ranges.add(new Range(0, 10)); assertThat(rangeHelper.getTotalLength(ranges), is(12L)); }
@Test public void shouldComputeTotalLengthForLargerValues() { List<Range> ranges = new ArrayList<>(); ranges.add(new Range(0, 550)); ranges.add(new Range(1024, 1623)); assertThat(rangeHelper.getTotalLength(ranges), is(1151L)); }
@Test public void shouldComputeTotalLengthX() { List<Range> ranges = new ArrayList<>(); ranges.add(new Range(0, 1)); ranges.add(new Range(2, 3)); assertThat(rangeHelper.getTotalLength(ranges), is(4L)); }