DATAMONGO-1105 - Added implementation of QueryDslPredicateExecutor.findAll(OrderSpecifier<?>... orders).

Renamed QuerydslRepositorySupportUnitTests to QuerydslRepositorySupportTests as it's an integration test.
This commit is contained in:
Oliver Gierke
2014-11-28 10:37:21 +01:00
parent 81f2c910f7
commit 10c37b101d
3 changed files with 26 additions and 3 deletions

View File

@@ -102,6 +102,15 @@ public class QueryDslMongoRepository<T, ID extends Serializable> extends SimpleM
return createQueryFor(predicate).orderBy(orders).list();
}
/*
* (non-Javadoc)
* @see org.springframework.data.querydsl.QueryDslPredicateExecutor#findAll(com.mysema.query.types.OrderSpecifier[])
*/
@Override
public Iterable<T> findAll(OrderSpecifier<?>... orders) {
return createQueryFor(new Predicate[0]).orderBy(orders).list();
}
/*
* (non-Javadoc)
* @see org.springframework.data.querydsl.QueryDslPredicateExecutor#findAll(com.mysema.query.types.Predicate, org.springframework.data.domain.Pageable)
@@ -128,7 +137,7 @@ public class QueryDslMongoRepository<T, ID extends Serializable> extends SimpleM
* @param predicate
* @return
*/
private MongodbQuery<T> createQueryFor(Predicate predicate) {
private MongodbQuery<T> createQueryFor(Predicate... predicate) {
Class<T> domainType = getEntityInformation().getJavaType();

View File

@@ -1060,4 +1060,15 @@ public abstract class AbstractPersonRepositoryIntegrationTests {
assertThat(persons, hasSize(1));
assertThat(persons, hasItem(alicia));
}
/**
* @see DATAMONGO-1105
*/
@Test
public void returnsOrderedResultsForQuerydslOrderSpecifier() {
Iterable<Person> result = repository.findAll(person.firstname.asc());
assertThat(result, contains(alicia, boyd, carter, dave, leroi, oliver, stefan));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011 the original author or authors.
* Copyright 2011-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,16 +37,18 @@ import com.mysema.query.mongodb.MongodbQuery;
* Unit tests for {@link QuerydslRepositorySupport}.
*
* @author Oliver Gierke
* @author Christoph Strobl
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:infrastructure.xml")
public class QuerydslRepositorySupportUnitTests {
public class QuerydslRepositorySupportTests {
@Autowired MongoOperations operations;
Person person;
@Before
public void setUp() {
operations.remove(new Query(), Person.class);
person = new Person("Dave", "Matthews");
operations.save(person);
@@ -54,6 +56,7 @@ public class QuerydslRepositorySupportUnitTests {
@Test
public void providesMongoQuery() {
QPerson p = QPerson.person;
QuerydslRepositorySupport support = new QuerydslRepositorySupport(operations) {};
MongodbQuery<Person> query = support.from(p).where(p.lastname.eq("Matthews"));