public void verifyState(HttpRequest request, HttpResponse response, OAuth2IdentityProvider provider) {
    verifyState(request, response, provider, DEFAULT_STATE_PARAMETER_NAME);
  }
@Test
  public void verify_state() {
    String state = "state";
    when(request.getCookies()).thenReturn(new Cookie[]{wrapCookie("OAUTHSTATE", sha256Hex(state))});
    when(request.getParameter("aStateParameter")).thenReturn(state);

    underTest.verifyState(request, response, identityProvider, "aStateParameter");

    verify(response).addCookie(cookieArgumentCaptor.capture());
    Cookie updatedCookie = cookieArgumentCaptor.getValue();
    assertThat(updatedCookie.getName()).isEqualTo("OAUTHSTATE");
    assertThat(updatedCookie.getValue()).isNull();
    assertThat(updatedCookie.getPath()).isEqualTo("/");
    assertThat(updatedCookie.getMaxAge()).isZero();
  }