@Test public void search_QueryGenerationFromMethodNameIsUsed_ShouldReturnTodoDocuments() { ReflectionTestUtils.setField(service, "queryMethodType", RepositoryTodoIndexService.QUERY_METHOD_METHOD_NAME); List<TodoDocument> expected = new ArrayList<TodoDocument>(); when(repositoryMock.findByTitleContainsOrDescriptionContains(eq(SEARCH_TERM), eq(SEARCH_TERM), any(Sort.class))).thenReturn(expected); List<TodoDocument> actual = service.search(SEARCH_TERM); ArgumentCaptor<Sort> sortArgument = ArgumentCaptor.forClass(Sort.class); verify(repositoryMock, times(1)).findByTitleContainsOrDescriptionContains(eq(SEARCH_TERM), eq(SEARCH_TERM), sortArgument.capture()); verifyNoMoreInteractions(repositoryMock); Sort sort = sortArgument.getValue(); assertEquals(Sort.Direction.DESC, sort.getOrderFor(TodoDocument.FIELD_ID).getDirection()); assertEquals(expected, actual); }
@Override public List<TodoDocument> search(String searchTerm) { LOGGER.debug("Searching documents with search term: {}", searchTerm); return findDocuments(searchTerm); }
RepositoryTodoIndexService implements TodoIndexService { @Override public List<TodoDocument> search(String searchTerm) { LOGGER.debug("Searching documents with search term: {}", searchTerm); return findDocuments(searchTerm); } }
RepositoryTodoIndexService implements TodoIndexService { @Override public List<TodoDocument> search(String searchTerm) { LOGGER.debug("Searching documents with search term: {}", searchTerm); return findDocuments(searchTerm); }  }
RepositoryTodoIndexService implements TodoIndexService { @Override public List<TodoDocument> search(String searchTerm) { LOGGER.debug("Searching documents with search term: {}", searchTerm); return findDocuments(searchTerm); }  @Transactional @Override void addToIndex(Todo todoEntry); @Transactional @Override void deleteFromIndex(Long id); @Override List<TodoDocument> search(String searchTerm); @Transactional @Override void update(Todo todoEntry); }
RepositoryTodoIndexService implements TodoIndexService { @Override public List<TodoDocument> search(String searchTerm) { LOGGER.debug("Searching documents with search term: {}", searchTerm); return findDocuments(searchTerm); }  @Transactional @Override void addToIndex(Todo todoEntry); @Transactional @Override void deleteFromIndex(Long id); @Override List<TodoDocument> search(String searchTerm); @Transactional @Override void update(Todo todoEntry);  }