    @Test
    void getApplicationTokenDetailsAccessTokenIsExpired() {

        onBehalfOfUsernameHolder.removeUser();
        UserKey userKey1 = new UserKey("user1", "realm1");
        onBehalfOfUsernameHolder.putUser(userKey1);

        TokenDetails tokenDetails = new TokenDetails();
        tokenDetails.setAccessToken("access-token123");
        tokenDetails.setRefreshToken("refresh-token123");
        applicationTokenHolder.setTokenDetails(userKey1, tokenDetails);
        when(oAuthClient.obtainTokenDetailsByRunOnBehalfOfUserCredentials(
                userKey1.getLogin(), userKey1.getRealm()))
                .thenReturn(tokenDetails);
        when(oidcAuthenticationHelper.isTokenExpiredOrShouldBeRefreshed(tokenDetails)).thenReturn(true);

        TokenDetails refreshedTokenDetails = new TokenDetails();
        when(oAuthClient.obtainTokenDetailsByRefreshToken(tokenDetails.getRefreshToken()))
                .thenReturn(refreshedTokenDetails);

        TokenDetails applicationTokenDetails = service.getApplicationTokenDetails();
        assertEquals(applicationTokenDetails, refreshedTokenDetails);
    }