com.github.robozonky.integrations.zonkoid.ZonkoidConfirmationProvider.getRequest()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(2.5k)|赞(0)|评价(0)|浏览(82)

本文整理了Java中com.github.robozonky.integrations.zonkoid.ZonkoidConfirmationProvider.getRequest()方法的一些代码示例,展示了ZonkoidConfirmationProvider.getRequest()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZonkoidConfirmationProvider.getRequest()方法的具体详情如下:
包路径:com.github.robozonky.integrations.zonkoid.ZonkoidConfirmationProvider
类名称:ZonkoidConfirmationProvider
方法名:getRequest

ZonkoidConfirmationProvider.getRequest介绍

暂无

代码示例

代码示例来源:origin: com.github.robozonky/robozonky-integration-zonkoid

private static boolean requestConfirmation(final RequestId requestId, final int loanId, final int amount,
                      final String rootUrl, final String protocol) {
  return Try.withResources(HttpClients::createDefault)
      .of(httpClient -> {
        LOGGER.debug("Requesting notification of {} CZK for loan #{}.", amount, loanId);
        final HttpPost post = getRequest(requestId, loanId, amount, protocol, rootUrl);
        return httpClient.execute(post, ZonkoidConfirmationProvider::respond);
      })
      .getOrElseGet(t -> handleError(requestId, loanId, amount, rootUrl, protocol, t));
}

代码示例来源:origin: RoboZonky/robozonky

private static boolean requestConfirmation(final RequestId requestId, final int loanId, final int amount,
                      final String rootUrl, final String protocol) {
  return Try.withResources(HttpClients::createDefault)
      .of(httpClient -> {
        LOGGER.debug("Requesting notification of {} CZK for loan #{}.", amount, loanId);
        final HttpPost post = getRequest(requestId, loanId, amount, protocol, rootUrl);
        return httpClient.execute(post, ZonkoidConfirmationProvider::respond);
      })
      .getOrElseGet(t -> handleError(requestId, loanId, amount, rootUrl, protocol, t));
}

代码示例来源:origin: RoboZonky/robozonky

@Test
void properHttpPost() throws UnsupportedEncodingException {
  final int loanId = 1;
  final RequestId r = new RequestId("user@somewhere.cz", "apitest".toCharArray());
  final HttpPost post = ZonkoidConfirmationProvider.getRequest(r, loanId, 200, "https", "somewhere");
  SoftAssertions.assertSoftly(softly -> {
    softly.assertThat(post.getFirstHeader("Accept").getValue()).isEqualTo("text/plain");
    softly.assertThat(post.getFirstHeader("Authorization").getValue())
        .isNotEmpty()
        .isEqualTo(ZonkoidConfirmationProvider.getAuthenticationString(r, loanId));
    softly.assertThat(post.getFirstHeader("Content-Type").getValue()).isEqualTo(
        "application/x-www-form-urlencoded");
    softly.assertThat(post.getEntity()).isInstanceOf(UrlEncodedFormEntity.class);
    softly.assertThat(post.getFirstHeader("User-Agent").getValue()).isEqualTo(Defaults.ROBOZONKY_USER_AGENT);
  });
}

相关文章