OAuth { public ZonkyApiToken refresh(final ZonkyApiToken token) { return api.call(a -> a.refresh(toString(token.getRefreshToken()), REFRESH_TOKEN_STRING)); } OAuth(final Api<ZonkyOAuthApi> api); ZonkyApiToken login(final char[] code); ZonkyApiToken refresh(final ZonkyApiToken token);  }
@Test void refresh() { final String originalTokenId = UUID.randomUUID() .toString(); final ZonkyApiToken originToken = new ZonkyApiTokenImpl(UUID.randomUUID() .toString(), originalTokenId, OffsetDateTime.now()); final ZonkyApiTokenImpl resultToken = mock(ZonkyApiTokenImpl.class); final ZonkyOAuthApi api = mock(ZonkyOAuthApi.class); when(api.refresh(eq(originalTokenId), anyString())).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); }