use of org.springframework.data.projection.SpelAwareProxyProjectionFactory in project spring-data-mongodb by spring-projects.
the class StringBasedAggregationUnitTests method aggregateRaisesErrorOnInvalidReturnType.
// DATAMONGO-2506
@Test
void aggregateRaisesErrorOnInvalidReturnType() {
Method method = ClassUtils.getMethod(UnsupportedRepository.class, "pageIsUnsupported", Pageable.class);
ProjectionFactory factory = new SpelAwareProxyProjectionFactory();
MongoQueryMethod queryMethod = new MongoQueryMethod(method, new DefaultRepositoryMetadata(SampleRepository.class), factory, converter.getMappingContext());
//
assertThatExceptionOfType(InvalidMongoDbApiUsageException.class).isThrownBy(() -> new StringBasedAggregation(queryMethod, operations, PARSER, //
QueryMethodEvaluationContextProvider.DEFAULT)).withMessageContaining(//
"pageIsUnsupported").withMessageContaining("Page");
}
use of org.springframework.data.projection.SpelAwareProxyProjectionFactory in project spring-data-mongodb by spring-projects.
the class AbstractMongoQueryUnitTests method createQueryForMethod.
private MongoQueryFake createQueryForMethod(Class<?> repository, String methodName, Class<?>... paramTypes) {
try {
Method method = repository.getMethod(methodName, paramTypes);
ProjectionFactory factory = new SpelAwareProxyProjectionFactory();
MongoQueryMethod queryMethod = new MongoQueryMethod(method, new DefaultRepositoryMetadata(repository), factory, mappingContextMock);
return new MongoQueryFake(queryMethod, mongoOperationsMock);
} catch (Exception e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
use of org.springframework.data.projection.SpelAwareProxyProjectionFactory in project spring-data-mongodb by spring-projects.
the class AbstractReactiveMongoQueryUnitTests method createQueryForMethod.
private ReactiveMongoQueryFake createQueryForMethod(Class<?> repository, String methodName, Class<?>... paramTypes) {
try {
Method method = repository.getMethod(methodName, paramTypes);
ProjectionFactory factory = new SpelAwareProxyProjectionFactory();
ReactiveMongoQueryMethod queryMethod = new ReactiveMongoQueryMethod(method, new DefaultRepositoryMetadata(repository), factory, mappingContextMock);
return new ReactiveMongoQueryFake(queryMethod, mongoOperationsMock);
} catch (Exception e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
use of org.springframework.data.projection.SpelAwareProxyProjectionFactory in project spring-data-mongodb by spring-projects.
the class ReactiveMongoQueryMethodUnitTests method rejectsNullMappingContext.
// DATAMONGO-1444
@Test(expected = IllegalArgumentException.class)
public void rejectsNullMappingContext() throws Exception {
Method method = PersonRepository.class.getMethod("findByFirstname", String.class, Point.class);
new MongoQueryMethod(method, new DefaultRepositoryMetadata(PersonRepository.class), new SpelAwareProxyProjectionFactory(), null);
}
use of org.springframework.data.projection.SpelAwareProxyProjectionFactory in project spring-data-mongodb by spring-projects.
the class ReactiveMongoQueryMethodUnitTests method queryMethod.
private ReactiveMongoQueryMethod queryMethod(Class<?> repository, String name, Class<?>... parameters) throws Exception {
Method method = repository.getMethod(name, parameters);
ProjectionFactory factory = new SpelAwareProxyProjectionFactory();
return new ReactiveMongoQueryMethod(method, new DefaultRepositoryMetadata(repository), factory, context);
}
Aggregations