### Question:
ReusableRecordsAllocator implements DynamicRecordAllocator { @Override public DynamicRecord nextRecord() { DynamicRecord record = recordIterator.next(); if ( !record.inUse() ) { record.setCreated(); } record.setInUse( true ); return record; } ReusableRecordsAllocator( int recordSize, DynamicRecord... records );  ReusableRecordsAllocator( int recordSize, Collection<DynamicRecord> records );  ReusableRecordsAllocator( int recordSize, Iterator<DynamicRecord> recordsIterator ); @Override int getRecordDataSize(); @Override DynamicRecord nextRecord(); boolean hasNext();  }### Answer:
@Test public void allocatePreviouslyNotUsedRecord() { DynamicRecord dynamicRecord = new DynamicRecord( 1 ); dynamicRecord.setInUse( false ); ReusableRecordsAllocator recordsAllocator = new ReusableRecordsAllocator( 10, dynamicRecord ); DynamicRecord allocatedRecord = recordsAllocator.nextRecord(); assertSame( "Records should be the same.", allocatedRecord, dynamicRecord ); assertTrue( "Record should be marked as used.", allocatedRecord.inUse() ); assertTrue( "Record should be marked as created.", allocatedRecord.isCreated() ); }
@Test public void allocatePreviouslyUsedRecord() { DynamicRecord dynamicRecord = new DynamicRecord( 1 ); dynamicRecord.setInUse( true ); ReusableRecordsAllocator recordsAllocator = new ReusableRecordsAllocator( 10, dynamicRecord ); DynamicRecord allocatedRecord = recordsAllocator.nextRecord(); assertSame( "Records should be the same.", allocatedRecord, dynamicRecord ); assertTrue( "Record should be marked as used.", allocatedRecord.inUse() ); assertFalse( "Record should be marked as created.", allocatedRecord.isCreated() ); }