|
18 | 18 | import static org.assertj.core.api.Assertions.*; |
19 | 19 | import static org.mockito.Mockito.*; |
20 | 20 |
|
21 | | -import java.util.Arrays; |
22 | 21 | import java.util.Collections; |
23 | 22 |
|
24 | | -import org.assertj.core.api.Assertions; |
25 | | -import org.bson.Document; |
26 | 23 | import org.junit.jupiter.api.BeforeEach; |
27 | 24 | import org.junit.jupiter.api.Test; |
28 | 25 | import org.junit.jupiter.api.extension.ExtendWith; |
29 | 26 | import org.mockito.Mock; |
30 | 27 | import org.mockito.junit.jupiter.MockitoExtension; |
| 28 | + |
31 | 29 | import org.springframework.data.mapping.context.MappingContext; |
32 | 30 | import org.springframework.data.mapping.model.SpELContext; |
33 | | -import org.springframework.data.mongodb.core.convert.ReferenceLoader.DocumentReferenceQuery; |
34 | | -import org.springframework.data.mongodb.core.convert.ReferenceLookupDelegate.LookupFunction; |
35 | 31 | import org.springframework.data.mongodb.core.convert.ReferenceResolver.MongoEntityReader; |
36 | | -import org.springframework.data.mongodb.core.convert.ReferenceResolver.ReferenceCollection; |
37 | 32 | import org.springframework.data.mongodb.core.mapping.DocumentReference; |
38 | 33 | import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity; |
39 | 34 | import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty; |
40 | 35 | import org.springframework.expression.EvaluationContext; |
41 | 36 | import org.springframework.expression.spel.standard.SpelExpressionParser; |
42 | 37 |
|
43 | 38 | /** |
| 39 | + * Unit tests for {@link ReferenceLookupDelegate}. |
| 40 | + * |
44 | 41 | * @author Christoph Strobl |
45 | 42 | */ |
46 | 43 | @ExtendWith(MockitoExtension.class) |
@@ -73,13 +70,10 @@ void shouldComputePlainStringTargetCollection() { |
73 | 70 | when(property.getDocumentReference()).thenReturn(documentReference); |
74 | 71 | when(documentReference.collection()).thenReturn("collection1"); |
75 | 72 |
|
76 | | - lookupDelegate.readReference(property, Arrays.asList("one"), new LookupFunction() { |
77 | | - @Override |
78 | | - public Iterable<Document> apply(DocumentReferenceQuery referenceQuery, ReferenceCollection referenceCollection) { |
| 73 | + lookupDelegate.readReference(property, Collections.singletonList("one"), (referenceQuery, referenceCollection) -> { |
79 | 74 |
|
80 | | - assertThat(referenceCollection.getCollection()).isEqualTo("collection1"); |
81 | | - return Collections.emptyList(); |
82 | | - } |
| 75 | + assertThat(referenceCollection.getCollection()).isEqualTo("collection1"); |
| 76 | + return Collections.emptyList(); |
83 | 77 | }, entityReader); |
84 | 78 | } |
85 | 79 | } |
0 commit comments