|
1 | 1 | /*
|
2 |
| - * Copyright 2017-2020 the original author or authors. |
| 2 | + * Copyright 2017-2022 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
37 | 37 | import static org.junit.Assert.fail;
|
38 | 38 | import static org.mockito.ArgumentMatchers.eq;
|
39 | 39 | import static org.mockito.Mockito.when;
|
| 40 | +import static org.springframework.data.mongodb.core.query.Criteria.where; |
| 41 | +import static org.springframework.data.mongodb.core.query.Query.query; |
40 | 42 |
|
41 | 43 | /**
|
42 | 44 | * @author Glenn Renfro
|
43 | 45 | * @author Drummond Dawson
|
44 | 46 | * @author Parikshit Dutta
|
| 47 | + * @author Mahmoud Ben Hassine |
45 | 48 | */
|
46 | 49 | public class MongoItemReaderBuilderTests {
|
47 | 50 | @Mock
|
@@ -209,14 +212,23 @@ public void testNullQuery() {
|
209 | 212 | }
|
210 | 213 |
|
211 | 214 | @Test
|
212 |
| - public void testNullSorts() { |
| 215 | + public void testNullSortsWithQueryString() { |
213 | 216 | validateExceptionMessage(new MongoItemReaderBuilder<String>().template(this.template)
|
214 | 217 | .targetType(String.class)
|
215 | 218 | .jsonQuery("{ }")
|
216 | 219 | .name("mongoReaderTest")
|
217 | 220 | .pageSize(50), "sorts map is required.");
|
218 | 221 | }
|
219 | 222 |
|
| 223 | + @Test |
| 224 | + public void testNullSortsWithQuery() { |
| 225 | + validateExceptionMessage(new MongoItemReaderBuilder<String>().template(this.template) |
| 226 | + .targetType(String.class) |
| 227 | + .query(query(where("_id").is("10"))) |
| 228 | + .name("mongoReaderTest") |
| 229 | + .pageSize(50), "sorts map is required."); |
| 230 | + } |
| 231 | + |
220 | 232 | @Test
|
221 | 233 | public void testNullName() {
|
222 | 234 | validateExceptionMessage(new MongoItemReaderBuilder<String>().template(this.template)
|
|
0 commit comments