Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c350be1

Browse files
committedOct 5, 2021
Polishing.
Reformat code. See #3842 Original pull request: #3844.
1 parent 65b058f commit c350be1

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed
 

‎spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/ReferenceLookupDelegate.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ private ReferenceCollection computeReferenceContext(MongoPersistentProperty prop
127127
// Use the first value as a reference for others in case of collection like
128128
if (value instanceof Iterable) {
129129

130-
Iterator iterator = ((Iterable) value).iterator();
130+
Iterator<?> iterator = ((Iterable<?>) value).iterator();
131131
value = iterator.hasNext() ? iterator.next() : new Document();
132132
}
133133

@@ -198,7 +198,7 @@ private <T> T parseValueOrGet(String value, ParameterBindingContext bindingConte
198198
return (T) codec.decode(value, bindingContext);
199199
}
200200

201-
if(!value.startsWith("#") && ExpressionUtils.detectExpression(value) == null) {
201+
if (!value.startsWith("#") && ExpressionUtils.detectExpression(value) == null) {
202202
return (T) value;
203203
}
204204

‎spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/ReferenceLookupDelegateUnitTests.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,26 @@
1818
import static org.assertj.core.api.Assertions.*;
1919
import static org.mockito.Mockito.*;
2020

21-
import java.util.Arrays;
2221
import java.util.Collections;
2322

24-
import org.assertj.core.api.Assertions;
25-
import org.bson.Document;
2623
import org.junit.jupiter.api.BeforeEach;
2724
import org.junit.jupiter.api.Test;
2825
import org.junit.jupiter.api.extension.ExtendWith;
2926
import org.mockito.Mock;
3027
import org.mockito.junit.jupiter.MockitoExtension;
28+
3129
import org.springframework.data.mapping.context.MappingContext;
3230
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;
3531
import org.springframework.data.mongodb.core.convert.ReferenceResolver.MongoEntityReader;
36-
import org.springframework.data.mongodb.core.convert.ReferenceResolver.ReferenceCollection;
3732
import org.springframework.data.mongodb.core.mapping.DocumentReference;
3833
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
3934
import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
4035
import org.springframework.expression.EvaluationContext;
4136
import org.springframework.expression.spel.standard.SpelExpressionParser;
4237

4338
/**
39+
* Unit tests for {@link ReferenceLookupDelegate}.
40+
*
4441
* @author Christoph Strobl
4542
*/
4643
@ExtendWith(MockitoExtension.class)
@@ -73,13 +70,10 @@ void shouldComputePlainStringTargetCollection() {
7370
when(property.getDocumentReference()).thenReturn(documentReference);
7471
when(documentReference.collection()).thenReturn("collection1");
7572

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) -> {
7974

80-
assertThat(referenceCollection.getCollection()).isEqualTo("collection1");
81-
return Collections.emptyList();
82-
}
75+
assertThat(referenceCollection.getCollection()).isEqualTo("collection1");
76+
return Collections.emptyList();
8377
}, entityReader);
8478
}
8579
}

0 commit comments

Comments
 (0)
Please sign in to comment.