use of io.shardingjdbc.core.parsing.parser.sql.dql.select.SelectStatement in project sharding-jdbc by shardingjdbc.
the class DQLMergeEngineTest method setUp.
@Before
public void setUp() throws SQLException {
ResultSet resultSet = mock(ResultSet.class);
when(resultSet.getObject(1)).thenReturn(0);
ResultSetMetaData resultSetMetaData = mock(ResultSetMetaData.class);
when(resultSet.getMetaData()).thenReturn(resultSetMetaData);
when(resultSetMetaData.getColumnCount()).thenReturn(1);
when(resultSetMetaData.getColumnLabel(1)).thenReturn("count(*)");
queryResults = Collections.<QueryResult>singletonList(new TestQueryResult(resultSet));
selectStatement = new SelectStatement();
}
use of io.shardingjdbc.core.parsing.parser.sql.dql.select.SelectStatement in project sharding-jdbc by shardingjdbc.
the class GroupByRowComparatorTest method assertCompareToForAscWithOrderByItems.
@Test
public void assertCompareToForAscWithOrderByItems() throws SQLException {
MemoryQueryResultRow o1 = new MemoryQueryResultRow(mockQueryResult("1", "2"));
MemoryQueryResultRow o2 = new MemoryQueryResultRow(mockQueryResult("3", "4"));
SelectStatement selectStatement = new SelectStatement();
selectStatement.getOrderByItems().addAll(Arrays.asList(new OrderItem(1, OrderDirection.ASC, OrderDirection.ASC), new OrderItem(2, OrderDirection.ASC, OrderDirection.ASC)));
selectStatement.getGroupByItems().addAll(Arrays.asList(new OrderItem(1, OrderDirection.DESC, OrderDirection.ASC), new OrderItem(2, OrderDirection.DESC, OrderDirection.ASC)));
GroupByRowComparator groupByRowComparator = new GroupByRowComparator(selectStatement);
assertTrue(groupByRowComparator.compare(o1, o2) < 0);
}
use of io.shardingjdbc.core.parsing.parser.sql.dql.select.SelectStatement in project sharding-jdbc by shardingjdbc.
the class GroupByRowComparatorTest method assertCompareToForDecsWithGroupByItems.
@Test
public void assertCompareToForDecsWithGroupByItems() throws SQLException {
MemoryQueryResultRow o1 = new MemoryQueryResultRow(mockQueryResult("1", "2"));
MemoryQueryResultRow o2 = new MemoryQueryResultRow(mockQueryResult("3", "4"));
SelectStatement selectStatement = new SelectStatement();
selectStatement.getGroupByItems().addAll(Arrays.asList(new OrderItem(1, OrderDirection.DESC, OrderDirection.ASC), new OrderItem(2, OrderDirection.DESC, OrderDirection.ASC)));
GroupByRowComparator groupByRowComparator = new GroupByRowComparator(selectStatement);
assertTrue(groupByRowComparator.compare(o1, o2) > 0);
}
use of io.shardingjdbc.core.parsing.parser.sql.dql.select.SelectStatement in project sharding-jdbc by shardingjdbc.
the class IteratorStreamMergedResultTest method setUp.
@Before
public void setUp() throws SQLException {
ResultSet resultSet = mock(ResultSet.class);
ResultSetMetaData resultSetMetaData = mock(ResultSetMetaData.class);
when(resultSet.getMetaData()).thenReturn(resultSetMetaData);
queryResults = Lists.<QueryResult>newArrayList(new TestQueryResult(resultSet), new TestQueryResult(mock(ResultSet.class)), new TestQueryResult(mock(ResultSet.class)));
selectStatement = new SelectStatement();
}
use of io.shardingjdbc.core.parsing.parser.sql.dql.select.SelectStatement in project sharding-jdbc by shardingjdbc.
the class OrderByStreamMergedResultTest method setUp.
@Before
public void setUp() throws SQLException {
ResultSet resultSet = mock(ResultSet.class);
ResultSetMetaData resultSetMetaData = mock(ResultSetMetaData.class);
when(resultSet.getMetaData()).thenReturn(resultSetMetaData);
queryResults = Lists.<QueryResult>newArrayList(new TestQueryResult(resultSet), new TestQueryResult(mock(ResultSet.class)), new TestQueryResult(mock(ResultSet.class)));
selectStatement = new SelectStatement();
selectStatement.getOrderByItems().add(new OrderItem(1, OrderDirection.ASC, OrderDirection.ASC));
}
Aggregations