@Test public void shouldGoPageWiseBackwardsOnSingleBatch() { // GIVEN RecordIdIterator ids = RecordIdIterator.backwards( 0, 8, withBatchSize( DEFAULT, 10 ) ); // THEN assertIds( ids, array( 0, 1, 2, 3, 4, 5, 6, 7 ) ); }
@Test public void shouldGoPageWiseBackwardsOnCleanBreak() { // GIVEN RecordIdIterator ids = RecordIdIterator.backwards( 0, 20, withBatchSize( DEFAULT, 10 ) ); // THEN assertIds( ids, array( 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 ), array( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ) ); }
@Test public void shouldGoForwardsWhenStartingFromNonZero() { // GIVEN RecordIdIterator ids = RecordIdIterator.forwards( 1, 12, withBatchSize( DEFAULT, 10 ) ); // THEN assertIds( ids, array( 1, 2, 3, 4, 5, 6, 7, 8, 9 ), array( 10, 11 ) ); }
@Test public void shouldGoBackwardsToNonZero() { // GIVEN RecordIdIterator ids = RecordIdIterator.backwards( 12, 34, withBatchSize( DEFAULT, 10 ) ); // THEN assertIds( ids, array( 30, 31, 32, 33 ), array( 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 ), array( 12, 13, 14, 15, 16, 17, 18, 19 ) ); }
@Test public void shouldGoForwardsWhenStartingFromNonZero2() { // GIVEN RecordIdIterator ids = RecordIdIterator.forwards( 34, 66, withBatchSize( DEFAULT, 10 ) ); // THEN assertIds( ids, array( 34, 35, 36, 37, 38, 39 ), array( 40, 41, 42, 43, 44, 45, 46, 47, 48, 49 ), array( 50, 51, 52, 53, 54, 55, 56, 57, 58, 59 ), array( 60, 61, 62, 63, 64, 65 ) ); }
@Test public void shouldGoPageWiseBackwards() { // GIVEN RecordIdIterator ids = RecordIdIterator.backwards( 0, 33, withBatchSize( DEFAULT, 10 ) ); // THEN assertIds( ids, array( 30, 31, 32 ), array( 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 ), array( 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 ), array( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ) ); }