@Test public void testHasNextWithStartOffset() throws Exception { MockSQLServerPagedDatabaseCollectionReader cr = (MockSQLServerPagedDatabaseCollectionReader) new MockSQLServerPagedDatabaseCollectionReader("com.mock", "url", "username", "password", "select id, note from doc order by id", "id", "note", 3, 2).produceCollectionReader(); DataManager dm = mock(DataManager.class); LeoArrayListHandler handler = mock(LeoArrayListHandler.class); List<Object[]> mockResults = new ArrayList<Object[]>(); mockResults.add(new Object[] { new Integer(1), "abc", new Integer(1), }); mockResults.add(new Object[] { new Integer(2), "def", new Integer(2), }); mockResults.add(new Object[] { new Integer(3), "ghi", new Integer(3), }); when(dm.query("select id, note from doc order by id\n" + "\t\tOFFSET 2 ROWS\n" + "\t\tFETCH NEXT 3 ROWS ONLY;")).thenReturn(mockResults); when(dm.query("select id, note from doc order by id\n" + "\t\tOFFSET 5 ROWS\n" + "\t\tFETCH NEXT 3 ROWS ONLY;")).thenReturn(mockResults); when(dm.query("select id, note from doc order by id\n" + "\t\tOFFSET 8 ROWS\n" + "\t\tFETCH NEXT 3 ROWS ONLY;")).thenReturn(new ArrayList<Object[]>()); when(handler.getColumnIndex("id")).thenReturn(0); when(handler.getColumnIndex("note")).thenReturn(1); when(dm.getHandler()).thenReturn(handler); AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(SampleService .simpleServiceDefinition() .getAnalysisEngineDescription()); CAS mockCas = ae.newCAS(); cr.setDataManager(dm); boolean hasNext = cr.hasNext(); assert(hasNext); cr.getNext(ae.newCAS()); hasNext = cr.hasNext(); assert(hasNext); cr.getNext(ae.newCAS()); hasNext = cr.hasNext(); assert(hasNext); cr.getNext(ae.newCAS()); hasNext = cr.hasNext(); assert(hasNext); cr.getNext(ae.newCAS()); hasNext = cr.hasNext(); assert(hasNext); cr.getNext(ae.newCAS()); hasNext = cr.hasNext(); assert(hasNext); cr.getNext(ae.newCAS()); hasNext = cr.hasNext(); assert(!hasNext); }
@Override public boolean hasNext() throws CollectionException { if(mRowIndex < 0 || mRecordList == null || mRowIndex == mRecordList.size()) { this.query = sqlServerPagedQuery.getPageQuery(currentBatch); if (this.query == null) { return false; } currentBatch++; mRowIndex = -1; } return super.hasNext(); }
SQLServerPagedDatabaseCollectionReader extends DatabaseCollectionReader { @Override public boolean hasNext() throws CollectionException { if(mRowIndex < 0 || mRecordList == null || mRowIndex == mRecordList.size()) { this.query = sqlServerPagedQuery.getPageQuery(currentBatch); if (this.query == null) { return false; } currentBatch++; mRowIndex = -1; } return super.hasNext(); } }
SQLServerPagedDatabaseCollectionReader extends DatabaseCollectionReader { @Override public boolean hasNext() throws CollectionException { if(mRowIndex < 0 || mRecordList == null || mRowIndex == mRecordList.size()) { this.query = sqlServerPagedQuery.getPageQuery(currentBatch); if (this.query == null) { return false; } currentBatch++; mRowIndex = -1; } return super.hasNext(); } SQLServerPagedDatabaseCollectionReader();  SQLServerPagedDatabaseCollectionReader(DatabaseConnectionInformation databaseConnectionInformation,
                                                  DataQueryInformation dataQueryInformation,
                                                  int pageSize);  SQLServerPagedDatabaseCollectionReader(DatabaseConnectionInformation databaseConnectionInformation,
                                                  DataQueryInformation dataQueryInformation,
                                                  int pageSize, int firstOffset);  SQLServerPagedDatabaseCollectionReader(String driver, String url, String username, String password, String query,
                                                  String idColumn, String noteColumn,int pageSize );  SQLServerPagedDatabaseCollectionReader(String driver, String url, String username, String password, String query,
                                                  String idColumn, String noteColumn,int pageSize, int firstOffset );  SQLServerPagedDatabaseCollectionReader(String driver, String url, String username, String password, String query,
                                                  String idColumn, String noteColumn,int pageSize, int firstOffset, int maxOffset ); }
SQLServerPagedDatabaseCollectionReader extends DatabaseCollectionReader { @Override public boolean hasNext() throws CollectionException { if(mRowIndex < 0 || mRecordList == null || mRowIndex == mRecordList.size()) { this.query = sqlServerPagedQuery.getPageQuery(currentBatch); if (this.query == null) { return false; } currentBatch++; mRowIndex = -1; } return super.hasNext(); } SQLServerPagedDatabaseCollectionReader();  SQLServerPagedDatabaseCollectionReader(DatabaseConnectionInformation databaseConnectionInformation,
                                                  DataQueryInformation dataQueryInformation,
                                                  int pageSize);  SQLServerPagedDatabaseCollectionReader(DatabaseConnectionInformation databaseConnectionInformation,
                                                  DataQueryInformation dataQueryInformation,
                                                  int pageSize, int firstOffset);  SQLServerPagedDatabaseCollectionReader(String driver, String url, String username, String password, String query,
                                                  String idColumn, String noteColumn,int pageSize );  SQLServerPagedDatabaseCollectionReader(String driver, String url, String username, String password, String query,
                                                  String idColumn, String noteColumn,int pageSize, int firstOffset );  SQLServerPagedDatabaseCollectionReader(String driver, String url, String username, String password, String query,
                                                  String idColumn, String noteColumn,int pageSize, int firstOffset, int maxOffset ); int getPageSize(); SQLServerPagedDatabaseCollectionReader setPageSize(int pageSize); int getFirstOffset(); SQLServerPagedDatabaseCollectionReader setFirstOffset(int firstOffset); int getMaxOffset(); SQLServerPagedDatabaseCollectionReader setMaxOffset(int maxOffset); @Override void initialize(); @Override boolean hasNext(); }
SQLServerPagedDatabaseCollectionReader extends DatabaseCollectionReader { @Override public boolean hasNext() throws CollectionException { if(mRowIndex < 0 || mRecordList == null || mRowIndex == mRecordList.size()) { this.query = sqlServerPagedQuery.getPageQuery(currentBatch); if (this.query == null) { return false; } currentBatch++; mRowIndex = -1; } return super.hasNext(); } SQLServerPagedDatabaseCollectionReader();  SQLServerPagedDatabaseCollectionReader(DatabaseConnectionInformation databaseConnectionInformation,
                                                  DataQueryInformation dataQueryInformation,
                                                  int pageSize);  SQLServerPagedDatabaseCollectionReader(DatabaseConnectionInformation databaseConnectionInformation,
                                                  DataQueryInformation dataQueryInformation,
                                                  int pageSize, int firstOffset);  SQLServerPagedDatabaseCollectionReader(String driver, String url, String username, String password, String query,
                                                  String idColumn, String noteColumn,int pageSize );  SQLServerPagedDatabaseCollectionReader(String driver, String url, String username, String password, String query,
                                                  String idColumn, String noteColumn,int pageSize, int firstOffset );  SQLServerPagedDatabaseCollectionReader(String driver, String url, String username, String password, String query,
                                                  String idColumn, String noteColumn,int pageSize, int firstOffset, int maxOffset ); int getPageSize(); SQLServerPagedDatabaseCollectionReader setPageSize(int pageSize); int getFirstOffset(); SQLServerPagedDatabaseCollectionReader setFirstOffset(int firstOffset); int getMaxOffset(); SQLServerPagedDatabaseCollectionReader setMaxOffset(int maxOffset); @Override void initialize(); @Override boolean hasNext();  }