use of org.springframework.data.repository.core.RepositoryMetadata in project spring-data-jdbc by spring-projects.
the class JdbcQueryMethodUnitTests method returnsSqlStatement.
// DATAJDBC-165
@Test
public void returnsSqlStatement() throws NoSuchMethodException {
RepositoryMetadata metadata = mock(RepositoryMetadata.class);
when(metadata.getReturnedDomainClass(any(Method.class))).thenReturn((Class) String.class);
JdbcQueryMethod queryMethod = new JdbcQueryMethod(JdbcQueryMethodUnitTests.class.getDeclaredMethod("queryMethod"), metadata, mock(ProjectionFactory.class));
assertThat(queryMethod.getAnnotatedQuery()).isEqualTo(DUMMY_SELECT);
}
use of org.springframework.data.repository.core.RepositoryMetadata in project spring-data-keyvalue by spring-projects.
the class SpelQueryEngineUnitTests method createQueryForMethodWithArgs.
private static SpelCriteria createQueryForMethodWithArgs(String methodName, Object... args) throws Exception {
List<Class<?>> types = new ArrayList<>(args.length);
for (Object arg : args) {
types.add(arg.getClass());
}
Method method = PersonRepository.class.getMethod(methodName, types.toArray(new Class<?>[types.size()]));
RepositoryMetadata metadata = mock(RepositoryMetadata.class);
doReturn(method.getReturnType()).when(metadata).getReturnedDomainClass(method);
PartTree partTree = new PartTree(method.getName(), method.getReturnType());
SpelQueryCreator creator = new SpelQueryCreator(partTree, new ParametersParameterAccessor(new QueryMethod(method, metadata, new SpelAwareProxyProjectionFactory()).getParameters(), args));
return new SpelCriteria(creator.createQuery().getCriteria(), new StandardEvaluationContext(args));
}
use of org.springframework.data.repository.core.RepositoryMetadata in project spring-data-commons by spring-projects.
the class AbstractRepositoryMetadataUnitTests method handlesGenericTypeInReturnedCollectionCorrectly.
// DATACMNS-98
@Test
public void handlesGenericTypeInReturnedCollectionCorrectly() throws SecurityException, NoSuchMethodException {
RepositoryMetadata metadata = new DummyRepositoryMetadata(ExtendingRepository.class);
Method method = ExtendingRepository.class.getMethod("anotherMethod");
assertThat(metadata.getReturnedDomainClass(method)).isEqualTo(Map.class);
}
use of org.springframework.data.repository.core.RepositoryMetadata in project spring-data-commons by spring-projects.
the class ReflectionRepositoryInvokerUnitTests method getInvokerFor.
private static RepositoryInvoker getInvokerFor(Object repository) {
RepositoryMetadata metadata = new DefaultRepositoryMetadata(repository.getClass().getInterfaces()[0]);
GenericConversionService conversionService = new DefaultFormattingConversionService();
return new ReflectionRepositoryInvoker(repository, metadata, conversionService);
}
use of org.springframework.data.repository.core.RepositoryMetadata in project spring-data-commons by spring-projects.
the class DefaultRepositoryMetadataUnitTests method findsDomainClassOnExtensionOfDaoInterface.
@Test
public void findsDomainClassOnExtensionOfDaoInterface() throws Exception {
RepositoryMetadata metadata = new DefaultRepositoryMetadata(ExtensionOfUserCustomExtendedDao.class);
assertThat(metadata.getDomainType()).isEqualTo(User.class);
}
Aggregations