Search in sources :

Example 6 with SpelAwareProxyProjectionFactory

use of org.springframework.data.projection.SpelAwareProxyProjectionFactory in project spring-data-mongodb by spring-projects.

the class MongoQueryMethodUnitTests method rejectsNullMappingContext.

@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);
}
Also used : SpelAwareProxyProjectionFactory(org.springframework.data.projection.SpelAwareProxyProjectionFactory) DefaultRepositoryMetadata(org.springframework.data.repository.core.support.DefaultRepositoryMetadata) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 7 with SpelAwareProxyProjectionFactory

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);
}
Also used : SpelAwareProxyProjectionFactory(org.springframework.data.projection.SpelAwareProxyProjectionFactory) DefaultRepositoryMetadata(org.springframework.data.repository.core.support.DefaultRepositoryMetadata) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 8 with SpelAwareProxyProjectionFactory

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);
}
Also used : ProjectionFactory(org.springframework.data.projection.ProjectionFactory) SpelAwareProxyProjectionFactory(org.springframework.data.projection.SpelAwareProxyProjectionFactory) SpelAwareProxyProjectionFactory(org.springframework.data.projection.SpelAwareProxyProjectionFactory) DefaultRepositoryMetadata(org.springframework.data.repository.core.support.DefaultRepositoryMetadata) Method(java.lang.reflect.Method)

Example 9 with SpelAwareProxyProjectionFactory

use of org.springframework.data.projection.SpelAwareProxyProjectionFactory in project spring-data-mongodb by spring-projects.

the class StringBasedMongoQueryUnitTests method createQueryForMethod.

private StringBasedMongoQuery createQueryForMethod(String name, Class<?>... parameters) {
    try {
        Method method = SampleRepository.class.getMethod(name, parameters);
        ProjectionFactory factory = new SpelAwareProxyProjectionFactory();
        MongoQueryMethod queryMethod = new MongoQueryMethod(method, new DefaultRepositoryMetadata(SampleRepository.class), factory, converter.getMappingContext());
        return new StringBasedMongoQuery(queryMethod, operations, PARSER, DefaultEvaluationContextProvider.INSTANCE);
    } catch (Exception e) {
        throw new IllegalArgumentException(e.getMessage(), e);
    }
}
Also used : ProjectionFactory(org.springframework.data.projection.ProjectionFactory) SpelAwareProxyProjectionFactory(org.springframework.data.projection.SpelAwareProxyProjectionFactory) SpelAwareProxyProjectionFactory(org.springframework.data.projection.SpelAwareProxyProjectionFactory) DefaultRepositoryMetadata(org.springframework.data.repository.core.support.DefaultRepositoryMetadata) Method(java.lang.reflect.Method)

Aggregations

Method (java.lang.reflect.Method)9 SpelAwareProxyProjectionFactory (org.springframework.data.projection.SpelAwareProxyProjectionFactory)9 DefaultRepositoryMetadata (org.springframework.data.repository.core.support.DefaultRepositoryMetadata)9 ProjectionFactory (org.springframework.data.projection.ProjectionFactory)6 Test (org.junit.Test)2 JSONParseException (com.mongodb.util.JSONParseException)1 ExpectedException (org.junit.rules.ExpectedException)1 MongoMappingContext (org.springframework.data.mongodb.core.mapping.MongoMappingContext)1 Query (org.springframework.data.mongodb.core.query.Query)1 PartTree (org.springframework.data.repository.query.parser.PartTree)1