### Question:
ClientFacesViewStateHandler implements FacesViewStateHandler { public ViewArtifact read(HttpServletRequest request) throws IOException { String id = request.getParameter(ID); if (id == null) { return null; } id = decrypt(request, id); return new ViewArtifact(id); }  void write(FacesContext facesContext, ViewArtifact viewState); ViewArtifact read(HttpServletRequest request);  }### Answer:
@Test public void shouldRead() throws Exception { String value = writeAndGetValue(this.viewState); given(this.request.getParameter("org.springframework.springfaces.id")).willReturn(value); ViewArtifact read = this.handler.read(this.request); assertThat(read, is(equalTo(this.viewState))); }
@Test public void shouldVerifyMac() throws Exception { String value = writeAndGetValue(this.viewState); value = new StringBuilder(value).reverse().toString(); given(this.request.getParameter("org.springframework.springfaces.id")).willReturn(value); this.thrown.expect(IllegalStateException.class); this.thrown.expectMessage("Unable to decrypt input value"); this.handler.read(this.request); }
@Test public void shouldEncryptPerSessionKey() throws Exception { String value = writeAndGetValue(this.viewState); this.session = new MockHttpSession(); value = new StringBuilder(value).reverse().toString(); given(this.request.getParameter("org.springframework.springfaces.id")).willReturn(value); this.thrown.expect(IllegalStateException.class); this.thrown.expectMessage("Unable to decrypt input value"); this.handler.read(this.request); }