|
15 | 15 | */
|
16 | 16 | package org.springframework.data.mongodb.core.convert;
|
17 | 17 |
|
18 |
| -import static org.assertj.core.api.Assertions.assertThat; |
19 |
| -import static org.hamcrest.Matchers.*; |
20 |
| -import static org.hamcrest.Matchers.contains; |
21 |
| -import static org.junit.Assert.assertThat; |
| 18 | +import static org.assertj.core.api.Assertions.*; |
22 | 19 | import static org.mockito.ArgumentMatchers.*;
|
23 |
| -import static org.mockito.ArgumentMatchers.any; |
24 | 20 | import static org.mockito.Mockito.*;
|
25 | 21 |
|
26 | 22 | import java.util.Arrays;
|
27 |
| -import java.util.Collection; |
28 | 23 | import java.util.Collections;
|
29 | 24 |
|
30 | 25 | import org.bson.Document;
|
|
35 | 30 | import org.mockito.ArgumentCaptor;
|
36 | 31 | import org.mockito.Mock;
|
37 | 32 | import org.mockito.Mockito;
|
38 |
| -import org.mockito.invocation.InvocationOnMock; |
39 | 33 | import org.mockito.junit.MockitoJUnitRunner;
|
40 |
| -import org.mockito.stubbing.Answer; |
41 | 34 | import org.springframework.dao.InvalidDataAccessApiUsageException;
|
42 | 35 | import org.springframework.data.mongodb.MongoDbFactory;
|
43 | 36 | import org.springframework.data.mongodb.core.DocumentTestUtils;
|
@@ -88,7 +81,7 @@ public void bulkFetchShouldLoadDbRefsCorrectly() {
|
88 | 81 | Document _id = DocumentTestUtils.getAsDocument(captor.getValue(), "_id");
|
89 | 82 | Iterable<Object> $in = DocumentTestUtils.getTypedValue(_id, "$in", Iterable.class);
|
90 | 83 |
|
91 |
| - assertThat($in, iterableWithSize(2)); |
| 84 | + assertThat($in).hasSize(2); |
92 | 85 | }
|
93 | 86 |
|
94 | 87 | @Test(expected = InvalidDataAccessApiUsageException.class) // DATAMONGO-1194
|
@@ -117,19 +110,9 @@ public void bulkFetchShouldRestoreOriginalOrder() {
|
117 | 110 | DBRef ref1 = new DBRef("collection-1", o1.get("_id"));
|
118 | 111 | DBRef ref2 = new DBRef("collection-1", o2.get("_id"));
|
119 | 112 |
|
120 |
| - when(cursorMock.into(any())).then(new Answer<Object>() { |
| 113 | + when(cursorMock.into(any())).then(invocation -> Arrays.asList(o2, o1)); |
121 | 114 |
|
122 |
| - @Override |
123 |
| - public Object answer(InvocationOnMock invocation) throws Throwable { |
124 |
| - |
125 |
| - Collection<Document> collection = (Collection<Document>) invocation.getArguments()[0]; |
126 |
| - collection.add(o2); |
127 |
| - collection.add(o1); |
128 |
| - return collection; |
129 |
| - } |
130 |
| - }); |
131 |
| - |
132 |
| - assertThat(resolver.bulkFetch(Arrays.asList(ref1, ref2)), contains(o1, o2)); |
| 115 | + assertThat(resolver.bulkFetch(Arrays.asList(ref1, ref2))).containsExactly(o1, o2); |
133 | 116 | }
|
134 | 117 |
|
135 | 118 | @Test // DATAMONGO-1765
|
|
0 commit comments