本文整理汇总了Java中org.springframework.social.connect.UserProfileBuilder类的典型用法代码示例。如果您正苦于以下问题:Java UserProfileBuilder类的具体用法?Java UserProfileBuilder怎么用?Java UserProfileBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UserProfileBuilder类属于org.springframework.social.connect包,在下文中一共展示了UserProfileBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFindUserIdsWithConnectionNewUser
import org.springframework.social.connect.UserProfileBuilder; //导入依赖的package包/类
@Test
public void testFindUserIdsWithConnectionNewUser() throws Exception {
TestConnection connection = new TestConnection(
SocialTestUtils.key(SocialTestUtils.FACEBOOK, SocialTestUtils.PROVIDER_USER_ID_ONE));
connection
.setDisplayName(SocialTestUtils.DISPLAY_NAME)
.setImageUrl(SocialTestUtils.IMAGE_URL)
.setProfileUrl("http://www.facebook.com/sbelov2015")
.setUserProfile(new UserProfileBuilder()
.setEmail(SocialTestUtils.USER_EMAIL_ONE)
.setFirstName("Stan")
.setLastName("Belov")
.setName("Stan Belov")
.setUsername(SocialTestUtils.PROVIDER_USER_ID_ONE)
.build());
when(connectionSignUp.execute(connection)).thenReturn(SocialTestUtils.USER_EMAIL_ONE);
List<String> userIds = usersConnectionRepository.findUserIdsWithConnection(connection);
assertEquals(ImmutableList.of(SocialTestUtils.USER_EMAIL_ONE), ImmutableList.copyOf(userIds));
verify(connectionSignUp).execute(connection);
}
示例2: testFindUserIdsWithConnectionExistingUser
import org.springframework.social.connect.UserProfileBuilder; //导入依赖的package包/类
@Test
public void testFindUserIdsWithConnectionExistingUser() throws Exception {
TestConnection connection = new TestConnection(
SocialTestUtils.key(SocialTestUtils.FACEBOOK, SocialTestUtils.PROVIDER_USER_ID_ONE));
connection
.setDisplayName(SocialTestUtils.DISPLAY_NAME)
.setImageUrl(SocialTestUtils.IMAGE_URL)
.setProfileUrl("http://www.facebook.com/sbelov2015")
.setUserProfile(new UserProfileBuilder()
.setEmail("[email protected]")
.setFirstName("Stan")
.setLastName("Belov")
.setName("Stan Belov")
.setUsername(SocialTestUtils.PROVIDER_USER_ID_ONE)
.build());
when(userRepository.findOneByAuthProviderUserId(
SocialTestUtils.FACEBOOK, SocialTestUtils.PROVIDER_USER_ID_ONE))
.thenReturn(SocialTestUtils.USER_ONE);
List<String> userIds = usersConnectionRepository.findUserIdsWithConnection(connection);
verify(userRepository, never()).save(any(User.class));
assertEquals(ImmutableList.of(SocialTestUtils.USER_EMAIL_ONE), ImmutableList.copyOf(userIds));
}
示例3: fetchUserProfile
import org.springframework.social.connect.UserProfileBuilder; //导入依赖的package包/类
@Override
public UserProfile fetchUserProfile(Discord api) {
DiscordUser profile = api.userOperations().getUser();
return new UserProfileBuilder()
.setId(profile.getId())
.setName(profile.getUsername() + " " + profile.getDiscriminator())
.setUsername(api.userOperations().getNickname())
.setEmail(profile.getEmail())
.build();
}
示例4: fetchUserProfile
import org.springframework.social.connect.UserProfileBuilder; //导入依赖的package包/类
@Override
public UserProfile fetchUserProfile(GitlabAPI gitlab) {
try {
GitlabUser gitlabUser = gitlab.getUser();
return new UserProfileBuilder()
.setEmail(gitlabUser.getEmail())
.setName(gitlabUser.getName())
.setUsername(gitlabUser.getUsername())
.build();
} catch (IOException e) {
throw new ApiException("gitlab?", "Could not fetch current user.", e);
}
}
示例5: testExecute
import org.springframework.social.connect.UserProfileBuilder; //导入依赖的package包/类
@Test
public void testExecute() throws Exception {
TestConnection connection = new TestConnection(
SocialTestUtils.key(SocialTestUtils.FACEBOOK, SocialTestUtils.PROVIDER_USER_ID_ONE));
connection
.setDisplayName(SocialTestUtils.DISPLAY_NAME)
.setImageUrl(SocialTestUtils.IMAGE_URL)
.setProfileUrl("http://www.facebook.com/sbelov2015")
.setUserProfile(new UserProfileBuilder()
.setEmail(SocialTestUtils.USER_EMAIL_ONE)
.setFirstName("Stan")
.setLastName("Belov")
.setName("Stan Belov")
.setUsername(SocialTestUtils.PROVIDER_USER_ID_ONE)
.build());
connectionSignUp.execute(connection);
ArgumentCaptor<User> userCaptor = ArgumentCaptor.forClass(User.class);
verify(userRepository).save(userCaptor.capture());
User captured = userCaptor.getValue();
assertEquals(FACEBOOK, captured.getAuthProviderId());
assertEquals(PROVIDER_USER_ID_ONE, captured.getAuthProviderUserId());
assertEquals(USER_EMAIL_ONE, captured.getPrimaryEmail());
assertEquals(DISPLAY_NAME, captured.getDisplayName());
assertEquals(UserStatus.ACTIVE, captured.getStatus());
assertEquals(IMAGE_URL, captured.getAvatar());
assertTrue(captured.isVisible());
}
示例6: fetchUserProfile
import org.springframework.social.connect.UserProfileBuilder; //导入依赖的package包/类
@Override
public UserProfile fetchUserProfile(Kakao kakao) {
UserProfileBuilder profileBuilder = new UserProfileBuilder();
KakaoProfile profile = fetchPrimaryProfile(kakao);
if (profile != null) {
profileBuilder.setUsername(profile.getUsername());
}
return profileBuilder.build();
}
示例7: fetchUserProfile
import org.springframework.social.connect.UserProfileBuilder; //导入依赖的package包/类
public UserProfile fetchUserProfile(final Naver naver) {
return new UserProfileBuilder()
.setEmail(naver.userOperation().getEmail())
.setName(naver.userOperation().getName())
.setUsername(naver.userOperation().getNickname())
.build();
}
示例8: fetchUserProfile
import org.springframework.social.connect.UserProfileBuilder; //导入依赖的package包/类
@Override
public UserProfile fetchUserProfile(Weibo api) {
try {
String uid = api.accountOperations().getUid().getString("uid");
User user = api.usersOperations().showUserById(uid);
return new UserProfileBuilder().setName(user.getName()).setUsername(uid).build();
} catch (Exception e) {
LOG.error("error fetchUserProfile", e);
}
return null;
}
示例9: fetchUserProfile
import org.springframework.social.connect.UserProfileBuilder; //导入依赖的package包/类
@Override
public UserProfile fetchUserProfile(Reddit reddit) {
RedditProfile profile = reddit.userOperations().getUserProfile();
return new UserProfileBuilder()
.setUsername(profile.getUsername())
.setName(profile.getUsername())
.build();
}
示例10: fetchUserProfile
import org.springframework.social.connect.UserProfileBuilder; //导入依赖的package包/类
@Override
public UserProfile fetchUserProfile(Meetup meetup) {
Member self = meetup.memberOperations().getDetails();
return new UserProfileBuilder().setName(self.getName())
.setEmail(self.getEmail())
.setUsername(self.getId()).build();
}
示例11: fetchUserProfile
import org.springframework.social.connect.UserProfileBuilder; //导入依赖的package包/类
@Override
public UserProfile fetchUserProfile(Gaelic gaelic) {
GaelicProfile profile = gaelic.getProfile();
final UserProfileBuilder BUILDER = new UserProfileBuilder();
return BUILDER
.setUsername(profile.getId())
.setEmail(profile.getEmail())
.build();
}
示例12: fetchUserProfile
import org.springframework.social.connect.UserProfileBuilder; //导入依赖的package包/类
public UserProfile fetchUserProfile(Plus api) {
Person person = api.getPeopleOperations().get("me");
UserProfileBuilder builder = new UserProfileBuilder().setFirstName(person.getName().getGivenName()).setLastName(person.getName().getFamilyName());
builder.setEmail(person.getGoogleAccountEmail());
builder.setName(person.getName().getFormatted());
return builder.build();
}
示例13: fetchUserProfile
import org.springframework.social.connect.UserProfileBuilder; //导入依赖的package包/类
@Override
public UserProfile fetchUserProfile(Evernote evernote) {
final User user = evernote.userStoreOperations().getUser();
return new UserProfileBuilder()
.setName(user.getName())
.setEmail(user.getEmail())
.setUsername(user.getUsername())
.build();
}
示例14: testSignup
import org.springframework.social.connect.UserProfileBuilder; //导入依赖的package包/类
@Test
public void testSignup() throws Exception {
final ConnectionData connectionData = new ConnectionData("provider id",
"provider user id",
"display name",
"profile url",
"image url",
"access token",
"secret",
"refresh token",
1234L);
final UserProfile userProfile = new UserProfileBuilder().setFirstName("first name")
.setLastName("last name")
.setEmail("[email protected]")
.build();
final Connection<?> connection = new ConnectionStub<>(connectionData, userProfile);
final ConnectionFactory<?> connectionFactory = new ConnectionFactoryStub<>("provider id", connection);
final ConnectionFactoryLocatorStub connectionFactoryLocator = new ConnectionFactoryLocatorStub(connectionFactory);
final ProviderSignInAttempt providerSignInAttempt = new ProviderSignInAttempt(connection, connectionFactoryLocator, null);
subject.perform(get("/signup")
.sessionAttr(ProviderSignInAttempt.class.getName(), providerSignInAttempt))
.andExpect(view().name(".signup"))
.andExpect(model().attribute("userForm", allOf(hasProperty("email", equalTo("[email protected]")),
hasProperty("firstName", equalTo("first name")),
hasProperty("lastName", equalTo("last name")))));
}
示例15: testSubmit
import org.springframework.social.connect.UserProfileBuilder; //导入依赖的package包/类
@Test
public void testSubmit() throws Exception {
final ConnectionData connectionData = new ConnectionData("provider id",
"provider user id",
"display name",
"profile url",
"image url",
"access token",
"secret",
"refresh token",
1234L);
final UserProfile userProfile = new UserProfileBuilder().setFirstName("first name")
.setLastName("last name")
.setEmail("[email protected]")
.build();
final Connection<?> connection = new ConnectionStub<>(connectionData, userProfile);
final ConnectionFactory<?> connectionFactory = new ConnectionFactoryStub<>("provider id", connection);
final ConnectionFactoryLocatorStub connectionFactoryLocator = new ConnectionFactoryLocatorStub(connectionFactory);
final UsersConnectionRepository usersConnectionRepository = new UsersConnectionRepositoryStub();
final ProviderSignInAttempt providerSignInAttempt = new ProviderSignInAttempt(connection, connectionFactoryLocator, usersConnectionRepository);
subject.perform(post("/signup")
.param("email", "[email protected]")
.param("firstName", "first name")
.param("lastName", "last name")
.sessionAttr(ProviderSignInAttempt.class.getName(), providerSignInAttempt))
.andExpect(view().name("redirect:/account"))
.andExpect(request().sessionAttribute(ProviderSignInAttempt.class.getName(), nullValue()));
assertThat(userRepository.count()).isEqualTo(1L);
}