public static HttpRequest.Builder buildRefreshRequestUrlForAccessToken(
      TokensAndUrlAuthData authData, AppCredentials appCredentials) throws IllegalStateException {
    BodyPublisher postBody = buildRefreshRequestPostBody(authData, appCredentials);
    URI refreshUri = authData.getTokenServerEncodedUri();
    return HttpRequest.newBuilder()
      .uri(refreshUri)
      .POST(postBody)
      .header("content-type", "application/x-www-form-urlencoded");
  }
@Test
  public void test_buildRefreshRequestUrlForAccessToken() {
    //
    // Arrange
    //
    final String fakeAuthUrl = "https://www.example.com/auth";
    TokensAndUrlAuthData fakeAuthData =
        new TokensAndUrlAuthData("my_access_token", "my_refresh_token", fakeAuthUrl);
    AppCredentials mockAppCredentials = mock(AppCredentials.class);
    when(mockAppCredentials.getKey()).thenReturn("fake-client_id-contents-here");
    when(mockAppCredentials.getSecret()).thenReturn("fake-client_secert-contents-here");

    //
    // Act
    //
    HttpRequest actualRequest =
        TokenRefresher.buildRefreshRequestUrlForAccessToken(fakeAuthData, mockAppCredentials)
            .build();

    //
    // Assert
    //
    assertEquals(actualRequest.method(), "POST");
    assertEquals(actualRequest.uri().toString(), fakeAuthUrl);
    assertFalse(actualRequest.bodyPublisher().isEmpty());
    assertPublishes(
        actualRequest.bodyPublisher().get(),
        "refresh_token=my_refresh_token&grant_type=refresh_token&client_secret=fake-client_secert-contents-here&client_id=fake-client_id-contents-here");
  }