CompletableFuture<CreatePayPalOneTimePaymentMutation.CreatePayPalOneTimePayment> createPayPalOneTimePayment(
      final BigDecimal amount, final String currency, final String returnUrl,
      final String cancelUrl, final String locale) {

    final CreatePayPalOneTimePaymentInput input = buildCreatePayPalOneTimePaymentInput(amount, currency, returnUrl,
        cancelUrl, locale);
    final CreatePayPalOneTimePaymentMutation mutation = new CreatePayPalOneTimePaymentMutation(input);
    final HttpRequest request = buildRequest(mutation);

    return httpClient.sendAsync(request, HttpResponse.BodyHandlers.ofString())
        .thenApply(httpResponse ->
        {
          // IntelliJ users: type parameters error “no instance of type variable exists so that Data conforms to Data”
          // is not accurate; this might be fixed in Kotlin 1.8: https://youtrack.jetbrains.com/issue/KTIJ-21905/
          final CreatePayPalOneTimePaymentMutation.Data data = assertSuccessAndExtractData(httpResponse, mutation);
          return data.createPayPalOneTimePayment;
        });
  }
@Test
  void createPayPalOneTimePayment() {

    final HttpResponse<Object> response = mock(HttpResponse.class);
    when(httpClient.sendAsync(any(), any()))
        .thenReturn(CompletableFuture.completedFuture(response));

    final String paymentId = "PAYID-AAA1AAAA1A11111AA111111A";
    when(response.body())
        .thenReturn(createPayPalOneTimePaymentResponse(paymentId));
    when(response.statusCode())
        .thenReturn(200);

    final CompletableFuture<CreatePayPalOneTimePaymentMutation.CreatePayPalOneTimePayment> future = braintreeGraphqlClient.createPayPalOneTimePayment(
        BigDecimal.ONE, CURRENCY,
        RETURN_URL, CANCEL_URL, LOCALE);

    assertTimeoutPreemptively(Duration.ofSeconds(3), () -> {
      final CreatePayPalOneTimePaymentMutation.CreatePayPalOneTimePayment result = future.get();

      assertEquals(paymentId, result.paymentId);
      assertNotNull(result.approvalUrl);
    });
  }