use of com.parse.ParseUser in project Parse-SDK-Android by ParsePlatform.
the class ParseTwitterUtilsTest method testIsLinked.
// endregion
@Test
public void testIsLinked() {
ParseUser user = mock(ParseUser.class);
when(user.isLinked(anyString())).thenReturn(true);
assertTrue(ParseTwitterUtils.isLinked(user));
verify(user).isLinked("twitter");
}
use of com.parse.ParseUser in project Parse-SDK-Android by ParsePlatform.
the class ParseTwitterUtilsTest method testLogInWithContext.
@Test
@SuppressWarnings("unchecked")
public void testLogInWithContext() {
ParseTwitterUtils.isInitialized = true;
ParseUser user = mock(ParseUser.class);
Map<String, String> authData = new HashMap<>();
when(controller.authenticateAsync(any(Context.class))).thenReturn(Task.forResult(authData));
when(userDelegate.logInWithInBackground(anyString(), anyMap())).thenReturn(Task.forResult(user));
Context context = mock(Context.class);
Task<ParseUser> task = ParseTwitterUtils.logInInBackground(context);
verify(controller).authenticateAsync(context);
verify(userDelegate).logInWithInBackground("twitter", authData);
assertTrue(task.isCompleted());
}
use of com.parse.ParseUser in project Parse-SDK-Android by ParsePlatform.
the class ParseTwitterUtilsTest method testLogInWithToken.
// region testLogIn
@Test
@SuppressWarnings("unchecked")
public void testLogInWithToken() {
ParseTwitterUtils.isInitialized = true;
ParseUser user = mock(ParseUser.class);
when(userDelegate.logInWithInBackground(anyString(), anyMap())).thenReturn(Task.forResult(user));
String twitterId = "test_id";
String screenName = "test_screen_name";
String authToken = "test_token";
String authSecret = "test_secret";
Task<ParseUser> task = ParseTwitterUtils.logInInBackground(twitterId, screenName, authToken, authSecret);
verify(controller).getAuthData(twitterId, screenName, authToken, authSecret);
verify(userDelegate).logInWithInBackground(eq("twitter"), anyMap());
assertTrue(task.isCompleted());
}
use of com.parse.ParseUser in project Parse-SDK-Android by ParsePlatform.
the class ParseFacebookUtilsTest method doLogInWith.
private void doLogInWith(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(userDelegate.logInWithInBackground(anyString(), anyMap())).thenReturn(Task.forResult(user));
Task<ParseUser> task;
if (FacebookController.LoginAuthorizationType.PUBLISH.equals(type)) {
if (activity != null) {
task = ParseFacebookUtils.logInWithPublishPermissionsInBackground(activity, permissions);
} else {
task = ParseFacebookUtils.logInWithPublishPermissionsInBackground(fragment, permissions);
}
} else {
if (activity != null) {
task = ParseFacebookUtils.logInWithReadPermissionsInBackground(activity, permissions);
} else {
task = ParseFacebookUtils.logInWithReadPermissionsInBackground(fragment, permissions);
}
}
verify(controller).authenticateAsync(activity, fragment, type, permissions);
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 testIsLinked.
// endregion
@Test
public void testIsLinked() {
ParseUser user = mock(ParseUser.class);
when(user.isLinked(anyString())).thenReturn(true);
assertTrue(ParseFacebookUtils.isLinked(user));
verify(user).isLinked("facebook");
}
Aggregations