@Test public void shouldUnderstandEmptyStrings() { Entry entry = new LinkedHashMapEntry(); entry.addAttribute(CoreTokenField.TOKEN_ID.toString(), "id"); entry.addAttribute(CoreTokenField.TOKEN_TYPE.toString(), TokenType.OAUTH.toString()); entry.addAttribute(CoreTokenField.STRING_ONE.toString(), TokenAttributeConversion.EMPTY); TokenAttributeConversion conversion = generateTokenAttributeConversion(); Token result = conversion.tokenFromEntry(entry); String string = result.getValue(CoreTokenField.STRING_ONE); assertTrue(string.isEmpty()); }
public Token tokenFromEntry(Entry entry) { Map<CoreTokenField, Object> map = mapFromEntry(entry); String tokenId = (String) map.get(CoreTokenField.TOKEN_ID); TokenType type = (TokenType) map.get(CoreTokenField.TOKEN_TYPE); Token token = new Token(tokenId, type); for (Map.Entry<CoreTokenField, Object> e : map.entrySet()) { CoreTokenField key = e.getKey(); Object value = e.getValue(); if (Token.isFieldReadOnly(key)) { continue; } token.setAttribute(key, value); } return token; }
TokenAttributeConversion { public Token tokenFromEntry(Entry entry) { Map<CoreTokenField, Object> map = mapFromEntry(entry); String tokenId = (String) map.get(CoreTokenField.TOKEN_ID); TokenType type = (TokenType) map.get(CoreTokenField.TOKEN_TYPE); Token token = new Token(tokenId, type); for (Map.Entry<CoreTokenField, Object> e : map.entrySet()) { CoreTokenField key = e.getKey(); Object value = e.getValue(); if (Token.isFieldReadOnly(key)) { continue; } token.setAttribute(key, value); } return token; } }
TokenAttributeConversion { public Token tokenFromEntry(Entry entry) { Map<CoreTokenField, Object> map = mapFromEntry(entry); String tokenId = (String) map.get(CoreTokenField.TOKEN_ID); TokenType type = (TokenType) map.get(CoreTokenField.TOKEN_TYPE); Token token = new Token(tokenId, type); for (Map.Entry<CoreTokenField, Object> e : map.entrySet()) { CoreTokenField key = e.getKey(); Object value = e.getValue(); if (Token.isFieldReadOnly(key)) { continue; } token.setAttribute(key, value); } return token; } @Inject  TokenAttributeConversion(LDAPConfig constants, LDAPDataConversion conversion); }
TokenAttributeConversion { public Token tokenFromEntry(Entry entry) { Map<CoreTokenField, Object> map = mapFromEntry(entry); String tokenId = (String) map.get(CoreTokenField.TOKEN_ID); TokenType type = (TokenType) map.get(CoreTokenField.TOKEN_TYPE); Token token = new Token(tokenId, type); for (Map.Entry<CoreTokenField, Object> e : map.entrySet()) { CoreTokenField key = e.getKey(); Object value = e.getValue(); if (Token.isFieldReadOnly(key)) { continue; } token.setAttribute(key, value); } return token; } @Inject  TokenAttributeConversion(LDAPConfig constants, LDAPDataConversion conversion); Entry getEntry(Token token); Map<CoreTokenField, Object> mapFromEntry(Entry entry); Token tokenFromEntry(Entry entry); static Entry addObjectClass(Entry entry); static Entry stripObjectClass(Entry entry); DN generateTokenDN(Token token); DN generateTokenDN(String tokenId); }
TokenAttributeConversion { public Token tokenFromEntry(Entry entry) { Map<CoreTokenField, Object> map = mapFromEntry(entry); String tokenId = (String) map.get(CoreTokenField.TOKEN_ID); TokenType type = (TokenType) map.get(CoreTokenField.TOKEN_TYPE); Token token = new Token(tokenId, type); for (Map.Entry<CoreTokenField, Object> e : map.entrySet()) { CoreTokenField key = e.getKey(); Object value = e.getValue(); if (Token.isFieldReadOnly(key)) { continue; } token.setAttribute(key, value); } return token; } @Inject  TokenAttributeConversion(LDAPConfig constants, LDAPDataConversion conversion); Entry getEntry(Token token); Map<CoreTokenField, Object> mapFromEntry(Entry entry); Token tokenFromEntry(Entry entry); static Entry addObjectClass(Entry entry); static Entry stripObjectClass(Entry entry); DN generateTokenDN(Token token); DN generateTokenDN(String tokenId);  }