use of com.parse.ParseUser in project Parse-SDK-Android by ParsePlatform.
the class ParseFacebookUtilsTest method testLinkWithAccessToken.
// endregion
// region testLink
@Test
public void testLinkWithAccessToken() {
Map<String, String> authData = new HashMap<>();
when(controller.getAuthData(any(AccessToken.class))).thenReturn(authData);
ParseFacebookUtils.isInitialized = true;
ParseUser user = mock(ParseUser.class);
when(user.linkWithInBackground(anyString(), anyMap())).thenReturn(Task.forResult(null));
AccessToken token = TestUtils.newAccessToken();
Task<Void> task = ParseFacebookUtils.linkInBackground(user, token);
verify(controller).getAuthData(token);
verify(user).linkWithInBackground("facebook", authData);
assertTrue(task.isCompleted());
}
use of com.parse.ParseUser in project Parse-SDK-Android by ParsePlatform.
the class ParseFacebookUtilsTest method doLinkWith.
private void doLinkWith(Activity activity, Fragment fragment, Collection<String> permissions, FacebookController.LoginAuthorizationType type) {
assertFalse("Cannot run test with both Activity and Fragment", activity != null && fragment != null);
Map<String, String> authData = new HashMap<>();
when(controller.authenticateAsync(nullable(Activity.class), nullable(Fragment.class), any(FacebookController.LoginAuthorizationType.class), anyList())).thenReturn(Task.forResult(authData));
ParseFacebookUtils.isInitialized = true;
ParseUser user = mock(ParseUser.class);
when(user.linkWithInBackground(anyString(), anyMap())).thenReturn(Task.forResult(null));
Task<Void> task;
if (FacebookController.LoginAuthorizationType.PUBLISH.equals(type)) {
if (activity != null) {
task = ParseFacebookUtils.linkWithPublishPermissionsInBackground(user, activity, permissions);
} else {
task = ParseFacebookUtils.linkWithPublishPermissionsInBackground(user, fragment, permissions);
}
} else {
if (activity != null) {
task = ParseFacebookUtils.linkWithReadPermissionsInBackground(user, activity, permissions);
} else {
task = ParseFacebookUtils.linkWithReadPermissionsInBackground(user, fragment, permissions);
}
}
verify(controller).authenticateAsync(activity, fragment, type, permissions);
verify(user).linkWithInBackground("facebook", authData);
assertTrue(task.isCompleted());
}
use of com.parse.ParseUser in project Parse-SDK-Android by ParsePlatform.
the class ParseFacebookUtilsTest method testLogInWithAccessToken.
// region testLogIn
@Test
public void testLogInWithAccessToken() {
Map<String, String> authData = new HashMap<>();
when(controller.getAuthData(any(AccessToken.class))).thenReturn(authData);
ParseFacebookUtils.isInitialized = true;
ParseUser user = mock(ParseUser.class);
when(userDelegate.logInWithInBackground(anyString(), anyMap())).thenReturn(Task.forResult(user));
AccessToken token = TestUtils.newAccessToken();
Task<ParseUser> task = ParseFacebookUtils.logInInBackground(token);
verify(controller).getAuthData(token);
verify(userDelegate).logInWithInBackground("facebook", authData);
assertTrue(task.isCompleted());
assertEquals(user, task.getResult());
}
use of com.parse.ParseUser in project Parse-SDK-Android by ParsePlatform.
the class ParseFacebookUtilsTest method testUnlinkInBackground.
// endregion
@Test
public void testUnlinkInBackground() {
ParseUser user = mock(ParseUser.class);
when(user.unlinkFromInBackground(anyString())).thenReturn(Task.forResult(null));
ParseFacebookUtils.isInitialized = true;
ParseFacebookUtils.unlinkInBackground(user);
verify(user).unlinkFromInBackground("facebook");
}
use of com.parse.ParseUser in project Parse-SDK-Android by ParsePlatform.
the class ParseTwitterUtilsTest method testLinkWithToken.
// endregion
// region testLink
@Test
@SuppressWarnings("unchecked")
public void testLinkWithToken() {
ParseTwitterUtils.isInitialized = true;
ParseUser user = mock(ParseUser.class);
when(user.linkWithInBackground(anyString(), anyMap())).thenReturn(Task.forResult(null));
String twitterId = "test_id";
String screenName = "test_screen_name";
String authToken = "test_token";
String authSecret = "test_secret";
Task<Void> task = ParseTwitterUtils.linkInBackground(user, twitterId, screenName, authToken, authSecret);
verify(controller).getAuthData(twitterId, screenName, authToken, authSecret);
verify(user).linkWithInBackground(eq("twitter"), anyMap());
assertTrue(task.isCompleted());
}
Aggregations