### Question:
TokenAuthenticationServiceImpl implements TokenAuthenticationService { @Override public UserAuthentication getAuthentication(String accessToken) { if (StringUtils.isBlank(accessToken)) { return null; } BearerTokenTO bearerToken = null; try { authInterceptor.setAccessToken(accessToken); ResponseEntity<BearerTokenTO> responseEntity = ledgersUserMgmt.validate(accessToken); if (responseEntity.getStatusCode() == HttpStatus.OK) { bearerToken = responseEntity.getBody(); } } finally { authInterceptor.setAccessToken(null); } if (bearerToken == null) { debug("Token is not valid."); return null; } return new UserAuthentication(bearerToken); }  @Override UserAuthentication getAuthentication(String accessToken);  }### Answer:
@Test void getAuthentication() { when(ledgersUserMgmt.validate(anyString())).thenReturn(ResponseEntity.ok(getBearer())); UserAuthentication result = service.getAuthentication(TOKEN); assertThat(result).isEqualTo(new UserAuthentication(getBearer())); }
@Test void getAuthentication_null_bearer() { when(ledgersUserMgmt.validate(anyString())).thenReturn(ResponseEntity.ok(null)); UserAuthentication result = service.getAuthentication(TOKEN); assertNull(result); }
@Test void getAuthentication_null_token() { UserAuthentication result = service.getAuthentication(null); assertThat(result).isEqualTo(null); }