use of io.shardingjdbc.core.parsing.parser.context.OrderItem 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));
}
use of io.shardingjdbc.core.parsing.parser.context.OrderItem in project sharding-jdbc by shardingjdbc.
the class OrderByValueTest method assertCompareToWhenEqual.
@Test
public void assertCompareToWhenEqual() throws SQLException {
OrderByValue orderByValue1 = new OrderByValue(new TestQueryResult(resultSet1), Arrays.asList(new OrderItem(1, OrderDirection.ASC, OrderDirection.ASC), new OrderItem(2, OrderDirection.DESC, OrderDirection.ASC)));
assertTrue(orderByValue1.next());
when(resultSet2.getObject(1)).thenReturn("1");
when(resultSet2.getObject(2)).thenReturn("2");
OrderByValue orderByValue2 = new OrderByValue(new TestQueryResult(resultSet2), Arrays.asList(new OrderItem(1, OrderDirection.ASC, OrderDirection.ASC), new OrderItem(2, OrderDirection.DESC, OrderDirection.ASC)));
assertTrue(orderByValue2.next());
assertThat(orderByValue1.compareTo(orderByValue2), is(0));
assertFalse(orderByValue1.getQueryResult().next());
assertFalse(orderByValue2.getQueryResult().next());
}
use of io.shardingjdbc.core.parsing.parser.context.OrderItem in project sharding-jdbc by shardingjdbc.
the class OrderByValueTest method assertCompareToForAsc.
@Test
public void assertCompareToForAsc() throws SQLException {
OrderByValue orderByValue1 = new OrderByValue(new TestQueryResult(resultSet1), Arrays.asList(new OrderItem(1, OrderDirection.ASC, OrderDirection.ASC), new OrderItem(2, OrderDirection.ASC, OrderDirection.ASC)));
assertTrue(orderByValue1.next());
when(resultSet2.getObject(1)).thenReturn("3");
when(resultSet2.getObject(2)).thenReturn("4");
OrderByValue orderByValue2 = new OrderByValue(new TestQueryResult(resultSet2), Arrays.asList(new OrderItem(1, OrderDirection.ASC, OrderDirection.ASC), new OrderItem(2, OrderDirection.ASC, OrderDirection.ASC)));
assertTrue(orderByValue2.next());
assertTrue(orderByValue1.compareTo(orderByValue2) < 0);
assertFalse(orderByValue1.getQueryResult().next());
assertFalse(orderByValue2.getQueryResult().next());
}
use of io.shardingjdbc.core.parsing.parser.context.OrderItem in project sharding-jdbc by shardingjdbc.
the class SelectStatementTest method assertIsSameGroupByAndOrderByItemsWhenDifferent.
@Test
public void assertIsSameGroupByAndOrderByItemsWhenDifferent() {
SelectStatement actual = new SelectStatement();
actual.getOrderByItems().add(new OrderItem("order_col", OrderDirection.ASC, OrderDirection.ASC, Optional.<String>absent()));
actual.getGroupByItems().add(new OrderItem("group_col", OrderDirection.ASC, OrderDirection.ASC, Optional.<String>absent()));
assertFalse(actual.isSameGroupByAndOrderByItems());
}
use of io.shardingjdbc.core.parsing.parser.context.OrderItem in project sharding-jdbc by shardingjdbc.
the class SelectStatementTest method assertIsSameGroupByAndOrderByItemsWhenSame.
@Test
public void assertIsSameGroupByAndOrderByItemsWhenSame() {
SelectStatement actual = new SelectStatement();
actual.getOrderByItems().add(new OrderItem("col", OrderDirection.ASC, OrderDirection.ASC, Optional.<String>absent()));
actual.getGroupByItems().add(new OrderItem("col", OrderDirection.ASC, OrderDirection.ASC, Optional.<String>absent()));
assertTrue(actual.isSameGroupByAndOrderByItems());
}
Aggregations