ResponsePagingUtils { public static int calculateNextStartIndex( int startIndex, int count, int hits ) { int nextStartIndex = startIndex + count; if ( nextStartIndex < hits ) { return nextStartIndex; } return -1; } private  ResponsePagingUtils(); static int calculateNextStartIndex( int startIndex, int count, int hits ); static int calculatePreviousStartIndex( int startIndex, int count );  }
@Test public void testCalculateNextStartIndex_NoFeaturesMatched() { int nextStartIndex = ResponsePagingUtils.calculateNextStartIndex( 0, 10, 0 ); assertThat( nextStartIndex, is( -1 ) ); }
@Test public void testCalculateNextStartIndex_SecondPage() { int nextStartIndex = ResponsePagingUtils.calculateNextStartIndex( 0, 10, 97 ); assertThat( nextStartIndex, is( 10 ) ); }
@Test public void testCalculateNextStartIndex_LastPage() { int nextStartIndex = ResponsePagingUtils.calculateNextStartIndex( 80, 10, 97 ); assertThat( nextStartIndex, is( 90 ) ); }
@Test public void testCalculateNextStartIndex_NextWithOneResult() { int nextStartIndex = ResponsePagingUtils.calculateNextStartIndex( 91, 5, 97 ); assertThat( nextStartIndex, is( 96 ) ); }
@Test public void testCalculateNextStartIndex_NextNotAvailable() { int nextStartIndex = ResponsePagingUtils.calculateNextStartIndex( 92, 5, 97 ); assertThat( nextStartIndex, is( -1 ) ); }