@Test public void testRemoveViewInstance() throws Exception { ViewInstanceEntity viewInstanceEntity = ViewInstanceEntityTest.getViewInstanceEntity(); final WebAppContext handler = createNiceMock(WebAppContext.class); Server server = createNiceMock(Server.class); expect(handler.getServer()).andReturn(server); handler.setServer(null); replay(handler, server); AmbariHandlerList handlerList = getAmbariHandlerList(handler); handlerList.addViewInstance(viewInstanceEntity); ArrayList<Handler> handlers = new ArrayList<Handler>(Arrays.asList(handlerList.getHandlers())); Assert.assertTrue(handlers.contains(handler)); handlerList.removeViewInstance(viewInstanceEntity); handlers = new ArrayList<Handler>(Arrays.asList(handlerList.getHandlers())); Assert.assertFalse(handlers.contains(handler)); verify(handler, server); }
@Override public void removeViewInstance(ViewInstanceEntity viewInstanceDefinition) { Handler handler = viewHandlerMap.get(viewInstanceDefinition); if (handler != null) { viewHandlerMap.remove(viewInstanceDefinition); removeHandler(handler); } }
AmbariHandlerList extends HandlerCollection implements ViewInstanceHandlerList { @Override public void removeViewInstance(ViewInstanceEntity viewInstanceDefinition) { Handler handler = viewHandlerMap.get(viewInstanceDefinition); if (handler != null) { viewHandlerMap.remove(viewInstanceDefinition); removeHandler(handler); } } }
AmbariHandlerList extends HandlerCollection implements ViewInstanceHandlerList { @Override public void removeViewInstance(ViewInstanceEntity viewInstanceDefinition) { Handler handler = viewHandlerMap.get(viewInstanceDefinition); if (handler != null) { viewHandlerMap.remove(viewInstanceDefinition); removeHandler(handler); } } AmbariHandlerList(); }
AmbariHandlerList extends HandlerCollection implements ViewInstanceHandlerList { @Override public void removeViewInstance(ViewInstanceEntity viewInstanceDefinition) { Handler handler = viewHandlerMap.get(viewInstanceDefinition); if (handler != null) { viewHandlerMap.remove(viewInstanceDefinition); removeHandler(handler); } } AmbariHandlerList(); @Override void handle(String target, Request baseRequest,
                     HttpServletRequest request, HttpServletResponse response); @Override void addHandler(Handler handler); @Override void addViewInstance(ViewInstanceEntity viewInstanceDefinition); @Override void removeViewInstance(ViewInstanceEntity viewInstanceDefinition); }
AmbariHandlerList extends HandlerCollection implements ViewInstanceHandlerList { @Override public void removeViewInstance(ViewInstanceEntity viewInstanceDefinition) { Handler handler = viewHandlerMap.get(viewInstanceDefinition); if (handler != null) { viewHandlerMap.remove(viewInstanceDefinition); removeHandler(handler); } } AmbariHandlerList(); @Override void handle(String target, Request baseRequest,
                     HttpServletRequest request, HttpServletResponse response); @Override void addHandler(Handler handler); @Override void addViewInstance(ViewInstanceEntity viewInstanceDefinition); @Override void removeViewInstance(ViewInstanceEntity viewInstanceDefinition);  }