DATACMNS-583 - DomainClassConverter returns input if given types are the same.
DomainClassConverter now returns input when the source type is identical to the target type. Previously we erroneously tried to convert the sourceType to the idType of the targetType's backing repository. As a side effect we also avoid performing some unnecessary converter hops. Original pull request: #101.
This commit is contained in:
committed by
Oliver Gierke
parent
257792c6df
commit
c898f1ec7b
@@ -39,6 +39,7 @@ import org.springframework.data.repository.core.support.DummyRepositoryFactoryBe
|
||||
* Unit test for {@link DomainClassConverter}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class DomainClassConverterUnitTests {
|
||||
@@ -143,6 +144,19 @@ public class DomainClassConverterUnitTests {
|
||||
assertThat(converter.matches(sourceDescriptor, targetDescriptor), is(true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @DATACMNS-583
|
||||
*/
|
||||
@Test
|
||||
public void shouldReturnSourceObjectIfSourceAndTargetTypesAreTheSame() {
|
||||
|
||||
ApplicationContext context = initContextWithRepo();
|
||||
converter.setApplicationContext(context);
|
||||
|
||||
assertThat(converter.matches(targetDescriptor, targetDescriptor), is(true));
|
||||
assertThat((User) converter.convert(USER, targetDescriptor, targetDescriptor), is(USER));
|
||||
}
|
||||
|
||||
private ApplicationContext initContextWithRepo() {
|
||||
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(DummyRepositoryFactoryBean.class);
|
||||
|
||||
Reference in New Issue
Block a user