DATACMNS-867 - ReflectionRepositoryInvoker now avoids ConversionService for Optional creation.
We now manually create Optional instances as the ConversionService converts single-argument collections into an optional with only that element.
This commit is contained in:
@@ -254,6 +254,22 @@ public class ReflectionRepositoryInvokerUnitTests {
|
||||
assertThat(invokeFindOne).isPresent();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-867
|
||||
public void wrapsSingleElementCollectionIntoOptional() throws Exception {
|
||||
|
||||
ManualCrudRepository mock = mock(ManualCrudRepository.class);
|
||||
when(mock.findAll()).thenReturn(Arrays.asList(new Domain()));
|
||||
|
||||
Method method = ManualCrudRepository.class.getMethod("findAll");
|
||||
|
||||
Optional<Object> result = getInvokerFor(mock).invokeQueryMethod(method, new LinkedMultiValueMap<>(), Pageable.unpaged(),
|
||||
Sort.unsorted());
|
||||
|
||||
assertThat(result).hasValueSatisfying(it -> {
|
||||
assertThat(it).isInstanceOf(Collection.class);
|
||||
});
|
||||
}
|
||||
|
||||
private static RepositoryInvoker getInvokerFor(Object repository) {
|
||||
|
||||
RepositoryMetadata metadata = new DefaultRepositoryMetadata(repository.getClass().getInterfaces()[0]);
|
||||
|
||||
Reference in New Issue
Block a user