Source:
<code>public void testNullOrEmptyTokenMapping() throws Exception { { UserResource userResource = findUserByUsernameId(adminClient.realm("test"), "test-user@localhost"); UserRepresentation user = userResource.toRepresentation(); user.singleAttribute("empty", ""); user.singleAttribute("null", null); userResource.update(user); ClientResource app = findClientResourceByClientId(adminClient.realm("test"), "test-app"); app.getProtocolMappers().createMapper(createClaimMapper("empty", "empty", "empty", "String", true, "", true, true, false)).close(); app.getProtocolMappers().createMapper(createClaimMapper("null", "null", "null", "String", true, "", true, true, false)).close(); } { OAuthClient.AccessTokenResponse response = browserLogin("password", "test-user@localhost", "password"); IDToken idToken = oauth.verifyIDToken(response.getIdToken()); Object empty = idToken.getOtherClaims().get("empty"); <START> assertThat((empty == null ? null : (String) empty), isEmptyOrNullString()); <END> Object nulll = idToken.getOtherClaims().get("null"); assertThat((nulll == null ? null : (String) nulll), isEmptyOrNullString()); AccessToken accessToken = oauth.verifyToken(response.getAccessToken()); oauth.openLogout(); } { ClientResource app = findClientByClientId(adminClient.realm("test"), "test-app"); ClientRepresentation clientRepresentation = app.toRepresentation(); for (ProtocolMapperRepresentation model : clientRepresentation.getProtocolMappers()) { if (model.getName().equals("empty") || model.getName().equals("null") ) { app.getProtocolMappers().delete(model.getId()); } } } events.clear(); { OAuthClient.AccessTokenResponse response = browserLogin("password", "test-user@localhost", "password"); IDToken idToken = oauth.verifyIDToken(response.getIdToken()); assertNull(idToken.getAddress()); assertNull(idToken.getOtherClaims().get("empty")); assertNull(idToken.getOtherClaims().get("null")); oauth.openLogout(); } events.clear(); }</code><technical_language>isEmptyOrNullString? empty string</technical_language>

Target:
public void testNullOrEmptyTokenMapping() throws Exception { { UserResource userResource = findUserByUsernameId(adminClient.realm("test"), "test-user@localhost"); UserRepresentation user = userResource.toRepresentation(); user.singleAttribute("empty", ""); user.singleAttribute("null", null); userResource.update(user); ClientResource app = findClientResourceByClientId(adminClient.realm("test"), "test-app"); app.getProtocolMappers().createMapper(createClaimMapper("empty", "empty", "empty", "String", true, "", true, true, false)).close(); app.getProtocolMappers().createMapper(createClaimMapper("null", "null", "null", "String", true, "", true, true, false)).close(); } { OAuthClient.AccessTokenResponse response = browserLogin("password", "test-user@localhost", "password"); IDToken idToken = oauth.verifyIDToken(response.getIdToken()); Object empty = idToken.getOtherClaims().get("empty"); assertThat((empty == null ? null : (String) empty), isEmptyString()); Object nulll = idToken.getOtherClaims().get("null"); assertNull(nulll); AccessToken accessToken = oauth.verifyToken(response.getAccessToken()); oauth.openLogout(); } { ClientResource app = findClientByClientId(adminClient.realm("test"), "test-app"); ClientRepresentation clientRepresentation = app.toRepresentation(); for (ProtocolMapperRepresentation model : clientRepresentation.getProtocolMappers()) { if (model.getName().equals("empty") || model.getName().equals("null") ) { app.getProtocolMappers().delete(model.getId()); } } } events.clear(); { OAuthClient.AccessTokenResponse response = browserLogin("password", "test-user@localhost", "password"); IDToken idToken = oauth.verifyIDToken(response.getIdToken()); assertNull(idToken.getAddress()); assertNull(idToken.getOtherClaims().get("empty")); assertNull(idToken.getOtherClaims().get("null")); oauth.openLogout(); } events.clear(); }