DATAMONGO-1105 - Added implementation of QueryDslPredicateExecutor.findAll(OrderSpecifier<?>... orders).
Renamed QuerydslRepositorySupportUnitTests to QuerydslRepositorySupportTests as it's an integration test.
This commit is contained in:
@@ -102,6 +102,15 @@ public class QueryDslMongoRepository<T, ID extends Serializable> extends SimpleM
|
|||||||
return createQueryFor(predicate).orderBy(orders).list();
|
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)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.data.querydsl.QueryDslPredicateExecutor#findAll(com.mysema.query.types.Predicate, org.springframework.data.domain.Pageable)
|
* @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
|
* @param predicate
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private MongodbQuery<T> createQueryFor(Predicate predicate) {
|
private MongodbQuery<T> createQueryFor(Predicate... predicate) {
|
||||||
|
|
||||||
Class<T> domainType = getEntityInformation().getJavaType();
|
Class<T> domainType = getEntityInformation().getJavaType();
|
||||||
|
|
||||||
|
|||||||
@@ -1060,4 +1060,15 @@ public abstract class AbstractPersonRepositoryIntegrationTests {
|
|||||||
assertThat(persons, hasSize(1));
|
assertThat(persons, hasSize(1));
|
||||||
assertThat(persons, hasItem(alicia));
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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}.
|
* Unit tests for {@link QuerydslRepositorySupport}.
|
||||||
*
|
*
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
|
* @author Christoph Strobl
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration("classpath:infrastructure.xml")
|
@ContextConfiguration("classpath:infrastructure.xml")
|
||||||
public class QuerydslRepositorySupportUnitTests {
|
public class QuerydslRepositorySupportTests {
|
||||||
|
|
||||||
@Autowired MongoOperations operations;
|
@Autowired MongoOperations operations;
|
||||||
Person person;
|
Person person;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
|
|
||||||
operations.remove(new Query(), Person.class);
|
operations.remove(new Query(), Person.class);
|
||||||
person = new Person("Dave", "Matthews");
|
person = new Person("Dave", "Matthews");
|
||||||
operations.save(person);
|
operations.save(person);
|
||||||
@@ -54,6 +56,7 @@ public class QuerydslRepositorySupportUnitTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void providesMongoQuery() {
|
public void providesMongoQuery() {
|
||||||
|
|
||||||
QPerson p = QPerson.person;
|
QPerson p = QPerson.person;
|
||||||
QuerydslRepositorySupport support = new QuerydslRepositorySupport(operations) {};
|
QuerydslRepositorySupport support = new QuerydslRepositorySupport(operations) {};
|
||||||
MongodbQuery<Person> query = support.from(p).where(p.lastname.eq("Matthews"));
|
MongodbQuery<Person> query = support.from(p).where(p.lastname.eq("Matthews"));
|
||||||
Reference in New Issue
Block a user