use of com.dangdang.ddframe.rdb.sharding.merger.fixture.MockResultSet in project sharding-jdbc by dangdangdotcom.
the class OrderByResultSetTest method assertNextForDesc.
@Test
public void assertNextForDesc() throws SQLException {
ResultSet resultSet = ResultSetFactory.getResultSet(Arrays.<ResultSet>asList(new MockResultSet<>(4, 1), new MockResultSet<>(4, 2), new MockResultSet<Integer>()), createMergeContext(OrderByType.DESC));
assertTrue(resultSet.next());
assertThat(resultSet.getInt(1), is(4));
assertTrue(resultSet.next());
assertThat(resultSet.getInt(1), is(4));
assertTrue(resultSet.next());
assertThat(resultSet.getInt(1), is(2));
assertTrue(resultSet.next());
assertThat(resultSet.getInt(1), is(1));
assertFalse(resultSet.next());
}
use of com.dangdang.ddframe.rdb.sharding.merger.fixture.MockResultSet in project sharding-jdbc by dangdangdotcom.
the class IteratorResultSetTest method assertNextWithLimitForPartData.
@Test
public void assertNextWithLimitForPartData() throws SQLException {
MergeContext mergeContext = new MergeContext();
mergeContext.setLimit(new Limit(1, 1, -1, -1));
ResultSet resultSet = ResultSetFactory.getResultSet(Arrays.<ResultSet>asList(new MockResultSet<>(1), new MockResultSet<>(2, 4), new MockResultSet<Integer>()), mergeContext);
int count = 0;
while (resultSet.next()) {
count++;
}
assertThat(count, is(1));
}
use of com.dangdang.ddframe.rdb.sharding.merger.fixture.MockResultSet in project sharding-jdbc by dangdangdotcom.
the class MemoryOrderByResultSetTest method assertSort.
@Test
public void assertSort() throws SQLException {
AbstractMemoryOrderByResultSet rs = new AbstractMemoryOrderByResultSet(Arrays.<ResultSet>asList(new MockResultSet<>(1, 3, 5, 6, 6), new MockResultSet<>(8, 6, 4, 2)), Collections.singletonList(new OrderByColumn(1, OrderByColumn.OrderByType.ASC))) {
};
List<Integer> actualList = new ArrayList<>();
while (rs.next()) {
actualList.add(rs.getInt(1));
}
assertThat(actualList, is(Arrays.asList(1, 2, 3, 4, 5, 6, 6, 6, 8)));
rs.close();
assertThat(rs.isClosed(), is(true));
rs = new AbstractMemoryOrderByResultSet(Arrays.<ResultSet>asList(new MockResultSet<>(1, 3, 5, 6, 6), new MockResultSet<>(8, 6, 4, 2)), Collections.singletonList(new OrderByColumn(1, OrderByColumn.OrderByType.DESC))) {
};
actualList.clear();
while (rs.next()) {
actualList.add(rs.getInt("nAmE"));
}
assertThat(actualList, is(Arrays.asList(8, 6, 6, 6, 5, 4, 3, 2, 1)));
}
use of com.dangdang.ddframe.rdb.sharding.merger.fixture.MockResultSet in project sharding-jdbc by dangdangdotcom.
the class OrderByResultSetTest method assertNextForAsc.
@Test
public void assertNextForAsc() throws SQLException {
ResultSet resultSet = ResultSetFactory.getResultSet(Arrays.<ResultSet>asList(new MockResultSet<>(1, 4), new MockResultSet<>(2, 4), new MockResultSet<Integer>()), createMergeContext(OrderByType.ASC));
assertTrue(resultSet.next());
assertThat(resultSet.getInt(1), is(1));
assertTrue(resultSet.next());
assertThat(resultSet.getInt(1), is(2));
assertTrue(resultSet.next());
assertThat(resultSet.getInt(1), is(4));
assertTrue(resultSet.next());
assertThat(resultSet.getInt(1), is(4));
assertFalse(resultSet.next());
}
use of com.dangdang.ddframe.rdb.sharding.merger.fixture.MockResultSet in project sharding-jdbc by dangdangdotcom.
the class IteratorResultSetTest method assertNextWithLimitForAllData.
@Test
public void assertNextWithLimitForAllData() throws SQLException {
MergeContext mergeContext = new MergeContext();
mergeContext.setLimit(new Limit(1, 10, -1, -1));
ResultSet resultSet = ResultSetFactory.getResultSet(Arrays.<ResultSet>asList(new MockResultSet<>(1), new MockResultSet<>(2, 4), new MockResultSet<Integer>()), mergeContext);
int count = 0;
while (resultSet.next()) {
count++;
}
assertThat(count, is(2));
}
Aggregations