コード例 #1
0
 /** goal 0-100 (impose finish at 100) */
 @Test
 public void testGetEnd() {
   int offset = 0;
   int limit = 5;
   Long finish = 100l;
   long total = 213;
   Sharding d = new Sharding();
   d.setLimit(offset, limit, finish);
   d.setCounts(total);
   long end = d.getEnd();
   assertEquals(finish.longValue(), end);
 }
コード例 #2
0
 /** goal query 0-55 (no finish) */
 @Test
 public void testGetEnd4() {
   int offset = 0;
   int limit = 10;
   Long finish = null;
   long total = 55;
   Sharding d = new Sharding();
   d.setLimit(offset, limit, finish);
   d.setCounts(total);
   long end = d.getEnd();
   assertEquals(55, end);
 }
コード例 #3
0
 /** goal 0-23 (no finish), means that should be 23 shards */
 @Test
 public void testGetPages3() {
   int offset = 0;
   int limit = 5;
   Long finish = null;
   long total = 23;
   Sharding d = new Sharding();
   d.setLimit(offset, limit, finish);
   d.setCounts(total);
   long end = d.getEnd();
   int shards = d.getShards();
   assertEquals(total, end);
   assertEquals(5, shards); // 23.6 is 5 shards
 }