DrawerManager extends Panel { public void replaceLast(AbstractDrawer newDrawer, AjaxRequestTarget target) { if (!drawers.isEmpty()) { ListItem last = drawers.getFirst(); last.drawer.replaceWith(newDrawer); last.drawer = newDrawer; newDrawer.setManager(this); target.add(newDrawer); } } DrawerManager(String id); void push(AbstractDrawer drawer); void push(AbstractDrawer drawer, AjaxRequestTarget target); void push(AbstractDrawer drawer, String cssClass); void push(AbstractDrawer drawer, AjaxRequestTarget target, String cssClass); void pop(AbstractDrawer drawer, AjaxRequestTarget target); void replaceLast(AbstractDrawer newDrawer, AjaxRequestTarget target); @SuppressWarnings("unchecked") T getLast(Class<T> drawerClass); String getLastItemRelativePath(); @Override void renderHead(IHeaderResponse response);  }
@Test public void testReplaceDrawerInEmptyManager() { DrawerManager m = new DrawerManager("test"); startTest(m); replayAll(); AbstractDrawer d = new TestDrawer(); m.replaceLast(d, getTarget()); verifyAll(); }