### Question:
ReusableRecordsCompositeAllocator implements DynamicRecordAllocator { @Override public DynamicRecord nextRecord() { return reusableRecordsAllocator.hasNext() ? reusableRecordsAllocator.nextRecord() : recordAllocator.nextRecord(); } ReusableRecordsCompositeAllocator( Collection<DynamicRecord> records,
            DynamicRecordAllocator recordAllocator );  ReusableRecordsCompositeAllocator( Iterator<DynamicRecord> recordsIterator,
            DynamicRecordAllocator recordAllocator ); @Override int getRecordDataSize(); @Override DynamicRecord nextRecord();  }### Answer:
@Test public void allocateReusableRecordsAndSwitchToDefaultWhenExhausted() { DynamicRecord dynamicRecord1 = new DynamicRecord( 1 ); DynamicRecord dynamicRecord2 = new DynamicRecord( 2 ); DynamicRecordAllocator recordAllocator = mock( DynamicRecordAllocator.class ); Mockito.when( recordAllocator.nextRecord() ).thenReturn( dynamicRecord2 ); ReusableRecordsCompositeAllocator compositeAllocator = new ReusableRecordsCompositeAllocator( singletonList( dynamicRecord1 ), recordAllocator ); assertSame( "Same as pre allocated record.", dynamicRecord1, compositeAllocator.nextRecord() ); assertSame( "Same as expected allocated record.", dynamicRecord2, compositeAllocator.nextRecord() ); }