DATACMNS-1056 - Prevent QueryExecutionResultHander from rewrapping JDK 8 Optionals.
In case a repository method execution returns a JDK 8 Optional in the first place, the Optional instance had been wrapped into a third-party null-wrapper as is. We're now unwrapping the value held inside that optional and forward it to the value conversion.
This commit is contained in:
@@ -17,6 +17,7 @@ package org.springframework.data.repository.core.support;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import javaslang.control.Option;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import rx.Completable;
|
||||
@@ -336,6 +337,17 @@ public class QueryExecutionResultHandlerUnitTests {
|
||||
assertThat(flux.next().block()).isEqualTo(entity.block());
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1056
|
||||
public void convertsOptionalToThirdPartyOption() throws Exception {
|
||||
|
||||
Entity value = new Entity();
|
||||
Optional<Entity> entity = Optional.of(value);
|
||||
|
||||
Object result = handler.postProcessInvocationResult(entity, TypeDescriptor.valueOf(Option.class));
|
||||
|
||||
assertThat(result).isInstanceOfSatisfying(Option.class, it -> assertThat(it.get()).isEqualTo(value));
|
||||
}
|
||||
|
||||
private static TypeDescriptor getTypeDescriptorFor(String methodName) throws Exception {
|
||||
|
||||
Method method = Sample.class.getMethod(methodName);
|
||||
|
||||
Reference in New Issue
Block a user