DATACMNS-768 - Added support for Optional as query method parameter type.

Query method parameter values of JDK 8 or Guava Optional type are now transparently unwrapped on parameter value access. ParametersParameterAccessor now unwraps them on instance creation.
This commit is contained in:
Oliver Gierke
2015-10-07 19:28:19 +02:00
parent 91eaf1bc50
commit 1185e71214
3 changed files with 128 additions and 17 deletions

View File

@@ -109,4 +109,36 @@ public class QueryExecutionConvertersUnitTests {
assertThat(result.isDone(), is(true));
assertThat(result.get(), is(nullValue()));
}
/**
* @see DATACMNS-768
*/
@Test
public void unwrapsJdk8Optional() {
assertThat(QueryExecutionConverters.unwrap(java.util.Optional.of("Foo")), is((Object) "Foo"));
}
/**
* @see DATACMNS-768
*/
@Test
public void unwrapsGuava8Optional() {
assertThat(QueryExecutionConverters.unwrap(Optional.of("Foo")), is((Object) "Foo"));
}
/**
* @see DATACMNS-768
*/
@Test
public void unwrapsNullToNull() {
assertThat(QueryExecutionConverters.unwrap(null), is(nullValue()));
}
/**
* @see DATACMNS-768
*/
@Test
public void unwrapsNonWrapperTypeToItself() {
assertThat(QueryExecutionConverters.unwrap("Foo"), is((Object) "Foo"));
}
}