### Question:
TokenService { public TokenDetails getTokenDetails() { TokenDetails tokenDetails = usersTokenService.retrieveUsersTokenDetails(); if (tokenDetails.isNotEmpty()) { logger.debug("return user's token details: {}", tokenDetails); return tokenDetails; } tokenDetails = applicationTokenService.getApplicationTokenDetails(); if (tokenDetails.isEmpty()) { logger.warn("return empty token details"); } return tokenDetails; } @Autowired  TokenService(UsersTokenService usersTokenService,
                        ApplicationTokenService applicationTokenService,
                        OAuthClient oAuthClient); TokenDetails getTokenDetails(); TokenDetails getTokenByRefreshToken(String refreshToken);  }### Answer:
@Test void getApplicationTokenDetails() { TokenDetails tokenDetails = new TokenDetails(); when(usersTokenService.retrieveUsersTokenDetails()).thenReturn(tokenDetails); TokenDetails applicationTokenDetails = new TokenDetails("accessToken444", "refreshToken4", LocalDateTime.now()); when(applicationTokenService.getApplicationTokenDetails()).thenReturn(applicationTokenDetails); assertEquals(service.getTokenDetails(), applicationTokenDetails); }
@Test void getUserTokenDetails() { TokenDetails userTokenDetails = new TokenDetails("accessToken5", "refreshToken555", LocalDateTime.now()); when(usersTokenService.retrieveUsersTokenDetails()).thenReturn(userTokenDetails); assertEquals(service.getTokenDetails(), userTokenDetails); }