Search in sources :

Example 1 with ProjectionFactory

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

the class MongoQueryMethodUnitTests method queryMethod.

private MongoQueryMethod queryMethod(Class<?> repository, String name, Class<?>... parameters) throws Exception {
    Method method = repository.getMethod(name, parameters);
    ProjectionFactory factory = new SpelAwareProxyProjectionFactory();
    return new MongoQueryMethod(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 2 with ProjectionFactory

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

the class PartTreeMongoQueryUnitTests method createQueryForMethod.

private PartTreeMongoQuery createQueryForMethod(String methodName, Class<?>... paramTypes) {
    try {
        Method method = Repo.class.getMethod(methodName, paramTypes);
        ProjectionFactory factory = new SpelAwareProxyProjectionFactory();
        MongoQueryMethod queryMethod = new MongoQueryMethod(method, new DefaultRepositoryMetadata(Repo.class), factory, mappingContext);
        return new PartTreeMongoQuery(queryMethod, mongoOperationsMock);
    } 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) JSONParseException(com.mongodb.util.JSONParseException) ExpectedException(org.junit.rules.ExpectedException)

Example 3 with ProjectionFactory

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

the class ReactiveStringBasedMongoQueryUnitTests method createQueryForMethod.

private ReactiveStringBasedMongoQuery createQueryForMethod(String name, Class<?>... parameters) throws Exception {
    Method method = SampleRepository.class.getMethod(name, parameters);
    ProjectionFactory factory = new SpelAwareProxyProjectionFactory();
    ReactiveMongoQueryMethod queryMethod = new ReactiveMongoQueryMethod(method, new DefaultRepositoryMetadata(SampleRepository.class), factory, converter.getMappingContext());
    return new ReactiveStringBasedMongoQuery(queryMethod, operations, PARSER, DefaultEvaluationContextProvider.INSTANCE);
}
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 4 with ProjectionFactory

use of org.springframework.data.projection.ProjectionFactory 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);
    }
}
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 5 with ProjectionFactory

use of org.springframework.data.projection.ProjectionFactory 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)

Aggregations

Method (java.lang.reflect.Method)6 ProjectionFactory (org.springframework.data.projection.ProjectionFactory)6 SpelAwareProxyProjectionFactory (org.springframework.data.projection.SpelAwareProxyProjectionFactory)6 DefaultRepositoryMetadata (org.springframework.data.repository.core.support.DefaultRepositoryMetadata)6 JSONParseException (com.mongodb.util.JSONParseException)1 ExpectedException (org.junit.rules.ExpectedException)1