@Test public void getPage() throws SQLException { final SwiftMetaData mockSwiftMetaData = PowerMock.createMock(SwiftMetaData.class); final List<Row> rows = Arrays.<Row>asList(new ListBasedRow(1L), new ListBasedRow(2L), new ListBasedRow(3L)); BaseApiResultSet mockBaseApiResultSet = PowerMock.createMock(BaseApiResultSet.class, null, mockSwiftMetaData, rows, rows.size(), true); SwiftApiResultSet nextPage = PowerMock.createMock(BaseApiResultSet.class, null, mockSwiftMetaData, rows, rows.size(), false); EasyMock.expect(mockBaseApiResultSet.queryNextPage(EasyMock.anyObject())).andReturn(nextPage).once(); PowerMock.replayAll(); int count = 0; while (mockBaseApiResultSet.hasNext()) { Row row = mockBaseApiResultSet.getNextRow(); assertNotNull(row); count++; } assertEquals(2 * rows.size(), count++); PowerMock.verifyAll(); }
@Override public List<Row> getPage() { hasNextPage = false; List<Row> ret = rows; if (originHasNextPage) { try { SwiftApiResultSet resultSet = queryNextPage(queryObject); if (null != resultSet) { hasNextPage = true; this.rows = resultSet.getRows(); this.originHasNextPage = resultSet.isOriginHasNextPage(); } else { hasNextPage = false; this.originHasNextPage = false; } } catch (Exception e) { Crasher.crash(e); } } return ret; }
BaseApiResultSet implements SwiftApiResultSet<T> { @Override public List<Row> getPage() { hasNextPage = false; List<Row> ret = rows; if (originHasNextPage) { try { SwiftApiResultSet resultSet = queryNextPage(queryObject); if (null != resultSet) { hasNextPage = true; this.rows = resultSet.getRows(); this.originHasNextPage = resultSet.isOriginHasNextPage(); } else { hasNextPage = false; this.originHasNextPage = false; } } catch (Exception e) { Crasher.crash(e); } } return ret; } }
BaseApiResultSet implements SwiftApiResultSet<T> { @Override public List<Row> getPage() { hasNextPage = false; List<Row> ret = rows; if (originHasNextPage) { try { SwiftApiResultSet resultSet = queryNextPage(queryObject); if (null != resultSet) { hasNextPage = true; this.rows = resultSet.getRows(); this.originHasNextPage = resultSet.isOriginHasNextPage(); } else { hasNextPage = false; this.originHasNextPage = false; } } catch (Exception e) { Crasher.crash(e); } } return ret; } BaseApiResultSet(T queryObject, SwiftMetaData metaData, List<Row> rows, int rowCount, boolean originHasNextPage); }
BaseApiResultSet implements SwiftApiResultSet<T> { @Override public List<Row> getPage() { hasNextPage = false; List<Row> ret = rows; if (originHasNextPage) { try { SwiftApiResultSet resultSet = queryNextPage(queryObject); if (null != resultSet) { hasNextPage = true; this.rows = resultSet.getRows(); this.originHasNextPage = resultSet.isOriginHasNextPage(); } else { hasNextPage = false; this.originHasNextPage = false; } } catch (Exception e) { Crasher.crash(e); } } return ret; } BaseApiResultSet(T queryObject, SwiftMetaData metaData, List<Row> rows, int rowCount, boolean originHasNextPage); @Override Map<String, Integer> getLabel2Index(); @Override List<Row> getRows(); @Override boolean isOriginHasNextPage(); @Override List<Row> getPage(); @Override boolean hasNextPage(); @Override int getRowCount(); @Override int getFetchSize(); @Override SwiftMetaData getMetaData(); @Override boolean hasNext(); @Override Row getNextRow(); @Override void close(); }
BaseApiResultSet implements SwiftApiResultSet<T> { @Override public List<Row> getPage() { hasNextPage = false; List<Row> ret = rows; if (originHasNextPage) { try { SwiftApiResultSet resultSet = queryNextPage(queryObject); if (null != resultSet) { hasNextPage = true; this.rows = resultSet.getRows(); this.originHasNextPage = resultSet.isOriginHasNextPage(); } else { hasNextPage = false; this.originHasNextPage = false; } } catch (Exception e) { Crasher.crash(e); } } return ret; } BaseApiResultSet(T queryObject, SwiftMetaData metaData, List<Row> rows, int rowCount, boolean originHasNextPage); @Override Map<String, Integer> getLabel2Index(); @Override List<Row> getRows(); @Override boolean isOriginHasNextPage(); @Override List<Row> getPage(); @Override boolean hasNextPage(); @Override int getRowCount(); @Override int getFetchSize(); @Override SwiftMetaData getMetaData(); @Override boolean hasNext(); @Override Row getNextRow(); @Override void close();  }