### Question:
XSUserInfoAdapter implements XSUserInfo { @Override public String getLogonName() { checkNotGrantTypeClientCredentials("getLogonName"); return getClaimValue(USER_NAME); } XSUserInfoAdapter(Object accessToken);  XSUserInfoAdapter(AccessToken accessToken);   XSUserInfoAdapter(Object accessToken, OAuth2ServiceConfiguration configuration); @Override String getLogonName(); @Override String getGivenName(); @Override String getFamilyName(); @Override String getOrigin(); @Override String getIdentityZone(); @Override /** * "ext_attr": { "enhancer": "XSUAA", "subaccountid": "my-subaccount-1234" }, */ String getSubaccountId(); @Override String getZoneId(); @Override /** * "ext_attr": { "enhancer": "XSUAA", "zdn": "paas-subdomain" }, */ String getSubdomain(); @Override String getClientId(); @Override String getJsonValue(String attribute); @Override String getEmail(); @Override String getDBToken(); @Override String getHdbToken(); @Override String getAppToken(); @Override String getToken(String namespace, String name); @Override String[] getAttribute(String attributeName); @Override boolean hasAttributes(); @Override String[] getSystemAttribute(String attributeName); @Override boolean checkScope(String scope); @Override boolean checkLocalScope(String scope); @Override String getAdditionalAuthAttribute(String attributeName); @Override String getCloneServiceInstanceId(); @Override String getGrantType(); @Override boolean isInForeignMode(); @Override String requestTokenForClient(String clientId, String clientSecret, String baseUaaUrl); @Override String requestTokenForUser(String clientId, String clientSecret, String baseUaaUrl); @Override String requestToken(XSTokenRequest tokenRequest);  }### Answer:
@Test public void constructors() throws XSUserInfoException { assertThat(new XSUserInfoAdapter((Object) token).getLogonName()).isEqualTo("TestUser"); assertThat(new XSUserInfoAdapter((Token) token).getLogonName()).isEqualTo("TestUser"); assertThat(new XSUserInfoAdapter((AccessToken) token).getLogonName()).isEqualTo("TestUser"); assertThatThrownBy(() -> new XSUserInfoAdapter(null)).isInstanceOf(XSUserInfoException.class) .hasMessageContaining("null") .hasMessageContaining("instance of AccessToken"); assertThatThrownBy(() -> new XSUserInfoAdapter("Tester")).isInstanceOf(XSUserInfoException.class) .hasMessageContaining("String") .hasMessageContaining("instance of AccessToken"); }
@Test public void testGetLogonName() throws XSUserInfoException { assertThat(cut.getLogonName()).isEqualTo("TestUser"); }
@Test public void testGetLogonName_grantTypeClientCredentials_throwsException() throws XSUserInfoException { cut = new XSUserInfoAdapter(createMockToken(GrantType.CLIENT_CREDENTIALS)); assertThatThrownBy(() -> cut.getLogonName()).isInstanceOf(XSUserInfoException.class) .hasMessageContaining("getLogonName") .hasMessageContaining(GrantType.CLIENT_CREDENTIALS.toString()); }