### Question:
XsuaaToken extends Jwt implements Token { @Override public String getUsername() { if (OAuth2TokenServiceConstants.GRANT_TYPE_CLIENT_CREDENTIALS.equals(getGrantType()) || OAuth2TokenServiceConstants.GRANT_TYPE_CLIENT_X509.equalsIgnoreCase(getGrantType())) { return String.format(UNIQUE_CLIENT_NAME_FORMAT, getClientId()); } else { return getUniquePrincipalName(getOrigin(), getLogonName()); } } protected  XsuaaToken(Jwt jwt); @Override Collection<? extends GrantedAuthority> getAuthorities(); @Override Date getExpirationDate(); @Override Instant getExpiration(); @Override String getPassword(); @Override String getUsername(); @Override boolean isAccountNonExpired(); @Override boolean isAccountNonLocked(); @Override boolean isCredentialsNonExpired(); @Override boolean isEnabled(); @Nullable static String getUniquePrincipalName(String origin, String userLoginName); @Override @Nullable String getLogonName(); @Override @Nullable String getClientId(); @Override String getGivenName(); @Override @Nullable String getFamilyName(); @Override String getEmail(); @Override String getOrigin(); @Override String getGrantType(); @Override String getSubaccountId(); @Override String getZoneId(); @Override String getSubdomain(); @Override String toString(); @Nullable @Override String[] getXSUserAttribute(String attributeName); @Override String getAdditionalAuthAttribute(String attributeName); @Override String getCloneServiceInstanceId(); @Override String getAppToken(); @Override Collection<String> getScopes(); boolean hasClaim(String claim);  }### Answer:
@Test public void getUserNameIsUniqueWithOrigin() { token = createToken(claimsSetBuilder); assertThat(token.getUsername(), is("user/userIdp/testUser")); }
@Test public void getUserNameReturnsErrorWhenOriginContainsDelimeter() { claimsSetBuilder.claim(TokenClaims.CLAIM_ORIGIN, "my/Idp"); token = createToken(claimsSetBuilder); assertNull(token.getUsername()); }
@Test public void getPrincipalNameReturnUniqueLogonNameWithOrigin() { Token token = new XsuaaToken(jwtSaml); UserDetails principal = token; Assert.assertEquals("user/useridp/Mustermann", principal.getUsername()); }