DATACMNS-1215 - Fixed repository lookup for proxy domain classes.
We now consistently use the user class for repository (metadata) lookup in Repositories.
This commit is contained in:
@@ -29,6 +29,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
@@ -140,6 +141,23 @@ public class RepositoriesUnitTests {
|
||||
.hasValueSatisfying(it -> assertThat(it.getRepositoryInterface()).isEqualTo(PersonRepository.class));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1215
|
||||
public void exposesRepositoryForProxyType() {
|
||||
|
||||
ProxyFactory factory = new ProxyFactory();
|
||||
factory.setTarget(new Person());
|
||||
factory.setProxyTargetClass(true);
|
||||
|
||||
Object proxy = factory.getProxy();
|
||||
|
||||
assertThat(ClassUtils.isCglibProxy(proxy)).isTrue();
|
||||
|
||||
Repositories repositories = new Repositories(context);
|
||||
|
||||
assertThat(repositories.hasRepositoryFor(proxy.getClass())).isTrue();
|
||||
assertThat(repositories.getRepositoryFor(proxy.getClass())).isNotEmpty();
|
||||
}
|
||||
|
||||
class Person {}
|
||||
|
||||
class Address {}
|
||||
|
||||
Reference in New Issue
Block a user