### Question:
DefaultSpringFacesContext extends SpringFacesContext { @Override public Object getController() { Object controller = getHandler(); if ((controller != null) && (controller instanceof HandlerMethod)) { controller = ((HandlerMethod) controller).createWithResolvedBean().getBean(); } return controller; } DefaultSpringFacesContext(LifecycleAccessor lifecycleAccessor, WebApplicationContext webApplicationContext,
			HttpServletRequest request, HttpServletResponse response, Object handler); void release(); @Override Object getHandler(); @Override Object getController(); @Override FacesContext getFacesContext(); @Override WebApplicationContext getWebApplicationContext(); @Override void render(View view, Map<String, Object> model); @Override ModelAndViewArtifact getRendering();  }### Answer:
@Test public void shouldGetControllerIfNotHandlerMethod() throws Exception { assertThat(this.springFacesContext.getController(), is(sameInstance(this.handler))); }
@Test public void shouldGetControllerIfHandlerMethod() throws Exception { Object controller = mock(Object.class, "controller"); HandlerMethod handlerMethod = mock(HandlerMethod.class, "handler"); this.springFacesContext = new DefaultSpringFacesContext(this.lifecycleAccessor, this.webApplicationContext, this.request, this.response, handlerMethod); given(handlerMethod.createWithResolvedBean()).willReturn(handlerMethod); given(handlerMethod.getBean()).willReturn(controller); assertThat(this.springFacesContext.getController(), is(sameInstance(controller))); }