DATACMNS-866 - Improved error message in invalid invocations of BasicPersistentEntity.getPropertyAccessor(…).
We now explicitly report the given object's type and the one expected in case of a mismatch when BasicPersistentEntity.getPropertyAccessor(…) is invoked.
This commit is contained in:
@@ -17,7 +17,7 @@ package org.springframework.data.mapping.model;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assume.assumeThat;
|
||||
import static org.junit.Assume.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -261,6 +261,20 @@ public class BasicPersistentEntityUnitTests<T extends PersistentProperty<T>> {
|
||||
assertThat(entity.getTypeAlias(), is((Object) "bar"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACMNS-866
|
||||
*/
|
||||
@Test
|
||||
public void invalidBeanAccessCreatesDescriptiveErrorMessage() {
|
||||
|
||||
PersistentEntity<Entity, T> entity = createEntity(Entity.class);
|
||||
|
||||
exception.expectMessage(Entity.class.getName());
|
||||
exception.expectMessage(Object.class.getName());
|
||||
|
||||
entity.getPropertyAccessor(new Object());
|
||||
}
|
||||
|
||||
private <S> BasicPersistentEntity<S, T> createEntity(Class<S> type) {
|
||||
return createEntity(type, null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user