@Test
public void testPagingAndLimits() {
SelectorBuilder builder = new SelectorBuilder();
builder = builder.offset(10);
Selector selector = builder.build();
Assert.assertNotNull(selector.getPaging());
Assert.assertNotNull(selector.getPaging().getStartIndex());
Assert.assertNull(selector.getPaging().getNumberResults());
Assert.assertEquals(selector.getPaging().getStartIndex().intValue(), 10);
selector = builder.offset(10).limit(20).build();
Assert.assertNotNull(selector.getPaging());
Assert.assertNotNull(selector.getPaging().getStartIndex());
Assert.assertNotNull(selector.getPaging().getNumberResults());
Assert.assertEquals(selector.getPaging().getStartIndex().intValue(), 10);
Assert.assertEquals(selector.getPaging().getNumberResults().intValue(), 20);
selector = builder.offset(10).limit(20).increaseOffsetBy(5).build();
Assert.assertNotNull(selector.getPaging());
Assert.assertNotNull(selector.getPaging().getStartIndex());
Assert.assertNotNull(selector.getPaging().getNumberResults());
Assert.assertEquals(selector.getPaging().getStartIndex().intValue(), 15);
Assert.assertEquals(selector.getPaging().getNumberResults().intValue(), 20);
selector = builder.offset(10).limit(20).removeLimitAndOffset().build();
Assert.assertNull(selector.getPaging());
selector = builder.offset(10).limit(20).removeLimitAndOffset().offset(55).limit(4).build();
Assert.assertNotNull(selector.getPaging());
Assert.assertNotNull(selector.getPaging().getStartIndex());
Assert.assertNotNull(selector.getPaging().getNumberResults());
Assert.assertEquals(selector.getPaging().getStartIndex().intValue(), 55);
Assert.assertEquals(selector.getPaging().getNumberResults().intValue(), 4);
}