DATACMNS-763 - Fixed constructor in example of custom repository base class.
Added hint to which constructor of the superclass to override. Added test cas e to make sure the expected types are advertised in the case of an error.
This commit is contained in:
@@ -49,7 +49,9 @@ import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.RepositoryDefinition;
|
||||
import org.springframework.data.repository.core.EntityInformation;
|
||||
import org.springframework.data.repository.core.NamedQueries;
|
||||
import org.springframework.data.repository.core.RepositoryInformation;
|
||||
import org.springframework.data.repository.core.RepositoryMetadata;
|
||||
import org.springframework.data.repository.query.RepositoryQuery;
|
||||
import org.springframework.data.repository.sample.User;
|
||||
@@ -291,7 +293,7 @@ public class RepositoryFactorySupportUnitTests {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see @see DATACMNS-714
|
||||
* @see DATACMNS-714
|
||||
*/
|
||||
@Test
|
||||
public void wrapsExecutionResultIntoListenableFutureWithEntityCollectionIfConfigured() throws Exception {
|
||||
@@ -303,6 +305,24 @@ public class RepositoryFactorySupportUnitTests {
|
||||
expect(prepareConvertingRepository(reference).readAllByLastname("Foo"), reference);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACMNS-763
|
||||
*/
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void rejectsRepositoryBaseClassWithInvalidConstructor() {
|
||||
|
||||
RepositoryInformation information = mock(RepositoryInformation.class);
|
||||
doReturn(CustomRepositoryBaseClass.class).when(information).getRepositoryBaseClass();
|
||||
EntityInformation entityInformation = mock(EntityInformation.class);
|
||||
|
||||
exception.expect(IllegalStateException.class);
|
||||
exception.expectMessage(entityInformation.getClass().getName());
|
||||
exception.expectMessage(String.class.getName());
|
||||
|
||||
factory.getTargetRepositoryViaReflection(information, entityInformation, "Foo");
|
||||
}
|
||||
|
||||
private ConvertingRepository prepareConvertingRepository(final Object expectedValue) {
|
||||
|
||||
when(factory.queryOne.execute(Mockito.any(Object[].class))).then(new Answer<Object>() {
|
||||
@@ -411,4 +431,9 @@ public class RepositoryFactorySupportUnitTests {
|
||||
@Async
|
||||
ListenableFuture<List<User>> readAllByLastname(String lastname);
|
||||
}
|
||||
|
||||
static class CustomRepositoryBaseClass {
|
||||
|
||||
public CustomRepositoryBaseClass(EntityInformation<?, ?> information) {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user