SearchLogsController extends AbstractTemplateController { @Override protected ModelAndView svnHandle(final SVNConnection connection, final BaseCommand command, final long headRevision, final UserRepositoryContext userRepositoryContext, final HttpServletRequest request, final HttpServletResponse response, final BindException exception) throws Exception { final String searchString = ServletRequestUtils.getRequiredStringParameter(request, SEARCH_STRING_PARAMETER); final String startDir = ServletRequestUtils.getRequiredStringParameter(request, START_DIR_PARAMETER); logger.debug("Searching logs for: " + searchString + " in path: " + startDir); final List<LogMessageSearchItem> logEntries; if (isRootDir(startDir)) { logEntries = getCache().find(command.getName(), searchString); } else { logEntries = getCache().find(command.getName(), searchString, startDir); } Collections.sort(logEntries, new LogMessageComparator(LogMessageComparator.DESCENDING)); final Map<String, Object> model = new HashMap<String, Object>(); model.put(SEARCH_STRING_PARAMETER, searchString); model.put(START_DIR_PARAMETER, startDir); model.put("logEntries", logEntries); model.put("isLogSearch", true); return new ModelAndView(getViewName(), model); }   static final String SEARCH_STRING_PARAMETER; static final String START_DIR_PARAMETER; }
@Test public void testSvnHandle() throws Exception { final CacheGateway mockCache = EasyMock.createMock(CacheGateway.class); final MockHttpServletRequest request = new MockHttpServletRequest(); request.addParameter(SEARCH_STRING_PARAMETER, "abc"); request.addParameter(START_DIR_PARAMETER, "/trunk/"); final BaseCommand command = new BaseCommand(); command.setPath("trunk/test"); command.setName(new RepositoryName("test")); command.setRevision(Revision.create(12)); final SearchLogsController ctrl = new SearchLogsController(); ctrl.setCacheGateway(mockCache); final List<LogMessageSearchItem> result = new ArrayList<LogMessageSearchItem>(); result.add(new LogMessageSearchItem(TestUtils.createLogEntry(123, "jesper", new Date(), "Revision 123.", null))); expect(mockCache.find(command.getName(), "abc", "/trunk/")).andStubReturn(result); replay(mockCache); final ModelAndView modelAndView = ctrl.svnHandle(null, command, 100, null, request, null, null); final Map model = modelAndView.getModel(); verify(mockCache); assertEquals(4, model.size()); assertEquals("abc", model.get(SEARCH_STRING_PARAMETER)); assertEquals("/trunk/", model.get(START_DIR_PARAMETER)); assertEquals(result, model.get("logEntries")); assertTrue((Boolean) model.get("isLogSearch")); }