@Test
 public void testToUri_noCodeVerifier() throws Exception {
   AuthorizationRequest req = mRequestBuilder.setCodeVerifier(null).build();
   assertThat(req.toUri().getQueryParameterNames())
       .doesNotContain(AuthorizationRequest.PARAM_CODE_CHALLENGE)
       .doesNotContain(AuthorizationRequest.PARAM_CODE_CHALLENGE_METHOD);
 }
  @Test
  public void testToUri() throws Exception {
    AuthorizationRequest request = mRequestBuilder.build();
    Uri uri = request.toUri();
    assertThat(uri.getQueryParameterNames())
        .isEqualTo(
            new HashSet<>(
                Arrays.asList(
                    AuthorizationRequest.PARAM_CLIENT_ID,
                    AuthorizationRequest.PARAM_RESPONSE_TYPE,
                    AuthorizationRequest.PARAM_REDIRECT_URI,
                    AuthorizationRequest.PARAM_STATE,
                    AuthorizationRequest.PARAM_CODE_CHALLENGE,
                    AuthorizationRequest.PARAM_CODE_CHALLENGE_METHOD)));

    assertThat(uri.getQueryParameter(AuthorizationRequest.PARAM_CLIENT_ID))
        .isEqualTo(TEST_CLIENT_ID);
    assertThat(uri.getQueryParameter(AuthorizationRequest.PARAM_RESPONSE_TYPE))
        .isEqualTo(ResponseTypeValues.CODE);
    assertThat(uri.getQueryParameter(AuthorizationRequest.PARAM_REDIRECT_URI))
        .isEqualTo(TEST_APP_REDIRECT_URI.toString());
    assertThat(uri.getQueryParameter(AuthorizationRequest.PARAM_STATE)).isEqualTo(request.state);
    assertThat(uri.getQueryParameter(AuthorizationRequest.PARAM_CODE_CHALLENGE))
        .isEqualTo(request.codeVerifierChallenge);
    assertThat(uri.getQueryParameter(AuthorizationRequest.PARAM_CODE_CHALLENGE_METHOD))
        .isEqualTo(request.codeVerifierChallengeMethod);
  }
  @Test
  public void testToUri_additionalParams() throws Exception {
    Map<String, String> additionalParams = new HashMap<>();
    additionalParams.put("my_param", "1234");
    additionalParams.put("another_param", "5678");
    AuthorizationRequest req = mRequestBuilder.setAdditionalParameters(additionalParams).build();

    Uri uri = req.toUri();
    assertThat(uri.getQueryParameter("my_param")).isEqualTo("1234");
    assertThat(uri.getQueryParameter("another_param")).isEqualTo("5678");
  }
 @Test
 public void testToUri_noStateParam() throws Exception {
   AuthorizationRequest req = mRequestBuilder.setState(null).build();
   assertThat(req.toUri().getQueryParameterNames())
       .doesNotContain(AuthorizationRequest.PARAM_STATE);
 }