Skip to content

Commit f2ee7d9

Browse files
christophstroblodrotbohm
authored andcommitted
DATAMONGO-1690 - Polishing.
Rename QueryDslMongoRepository -> QuerydslMongoRepository. Migrate assertions to AssertJ. Original pull request #461. Related ticket: DATACMNS-1059.
1 parent 898489f commit f2ee7d9

File tree

3 files changed

+23
-28
lines changed

3 files changed

+23
-28
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/MongoRepositoryFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ protected Class<?> getRepositoryBaseClass(RepositoryMetadata metadata) {
106106
return SimpleReactiveMongoRepository.class;
107107
}
108108

109-
return isQueryDslRepository ? QueryDslMongoRepository.class : SimpleMongoRepository.class;
109+
return isQueryDslRepository ? QuerydslMongoRepository.class : SimpleMongoRepository.class;
110110
}
111111

112112
/*
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,40 +45,40 @@
4545
import com.querydsl.mongodb.AbstractMongodbQuery;
4646

4747
/**
48-
* Special QueryDsl based repository implementation that allows execution {@link Predicate}s in various forms.
49-
*
48+
* Special Querydsl based repository implementation that allows execution {@link Predicate}s in various forms.
49+
*
5050
* @author Oliver Gierke
5151
* @author Thomas Darimont
5252
* @author Mark Paluch
5353
* @author Christoph Strobl
5454
*/
55-
public class QueryDslMongoRepository<T, ID extends Serializable> extends SimpleMongoRepository<T, ID>
55+
public class QuerydslMongoRepository<T, ID extends Serializable> extends SimpleMongoRepository<T, ID>
5656
implements QuerydslPredicateExecutor<T> {
5757

5858
private final PathBuilder<T> builder;
5959
private final EntityInformation<T, ID> entityInformation;
6060
private final MongoOperations mongoOperations;
6161

6262
/**
63-
* Creates a new {@link QueryDslMongoRepository} for the given {@link EntityMetadata} and {@link MongoTemplate}. Uses
63+
* Creates a new {@link QuerydslMongoRepository} for the given {@link EntityMetadata} and {@link MongoTemplate}. Uses
6464
* the {@link SimpleEntityPathResolver} to create an {@link EntityPath} for the given domain class.
65-
*
65+
*
6666
* @param entityInformation must not be {@literal null}.
6767
* @param mongoOperations must not be {@literal null}.
6868
*/
69-
public QueryDslMongoRepository(MongoEntityInformation<T, ID> entityInformation, MongoOperations mongoOperations) {
69+
public QuerydslMongoRepository(MongoEntityInformation<T, ID> entityInformation, MongoOperations mongoOperations) {
7070
this(entityInformation, mongoOperations, SimpleEntityPathResolver.INSTANCE);
7171
}
7272

7373
/**
74-
* Creates a new {@link QueryDslMongoRepository} for the given {@link MongoEntityInformation}, {@link MongoTemplate}
74+
* Creates a new {@link QuerydslMongoRepository} for the given {@link MongoEntityInformation}, {@link MongoTemplate}
7575
* and {@link EntityPathResolver}.
76-
*
76+
*
7777
* @param entityInformation must not be {@literal null}.
7878
* @param mongoOperations must not be {@literal null}.
7979
* @param resolver must not be {@literal null}.
8080
*/
81-
public QueryDslMongoRepository(MongoEntityInformation<T, ID> entityInformation, MongoOperations mongoOperations,
81+
public QuerydslMongoRepository(MongoEntityInformation<T, ID> entityInformation, MongoOperations mongoOperations,
8282
EntityPathResolver resolver) {
8383

8484
super(entityInformation, mongoOperations);
@@ -227,7 +227,7 @@ public boolean exists(Predicate predicate) {
227227

228228
/**
229229
* Creates a {@link MongodbQuery} for the given {@link Predicate}.
230-
*
230+
*
231231
* @param predicate
232232
* @return
233233
*/
@@ -246,7 +246,7 @@ private AbstractMongodbQuery<T, SpringDataMongodbQuery<T>> createQuery() {
246246

247247
/**
248248
* Applies the given {@link Pageable} to the given {@link MongodbQuery}.
249-
*
249+
*
250250
* @param query
251251
* @param pageable
252252
* @return
@@ -260,7 +260,7 @@ private AbstractMongodbQuery<T, SpringDataMongodbQuery<T>> applyPagination(
260260

261261
/**
262262
* Applies the given {@link Sort} to the given {@link MongodbQuery}.
263-
*
263+
*
264264
* @param query
265265
* @param sort
266266
* @return
@@ -284,7 +284,7 @@ private AbstractMongodbQuery<T, SpringDataMongodbQuery<T>> applySorting(
284284

285285
/**
286286
* Transforms a plain {@link Order} into a QueryDsl specific {@link OrderSpecifier}.
287-
*
287+
*
288288
* @param order
289289
* @return
290290
*/

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/support/QueryDslMongoRepositoryIntegrationTests.java

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
*/
1616
package org.springframework.data.mongodb.repository.support;
1717

18-
import static org.hamcrest.Matchers.*;
19-
import static org.junit.Assert.*;
18+
import static org.assertj.core.api.Assertions.*;
2019

2120
import java.util.Arrays;
2221
import java.util.List;
2322

24-
import org.assertj.core.api.Assertions;
2523
import org.junit.Before;
2624
import org.junit.Test;
2725
import org.junit.runner.RunWith;
@@ -37,7 +35,7 @@
3735
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
3836

3937
/**
40-
* Integration test for {@link QueryDslMongoRepository}.
38+
* Integration test for {@link QuerydslMongoRepository}.
4139
*
4240
* @author Thomas Darimont
4341
* @author Mark Paluch
@@ -49,7 +47,7 @@
4947
public class QueryDslMongoRepositoryIntegrationTests {
5048

5149
@Autowired MongoOperations operations;
52-
QueryDslMongoRepository<Person, String> repository;
50+
QuerydslMongoRepository<Person, String> repository;
5351

5452
Person dave, oliver, carter;
5553
QPerson person;
@@ -59,7 +57,7 @@ public void setup() {
5957

6058
MongoRepositoryFactory factory = new MongoRepositoryFactory(operations);
6159
MongoEntityInformation<Person, String> entityInformation = factory.getEntityInformation(Person.class);
62-
repository = new QueryDslMongoRepository<Person, String>(entityInformation, operations);
60+
repository = new QuerydslMongoRepository<>(entityInformation, operations);
6361

6462
operations.dropCollection(Person.class);
6563

@@ -75,29 +73,26 @@ public void setup() {
7573
@Test // DATAMONGO-1146
7674
public void shouldSupportExistsWithPredicate() throws Exception {
7775

78-
assertThat(repository.exists(person.firstname.eq("Dave")), is(true));
79-
assertThat(repository.exists(person.firstname.eq("Unknown")), is(false));
76+
assertThat(repository.exists(person.firstname.eq("Dave"))).isTrue();
77+
assertThat(repository.exists(person.firstname.eq("Unknown"))).isFalse();
8078
}
8179

8280
@Test // DATAMONGO-1167
8381
public void shouldSupportFindAllWithPredicateAndSort() {
8482

8583
List<Person> users = repository.findAll(person.lastname.isNotNull(), Sort.by(Direction.ASC, "firstname"));
8684

87-
assertThat(users, hasSize(3));
88-
assertThat(users.get(0).getFirstname(), is(carter.getFirstname()));
89-
assertThat(users.get(2).getFirstname(), is(oliver.getFirstname()));
90-
assertThat(users, hasItems(carter, dave, oliver));
85+
assertThat(users).containsExactly(carter, dave, oliver);
9186
}
9287

9388
@Test // DATAMONGO-1690
9489
public void findOneWithPredicateReturnsResultCorrectly() {
95-
Assertions.assertThat(repository.findOne(person.firstname.eq(dave.getFirstname()))).contains(dave);
90+
assertThat(repository.findOne(person.firstname.eq(dave.getFirstname()))).contains(dave);
9691
}
9792

9893
@Test // DATAMONGO-1690
9994
public void findOneWithPredicateReturnsOptionalEmptyWhenNoDataFound() {
100-
Assertions.assertThat(repository.findOne(person.firstname.eq("batman"))).isNotPresent();
95+
assertThat(repository.findOne(person.firstname.eq("batman"))).isNotPresent();
10196
}
10297

10398
@Test(expected = IncorrectResultSizeDataAccessException.class) // DATAMONGO-1690

0 commit comments

Comments
 (0)