GoogleUserEntity { @JsonIgnore public OAuth2User asGenericUser() { HashMap<String, String> outputMap = new HashMap<>(); outputMap.put("email", email); outputMap.put("name", name); outputMap.put("verified_email", String.valueOf(verifiedEmail)); outputMap.put("family_name", familyName); outputMap.put("link", link); outputMap.put("picture", picture); outputMap.put("locale", locale); 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); Boolean isVerifiedEmail(); void setVerifiedEmail(final Boolean verifiedEmail); String getFamilyName(); void setFamilyName(final String familyName); String getLink(); void setLink(final String link); String getPicture(); void setPicture(final String picture); String getLocale(); void setLocale(final String locale); @JsonIgnore OAuth2User asGenericUser();  }
@Test public void testAsGenericUser() { GoogleUserEntity token = new GoogleUserEntity(); token.setId(RandomStringUtils.randomAlphabetic(30)); token.setName(RandomStringUtils.randomAlphabetic(30)); token.setVerifiedEmail(true); token.setFamilyName(RandomStringUtils.randomAlphabetic(30)); token.setLink(RandomStringUtils.randomAlphabetic(30)); token.setPicture(RandomStringUtils.randomAlphabetic(30)); token.setLocale(RandomStringUtils.randomAlphabetic(30)); OAuth2User user = token.asGenericUser(); assertEquals(token.getId(), user.getId()); assertEquals(token.getName(), user.getClaims().get("name")); assertEquals(token.isVerifiedEmail().toString(), user.getClaims().get("verified_email")); assertEquals(token.getFamilyName(), user.getClaims().get("family_name")); assertEquals(token.getLink(), user.getClaims().get("link")); assertEquals(token.getPicture(), user.getClaims().get("picture")); assertEquals(token.getLocale(), user.getClaims().get("locale")); }