FacebookUserEntity { @JsonIgnore public OAuth2User asGenericUser() { HashMap<String, String> outputMap = new HashMap<>(); outputMap.put("email", email); outputMap.put("name", name); outputMap.put("firstName", firstName); outputMap.put("middleName", middleName); outputMap.put("lastName", lastName); OAuth2User user = new OAuth2User(); user.setId(getId()); user.setClaims(outputMap); return user; }  String getName(); void setName(final String name); String getId(); void setId(final String id); String getEmail(); void setEmail(final String email); String getFirstName(); void setFirstName(final String firstName); String getLastName(); void setLastName(final String lastName); String getMiddleName(); void setMiddleName(final String middleName); @JsonIgnore OAuth2User asGenericUser();  }
@Test public void testAsGenericUser() { FacebookUserEntity token = new FacebookUserEntity(); token.setId(RandomStringUtils.randomAlphabetic(30)); token.setName(RandomStringUtils.randomAlphabetic(30)); token.setFirstName(RandomStringUtils.randomAlphabetic(30)); token.setLastName(RandomStringUtils.randomAlphabetic(30)); token.setMiddleName(RandomStringUtils.randomAlphabetic(30)); OAuth2User user = token.asGenericUser(); assertEquals(token.getId(), user.getId()); assertEquals(token.getName(), user.getClaims().get("name")); assertEquals(token.getFirstName(), user.getClaims().get("firstName")); assertEquals(token.getMiddleName(), user.getClaims().get("middleName")); assertEquals(token.getLastName(), user.getClaims().get("lastName")); assertEquals(token.getEmail(), user.getClaims().get("email")); }