### Question:
SecondaryUnitPrepareIdSequence implements PrepareIdSequence { @Override public LongFunction<IdSequence> apply( IdSequence idSequence ) { return new NeighbourIdSequence(); }  @Override LongFunction<IdSequence> apply( IdSequence idSequence );  }### Answer:
@Test public void shouldReturnIdImmediatelyAfterRecordId() { PrepareIdSequence idSequence = new SecondaryUnitPrepareIdSequence(); IdSequence actual = mock( IdSequence.class ); long recordId = 10; IdSequence prepared = idSequence.apply( actual ).apply( recordId ); long nextRecordId = prepared.nextId(); assertEquals( 10 + 1, nextRecordId ); verifyNoMoreInteractions( actual ); }
@Test public void shouldReturnIdImmediatelyAfterRecordIdOnlyOnce() { PrepareIdSequence idSequence = new SecondaryUnitPrepareIdSequence(); IdSequence actual = mock( IdSequence.class ); long recordId = 10; IdSequence prepared = idSequence.apply( actual ).apply( recordId ); long nextRecordId = prepared.nextId(); assertEquals( 10 + 1, nextRecordId ); verifyNoMoreInteractions( actual ); try { prepared.nextId(); fail( "Should've failed" ); } catch ( IllegalStateException e ) { } recordId = 20; prepared = idSequence.apply( actual ).apply( recordId ); nextRecordId = prepared.nextId(); assertEquals( 20 + 1, nextRecordId ); verifyNoMoreInteractions( actual ); }