DocumentRepositoryImpl extends AbstractCRUDRepository<Document> implements DocumentRepository { @Override public QueryResponseWrapper readAll(String database, String tableString, int limit, long offset) { Table table = new Table(); table.setDatabaseByString(database); table.setName(tableString); long maxIndex = offset + limit; PreparedStatement readStmt = PreparedStatementFactory.getPreparedStatement(String.format(READ_ALL_CQL, table.toDbTable(), maxIndex + 1), getSession()); BoundStatement bs = new BoundStatement(readStmt); ResultSet results = getSession().execute(bs); return DocumentPersistanceUtils.parseResultSetWithLimitAndOffset(results, limit, offset); } DocumentRepositoryImpl(Session session); @Override Document create(Document entity); @Override Document read(Identifier identifier); @Override QueryResponseWrapper readAll(String database, String tableString, int limit, long offset); @Override Document update(Document entity); @Override void delete(Document entity); @Override void delete(Identifier id); @Override boolean exists(Identifier identifier);  }
@Test public void testDoReadAll() throws IOException, ParseException { System.out.println("doReadAll"); f.insertDocuments(Fixtures.getBulkDocuments()); DocumentRepository instance = new DocumentRepositoryImpl(f.getSession()); List<Document> result = instance.readAll(testDb.getName(), testTable.getName(), 10, 0); assertTrue(result.size() == 10); assertNotNull(result.get(0).getId()); assertNotNull(result.get(0).getUuid()); assertNotNull(result.get(0).getUpdatedAt()); result = instance.readAll(testDb.getName(), testTable.getName(), 10, 10); assertTrue(result.size() == 10); assertNotNull(result.get(0).getId()); assertNotNull(result.get(0).getUuid()); assertNotNull(result.get(0).getUpdatedAt()); result = instance.readAll(testDb.getName(), testTable.getName(), 100, 20); assertTrue(result.size() == 14); }
@Test public void testDoReadAll2() throws IOException, ParseException { System.out.println("doReadAll2"); f.insertDocuments(Fixtures.getBulkDocuments()); DocumentRepository instance = new DocumentRepositoryImpl(f.getSession()); QueryResponseWrapper result = instance.readAll(testDb.getName(), testTable.getName(), 5, 0); assertNotNull(result); assertTrue(!result.isEmpty()); assertTrue(result.size() == 5); assertTrue(result.getNumAdditionalResults() == null); result = instance.readAll(testDb.getName(), testTable.getName(), 5, 5); assertNotNull(result); assertTrue(!result.isEmpty()); assertTrue(result.size() == 5); assertTrue(result.getNumAdditionalResults() == null); result = instance.readAll(testDb.getName(), testTable.getName(), 5, 10); assertNotNull(result); assertTrue(!result.isEmpty()); assertTrue(result.size() == 5); assertTrue(result.getNumAdditionalResults() == null); result = instance.readAll(testDb.getName(), testTable.getName(), 5, 30); assertNotNull(result); assertTrue(!result.isEmpty()); assertTrue(result.size() == 4); assertTrue(result.getNumAdditionalResults() == 0); }