### Question:
HtmlResponseStateManager extends MyfacesResponseStateManager { @Override public boolean isPostback(FacesContext context) { return context.getExternalContext().getRequestParameterMap().containsKey(ResponseStateManager.VIEW_STATE_PARAM); } HtmlResponseStateManager(); @Override void writeState(FacesContext facesContext, Object state); @Override void saveState(FacesContext facesContext, Object state); @Override Object getState(FacesContext facesContext, String viewId); @Override boolean isPostback(FacesContext context); @Override String getViewState(FacesContext facesContext, Object baseState); @Override boolean isStateless(FacesContext context, String viewId); @Override String getCryptographicallyStrongTokenFromSession(FacesContext context); @Override boolean isWriteStateAfterRenderViewRequired(FacesContext facesContext); static String generateUpdateClientWindowId(FacesContext facesContext); static String generateUpdateViewStateId(FacesContext facesContext);  }### Answer:
@Test public void testIsPostback() { Mockito.when(_facesContext.getExternalContext()).thenReturn(_externalContext); Mockito.when(_externalContext.getApplicationMap()).thenReturn(new ConcurrentHashMap<>()); HtmlResponseStateManager hrsm = Mockito.spy(HtmlResponseStateManager.class); Map<String, String> map = new HashMap<>(); map.put(ResponseStateManager.VIEW_STATE_PARAM, "seomthing"); Mockito.when(_externalContext.getRequestParameterMap()).thenReturn(map); Assert.assertEquals(true, hrsm.isPostback(_facesContext)); }
@Test public void testIsNoPostback() { Mockito.when(_facesContext.getExternalContext()).thenReturn(_externalContext); Mockito.when(_externalContext.getApplicationMap()).thenReturn(new ConcurrentHashMap<>()); Mockito.when(_externalContext.getRequestParameterMap()).thenReturn(new HashMap<>()); HtmlResponseStateManager hrsm = Mockito.spy(HtmlResponseStateManager.class); Assert.assertEquals(false, hrsm.isPostback(_facesContext)); }