DATACMNS-795 - Added support for Scala's Option type on repositories.
Just like with Google's or Java 8's optional we now support Scala's Option type as wrapper fro return values on repositories.
This commit is contained in:
@@ -19,6 +19,8 @@ import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assume.*;
|
||||
|
||||
import scala.Option;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
@@ -60,6 +62,7 @@ public class QueryExecutionConvertersUnitTests {
|
||||
assertThat(QueryExecutionConverters.supports(java.util.Optional.class), is(true));
|
||||
assertThat(QueryExecutionConverters.supports(Future.class), is(true));
|
||||
assertThat(QueryExecutionConverters.supports(ListenableFuture.class), is(true));
|
||||
assertThat(QueryExecutionConverters.supports(Option.class), is(true));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,4 +144,23 @@ public class QueryExecutionConvertersUnitTests {
|
||||
public void unwrapsNonWrapperTypeToItself() {
|
||||
assertThat(QueryExecutionConverters.unwrap("Foo"), is((Object) "Foo"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACMNS-795
|
||||
*/
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void turnsNullIntoScalaOptionEmpty() {
|
||||
|
||||
assertThat((Option<Object>) conversionService.convert(new NullableWrapper(null), Option.class),
|
||||
is(Option.<Object> empty()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACMNS-795
|
||||
*/
|
||||
@Test
|
||||
public void unwrapsScalaOption() {
|
||||
assertThat(QueryExecutionConverters.unwrap(Option.apply("foo")), is((Object) "foo"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user