@Test public void testVerifyToken() { LineApiResponse<AccessTokenVerificationResult> expectedResponse = LineApiResponse.createAsSuccess(new AccessTokenVerificationResult( "1234", 3L, Arrays.asList(Scope.FRIEND, Scope.GROUP))); doReturn(expectedResponse) .when(internalOauthApiClient) .verifyAccessToken(any(InternalAccessToken.class)); accessTokenCache.saveAccessToken(ACCESS_TOKEN); LineApiResponse<LineCredential> actualResponse = target.verifyToken(); assertTrue(actualResponse.isSuccess()); verify(internalOauthApiClient, times(1)).verifyAccessToken(ACCESS_TOKEN); LineAccessToken verifiedAccessToken = actualResponse.getResponseData().getAccessToken(); assertEquals(ACCESS_TOKEN.getAccessToken(), verifiedAccessToken.getTokenString()); assertEquals(3L, verifiedAccessToken.getExpiresInMillis()); assertTrue(ACCESS_TOKEN.getIssuedClientTimeMillis() != verifiedAccessToken.getIssuedClientTimeMillis()); assertEquals(3L, verifiedAccessToken.getExpiresInMillis()); assertEquals(Arrays.asList(Scope.FRIEND, Scope.GROUP), actualResponse.getResponseData().getScopes()); InternalAccessToken newAccessToken = accessTokenCache.getAccessToken(); assertEquals(ACCESS_TOKEN.getAccessToken(), newAccessToken.getAccessToken()); assertEquals(3L, newAccessToken.getExpiresInMillis()); assertTrue(newAccessToken.getIssuedClientTimeMillis() != ACCESS_TOKEN.getIssuedClientTimeMillis()); assertEquals(ACCESS_TOKEN.getRefreshToken(), newAccessToken.getRefreshToken()); }
@Override @NonNull public LineApiResponse<LineCredential> verifyToken() { return callWithAccessToken(this::verifyToken); }
LineApiClientImpl implements LineApiClient { @Override @NonNull public LineApiResponse<LineCredential> verifyToken() { return callWithAccessToken(this::verifyToken); } }
LineApiClientImpl implements LineApiClient { @Override @NonNull public LineApiResponse<LineCredential> verifyToken() { return callWithAccessToken(this::verifyToken); } LineApiClientImpl(
            @NonNull String channelId,
            @NonNull LineAuthenticationApiClient oauthApiClient,
            @NonNull TalkApiClient talkApiClient,
            @NonNull AccessTokenCache accessTokenCache); }
LineApiClientImpl implements LineApiClient { @Override @NonNull public LineApiResponse<LineCredential> verifyToken() { return callWithAccessToken(this::verifyToken); } LineApiClientImpl(
            @NonNull String channelId,
            @NonNull LineAuthenticationApiClient oauthApiClient,
            @NonNull TalkApiClient talkApiClient,
            @NonNull AccessTokenCache accessTokenCache); @Override @NonNull LineApiResponse<?> logout(); @Override @NonNull LineApiResponse<LineAccessToken> refreshAccessToken(); @Override @NonNull LineApiResponse<LineCredential> verifyToken(); @Override @NonNull LineApiResponse<LineAccessToken> getCurrentAccessToken(); @Override @TokenAutoRefresh @NonNull LineApiResponse<LineProfile> getProfile(); @Override @TokenAutoRefresh @NonNull LineApiResponse<LineFriendshipStatus> getFriendshipStatus(); @Override @TokenAutoRefresh @NonNull LineApiResponse<GetFriendsResponse> getFriends(
            @NonNull FriendSortField sort,
            @Nullable String nextPageRequestToken); @Override @TokenAutoRefresh @NonNull LineApiResponse<GetFriendsResponse> getFriends(
            @NonNull FriendSortField sort,
            @Nullable String nextPageRequestToken,
            boolean isForOttShareMessage); @Override @TokenAutoRefresh @NonNull LineApiResponse<GetFriendsResponse> getFriendsApprovers(
            FriendSortField sort,
            @Nullable String nextPageRequestToken); @Override @TokenAutoRefresh @NonNull LineApiResponse<GetGroupsResponse> getGroups(@Nullable String nextPageRequestToken); @Override @TokenAutoRefresh @NonNull LineApiResponse<GetGroupsResponse> getGroups(
            @Nullable String nextPageRequestToken,
            boolean isForOttShareMessage); @Override @TokenAutoRefresh @NonNull LineApiResponse<GetFriendsResponse> getGroupApprovers(
            @NonNull String groupId,
            @Nullable String nextPageRequestToken); @Override @TokenAutoRefresh @NonNull LineApiResponse<String> sendMessage(
            @NonNull String targetUserId,
            @NonNull List<MessageData> messages); @Override @TokenAutoRefresh @NonNull LineApiResponse<List<SendMessageResponse>> sendMessageToMultipleUsers(
            @NonNull List<String> targetUserIds,
            @NonNull List<MessageData> messages); @Override @TokenAutoRefresh @NonNull LineApiResponse<List<SendMessageResponse>> sendMessageToMultipleUsers(
            @NonNull List<String> targetUserIds,
            @NonNull List<MessageData> messages,
            boolean isOttUsed); @NonNull LineApiResponse<Boolean> getOpenChatAgreementStatus(); @NonNull LineApiResponse<OpenChatRoomInfo> createOpenChatRoom(@NonNull OpenChatParameters openChatParameters); @NonNull LineApiResponse<Boolean> joinOpenChatRoom(@NonNull String roomId, @NonNull String displayName); @NonNull LineApiResponse<OpenChatRoomStatus> getOpenChatRoomStatus(@NonNull String roomId); @NonNull LineApiResponse<MembershipStatus> getOpenChatMembershipStatus(@NonNull String roomId); @NonNull LineApiResponse<OpenChatRoomJoinType> getOpenChatRoomJoinType(@NonNull String roomId); }
LineApiClientImpl implements LineApiClient { @Override @NonNull public LineApiResponse<LineCredential> verifyToken() { return callWithAccessToken(this::verifyToken); } LineApiClientImpl(
            @NonNull String channelId,
            @NonNull LineAuthenticationApiClient oauthApiClient,
            @NonNull TalkApiClient talkApiClient,
            @NonNull AccessTokenCache accessTokenCache); @Override @NonNull LineApiResponse<?> logout(); @Override @NonNull LineApiResponse<LineAccessToken> refreshAccessToken(); @Override @NonNull LineApiResponse<LineCredential> verifyToken(); @Override @NonNull LineApiResponse<LineAccessToken> getCurrentAccessToken(); @Override @TokenAutoRefresh @NonNull LineApiResponse<LineProfile> getProfile(); @Override @TokenAutoRefresh @NonNull LineApiResponse<LineFriendshipStatus> getFriendshipStatus(); @Override @TokenAutoRefresh @NonNull LineApiResponse<GetFriendsResponse> getFriends(
            @NonNull FriendSortField sort,
            @Nullable String nextPageRequestToken); @Override @TokenAutoRefresh @NonNull LineApiResponse<GetFriendsResponse> getFriends(
            @NonNull FriendSortField sort,
            @Nullable String nextPageRequestToken,
            boolean isForOttShareMessage); @Override @TokenAutoRefresh @NonNull LineApiResponse<GetFriendsResponse> getFriendsApprovers(
            FriendSortField sort,
            @Nullable String nextPageRequestToken); @Override @TokenAutoRefresh @NonNull LineApiResponse<GetGroupsResponse> getGroups(@Nullable String nextPageRequestToken); @Override @TokenAutoRefresh @NonNull LineApiResponse<GetGroupsResponse> getGroups(
            @Nullable String nextPageRequestToken,
            boolean isForOttShareMessage); @Override @TokenAutoRefresh @NonNull LineApiResponse<GetFriendsResponse> getGroupApprovers(
            @NonNull String groupId,
            @Nullable String nextPageRequestToken); @Override @TokenAutoRefresh @NonNull LineApiResponse<String> sendMessage(
            @NonNull String targetUserId,
            @NonNull List<MessageData> messages); @Override @TokenAutoRefresh @NonNull LineApiResponse<List<SendMessageResponse>> sendMessageToMultipleUsers(
            @NonNull List<String> targetUserIds,
            @NonNull List<MessageData> messages); @Override @TokenAutoRefresh @NonNull LineApiResponse<List<SendMessageResponse>> sendMessageToMultipleUsers(
            @NonNull List<String> targetUserIds,
            @NonNull List<MessageData> messages,
            boolean isOttUsed); @NonNull LineApiResponse<Boolean> getOpenChatAgreementStatus(); @NonNull LineApiResponse<OpenChatRoomInfo> createOpenChatRoom(@NonNull OpenChatParameters openChatParameters); @NonNull LineApiResponse<Boolean> joinOpenChatRoom(@NonNull String roomId, @NonNull String displayName); @NonNull LineApiResponse<OpenChatRoomStatus> getOpenChatRoomStatus(@NonNull String roomId); @NonNull LineApiResponse<MembershipStatus> getOpenChatMembershipStatus(@NonNull String roomId); @NonNull LineApiResponse<OpenChatRoomJoinType> getOpenChatRoomJoinType(@NonNull String roomId);  }