com.github.robozonky.api.remote.entities.ZonkyApiToken.<init>()方法的使用及代码示例

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

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

ZonkyApiToken.<init>介绍

暂无

代码示例

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

private static ZonkyApiToken getTokenExpiringIn(final Duration duration) {
  return new ZonkyApiToken(UUID.randomUUID().toString(), UUID.randomUUID().toString(),
               OffsetDateTime.ofInstant(DateUtil.now().minus(Duration.ofMinutes(5)).plus(duration),
                           Defaults.ZONE_ID));
}

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

@Test
  void refresh() {
    final String originalTokenId = UUID.randomUUID().toString();
    final ZonkyApiToken originToken = new ZonkyApiToken(UUID.randomUUID().toString(), originalTokenId,
                              OffsetDateTime.now());
    final ZonkyApiToken resultToken = mock(ZonkyApiToken.class);
    final ZonkyOAuthApi api = mock(ZonkyOAuthApi.class);
    when(api.refresh(eq(originalTokenId), anyString(), any())).thenReturn(resultToken);
    final Api<ZonkyOAuthApi> wrapper = new Api<>(api);
    final OAuth oauth = new OAuth(wrapper);
    final ZonkyApiToken returnedToken = oauth.refresh(originToken);
    assertThat(returnedToken).isEqualTo(resultToken);
  }
}

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

@Test
  void changes400to401() throws IOException {
    final int expectedCode = 400;
    final ClientRequestContext ctx = mock(ClientRequestContext.class);
    final ClientResponseContext ctx2 = mock(ClientResponseContext.class);
    final ZonkyApiToken token = new ZonkyApiToken("", "", 299);
    when(ctx2.hasEntity()).thenReturn(true);
    when(ctx2.getHeaders()).thenReturn(new MultivaluedMapImpl<>());
    when(ctx2.getEntityStream()).thenReturn(c(token));
    when(ctx2.getStatusInfo()).thenReturn(Response.Status.fromStatusCode(expectedCode));
    when(ctx2.getStatus()).thenReturn(expectedCode);
    final RoboZonkyFilter filter = new AuthenticatedFilter(() -> token);
    filter.filter(ctx, ctx2);
    verify(ctx2, times(1)).setStatus(401);
  }
}

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

@Test
void fresh() {
  final ZonkyApiToken token = new ZonkyApiToken();
  assertThat(token.getObtainedOn()).isBeforeOrEqualTo(OffsetDateTime.now());
}

相关文章