Search in sources :

Example 1 with PersonRepository

use of org.springframework.data.repository.support.CrudRepositoryInvokerUnitTests.PersonRepository in project spring-data-commons by spring-projects.

the class ReflectionRepositoryInvokerUnitTests method considersFormattingAnnotationsOnQueryMethodParameters.

// DATACMNS-589
@Test
public void considersFormattingAnnotationsOnQueryMethodParameters() throws Exception {
    MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>();
    parameters.add("date", "2013-07-18T10:49:00.000+02:00");
    Method method = PersonRepository.class.getMethod("findByCreatedUsingISO8601Date", Date.class, Pageable.class);
    PersonRepository repository = mock(PersonRepository.class);
    getInvokerFor(repository, expectInvocationOf(method)).invokeQueryMethod(method, parameters, Pageable.unpaged(), Sort.unsorted());
}
Also used : LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) PersonRepository(org.springframework.data.repository.support.CrudRepositoryInvokerUnitTests.PersonRepository) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 2 with PersonRepository

use of org.springframework.data.repository.support.CrudRepositoryInvokerUnitTests.PersonRepository in project spring-data-commons by spring-projects.

the class ReflectionRepositoryInvokerUnitTests method translatesCollectionRequestParametersCorrectly.

// DATACMNS-647
@Test
public void translatesCollectionRequestParametersCorrectly() throws Exception {
    for (String[] ids : Arrays.asList(new String[] { "1,2" }, new String[] { "1", "2" })) {
        MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>();
        parameters.put("ids", Arrays.asList(ids));
        Method method = PersonRepository.class.getMethod("findByIdIn", Collection.class);
        PersonRepository repository = mock(PersonRepository.class);
        getInvokerFor(repository, expectInvocationOf(method)).invokeQueryMethod(method, parameters, Pageable.unpaged(), Sort.unsorted());
    }
}
Also used : LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) PersonRepository(org.springframework.data.repository.support.CrudRepositoryInvokerUnitTests.PersonRepository) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 3 with PersonRepository

use of org.springframework.data.repository.support.CrudRepositoryInvokerUnitTests.PersonRepository in project spring-data-commons by spring-projects.

the class ReflectionRepositoryInvokerUnitTests method invokesQueryMethod.

// DATACMNS-589
@Test
public void invokesQueryMethod() throws Exception {
    MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>();
    parameters.add("firstName", "John");
    Method method = PersonRepository.class.getMethod("findByFirstName", String.class, Pageable.class);
    PersonRepository repository = mock(PersonRepository.class);
    getInvokerFor(repository, expectInvocationOf(method)).invokeQueryMethod(method, parameters, Pageable.unpaged(), Sort.unsorted());
}
Also used : LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) PersonRepository(org.springframework.data.repository.support.CrudRepositoryInvokerUnitTests.PersonRepository) Method(java.lang.reflect.Method) Test(org.junit.Test)

Aggregations

Method (java.lang.reflect.Method)3 Test (org.junit.Test)3 PersonRepository (org.springframework.data.repository.support.CrudRepositoryInvokerUnitTests.PersonRepository)3 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)3