### Question:
CompositeSequenceableLoader implements SequenceableLoader { @Override public final long getBufferedPositionUs() { long bufferedPositionUs = Long.MAX_VALUE; for (SequenceableLoader loader : loaders) { long loaderBufferedPositionUs = loader.getBufferedPositionUs(); if (loaderBufferedPositionUs != C.TIME_END_OF_SOURCE) { bufferedPositionUs = Math.min(bufferedPositionUs, loaderBufferedPositionUs); } } return bufferedPositionUs == Long.MAX_VALUE ? C.TIME_END_OF_SOURCE : bufferedPositionUs; } CompositeSequenceableLoader(SequenceableLoader[] loaders); @Override final long getBufferedPositionUs(); @Override final long getNextLoadPositionUs(); @Override final void reevaluateBuffer(long positionUs); @Override boolean continueLoading(long positionUs);  }### Answer:
@Test public void testGetBufferedPositionUsReturnsMinimumLoaderBufferedPosition() { FakeSequenceableLoader loader1 = new FakeSequenceableLoader( 1000, 2000); FakeSequenceableLoader loader2 = new FakeSequenceableLoader( 1001, 2001); CompositeSequenceableLoader compositeSequenceableLoader = new CompositeSequenceableLoader( new SequenceableLoader[] {loader1, loader2}); assertThat(compositeSequenceableLoader.getBufferedPositionUs()).isEqualTo(1000); }
@Test public void testGetBufferedPositionUsReturnsMinimumNonEndOfSourceLoaderBufferedPosition() { FakeSequenceableLoader loader1 = new FakeSequenceableLoader( 1000, 2000); FakeSequenceableLoader loader2 = new FakeSequenceableLoader( 1001, 2000); FakeSequenceableLoader loader3 = new FakeSequenceableLoader( C.TIME_END_OF_SOURCE, C.TIME_END_OF_SOURCE); CompositeSequenceableLoader compositeSequenceableLoader = new CompositeSequenceableLoader( new SequenceableLoader[] {loader1, loader2, loader3}); assertThat(compositeSequenceableLoader.getBufferedPositionUs()).isEqualTo(1000); }
@Test public void testGetBufferedPositionUsReturnsEndOfSourceWhenAllLoaderBufferedTillEndOfSource() { FakeSequenceableLoader loader1 = new FakeSequenceableLoader( C.TIME_END_OF_SOURCE, C.TIME_END_OF_SOURCE); FakeSequenceableLoader loader2 = new FakeSequenceableLoader( C.TIME_END_OF_SOURCE, C.TIME_END_OF_SOURCE); CompositeSequenceableLoader compositeSequenceableLoader = new CompositeSequenceableLoader( new SequenceableLoader[] {loader1, loader2}); assertThat(compositeSequenceableLoader.getBufferedPositionUs()).isEqualTo(C.TIME_END_OF_SOURCE); }