GithubUserEntity { @JsonIgnore public OAuth2User asGenericUser() { HashMap<String, String> outputMap = new HashMap<>(); outputMap.put("email", email); outputMap.put("name", name); outputMap.put("login", login); OAuth2User user = new OAuth2User(); user.setId(getId().toString()); user.setClaims(outputMap); return user; }  String getName(); void setName(final String name); Integer getId(); void setId(final Integer id); String getEmail(); void setEmail(final String email); String getLogin(); void setLogin(final String login); @JsonIgnore OAuth2User asGenericUser();  }
@Test public void testAsGenericUser() { GithubUserEntity token = new GithubUserEntity(); token.setId(RandomUtils.nextInt()); token.setName(randomAlphabetic(30)); token.setLogin(randomAlphabetic(30)); token.setEmail(randomAlphabetic(30)); OAuth2User user = token.asGenericUser(); assertEquals(token.getId().toString(), user.getId()); assertEquals(token.getName(), user.getClaims().get("name")); assertEquals(token.getLogin(), user.getClaims().get("login")); assertEquals(token.getEmail(), user.getClaims().get("email")); }