|
| 1 | +/* |
| 2 | + * Hibernate, Relational Persistence for Idiomatic Java |
| 3 | + * |
| 4 | + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
| 5 | + * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. |
| 6 | + */ |
| 7 | +package org.hibernate.query.sqm.tree.select; |
| 8 | + |
| 9 | +import org.hibernate.query.criteria.JpaOrder; |
| 10 | +import org.hibernate.query.sqm.tree.expression.SqmExpression; |
| 11 | + |
| 12 | +import org.hibernate.testing.TestForIssue; |
| 13 | +import org.junit.Test; |
| 14 | + |
| 15 | +import static org.hibernate.NullPrecedence.FIRST; |
| 16 | +import static org.hibernate.SortOrder.ASCENDING; |
| 17 | +import static org.hibernate.SortOrder.DESCENDING; |
| 18 | +import static org.junit.Assert.assertEquals; |
| 19 | +import static org.junit.Assert.assertNotSame; |
| 20 | +import static org.mockito.Mockito.mock; |
| 21 | + |
| 22 | +/** |
| 23 | + * @author seregamorph |
| 24 | + */ |
| 25 | +@TestForIssue(jiraKey = "HHH-13884") |
| 26 | +public class HHH13884Test { |
| 27 | + |
| 28 | + @Test |
| 29 | + public void testDefaultSqmSortSpecificationReverse() { |
| 30 | + SqmExpression sortExpression = mock( SqmExpression.class ); |
| 31 | + String collation = "collation"; |
| 32 | + |
| 33 | + SqmSortSpecification order = new SqmSortSpecification( sortExpression, collation, ASCENDING, FIRST ); |
| 34 | + |
| 35 | + assertEquals( sortExpression, order.getSortExpression() ); |
| 36 | + assertEquals( collation, order.getCollation() ); |
| 37 | + assertEquals( ASCENDING, order.getSortOrder() ); |
| 38 | + assertEquals( FIRST, order.getNullPrecedence() ); |
| 39 | + |
| 40 | + JpaOrder reversed = order.reverse(); |
| 41 | + |
| 42 | + assertEquals( DESCENDING, reversed.getSortOrder() ); |
| 43 | + assertEquals( FIRST, reversed.getNullPrecedence() ); |
| 44 | + |
| 45 | + assertNotSame( "Order.reverse() should create new instance", order, reversed ); |
| 46 | + } |
| 47 | +} |
0 commit comments