### Question:
TokenService { @PreAuthorize("hasAuthority('VIEW_KEYS')") public TokenInfo getToken(String id) throws TokenNotFoundException { try { return signerProxyFacade.getToken(id); } catch (CodedException e) { if (isCausedByTokenNotFound(e)) { throw new TokenNotFoundException(e); } else { throw e; } } catch (Exception other) { throw new RuntimeException("get token failed", other); } } @Autowired  TokenService(SignerProxyFacade signerProxyFacade); @PreAuthorize("hasAuthority('VIEW_KEYS')") List<TokenInfo> getAllTokens(); @PreAuthorize("hasAuthority('VIEW_CLIENT_DETAILS')") List<CertificateInfo> getSignCertificates(ClientType clientType); @PreAuthorize("hasAuthority('VIEW_CLIENT_DETAILS')") List<CertificateInfo> getAllCertificates(ClientType clientType); @PreAuthorize("hasAuthority('ACTIVATE_TOKEN')") void activateToken(String id, char[] password); @PreAuthorize("hasAuthority('DEACTIVATE_TOKEN')") void deactivateToken(String id); @PreAuthorize("hasAuthority('VIEW_KEYS')") TokenInfo getToken(String id);  }### Answer:
@Test @WithMockUser(authorities = { "VIEW_KEYS" }) public void getToken() throws Exception { TokenInfo tokenInfo; try { tokenInfo = tokenService.getToken(TOKEN_NOT_FOUND_TOKEN_ID); } catch (TokenService.TokenNotFoundException expected) { } tokenInfo = tokenService.getToken(GOOD_TOKEN_ID); assertEquals("good-token", tokenInfo.getFriendlyName()); }