FlattenController 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 List<DirEntry> entries = Collections.checkedList(new ArrayList<DirEntry>(), DirEntry.class); logger.debug("Flattening directories below: " + command.getPath()); entries.addAll(getCache().findDirectories(command.getName(), command.getPath())); logger.debug(entries.size() + " entries found"); final Map<String, Object> model = new HashMap<String, Object>(); logger.debug("Sort params: " + userRepositoryContext.getSortType().name() + ", " + userRepositoryContext.getSortMode()); new DirEntrySorter(userRepositoryContext.getSortType(), userRepositoryContext.getSortMode()).sort(entries); model.put("dirEntries", entries); model.put("isFlatten", true); return new ModelAndView(getViewName(), model); }    }
@Test public void testSvnHandle() throws Exception { final CacheGateway mockCache = EasyMock.createMock(CacheGateway.class); final List<DirEntry> entries = TestUtils.getFlattenedDirectoriesList(); final BaseCommand command = new BaseCommand(); command.setName(new RepositoryName("test")); command.setRevision(Revision.create(12)); final UserRepositoryContext context = new UserRepositoryContext(); context.setSortMode(DirEntrySorter.SortMode.DESC); context.setSortType(DirEntryComparator.SortType.REVISION); final FlattenController ctrl = new FlattenController(); ctrl.setCacheGateway(mockCache); expect(mockCache.findDirectories(command.getName(), command.getPath())).andStubReturn(entries); replay(mockCache); final ModelAndView modelAndView = ctrl.svnHandle(null, command, 100, context, null, null, null); final Map model = modelAndView.getModel(); verify(mockCache); assertEquals(2, model.size()); assertEquals(entries.get(2), ((List<DirEntry>) model.get("dirEntries")).get(0)); assertEquals(Boolean.TRUE, model.get("isFlatten")); }