DATACMNS-402 - Slight refinements in QSort implementation.

Re-enable concatenation with plain Sort via ….and(…) method. Some general polishing and JavaDoc cleanups.

Original pull request: #59.
This commit is contained in:
Oliver Gierke
2013-12-04 13:30:19 +01:00
parent f2ff84fb63
commit 62e14d2b12
3 changed files with 44 additions and 31 deletions

View File

@@ -15,18 +15,24 @@
*/
package org.springframework.data.querydsl;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.domain.Sort.Order;
import com.mysema.query.types.OrderSpecifier;
/**
* Unit tests for {@link QSort}.
*
* @author Thomas Darimont
* @author Oliver Gierke
*/
public class QSortUnitTests {
@@ -126,4 +132,18 @@ public class QSortUnitTests {
assertThat(sort.getOrderFor("firstname"), is(new Sort.Order(Sort.Direction.ASC, "firstname")));
assertThat(sort.getOrderFor("lastname"), is(new Sort.Order(Sort.Direction.DESC, "lastname")));
}
/**
* @see DATACMNS-402
*/
@Test
public void concatenatesPlainSortCorrectly() {
QUser user = QUser.user;
QSort sort = new QSort(user.firstname.asc());
Sort result = sort.and(new Sort(Direction.ASC, "lastname"));
assertThat(result, is(Matchers.<Order> iterableWithSize(2)));
assertThat(result, hasItems(new Order(Direction.ASC, "lastname"), new Order(Direction.ASC, "firstname")));
}
}