Search in sources :

Example 11 with ParseUser

use of com.parse.ParseUser in project Parse-SDK-Android by ParsePlatform.

the class ParseTwitterUtilsTest method testLinkWithContext.

@Test
@SuppressWarnings("unchecked")
public void testLinkWithContext() {
    ParseTwitterUtils.isInitialized = true;
    Map<String, String> authData = new HashMap<>();
    when(controller.authenticateAsync(any(Context.class))).thenReturn(Task.forResult(authData));
    Context context = mock(Context.class);
    ParseUser user = mock(ParseUser.class);
    when(user.linkWithInBackground(anyString(), any())).thenReturn(Task.forResult(null));
    Task<Void> task = ParseTwitterUtils.linkInBackground(context, user);
    verify(controller).authenticateAsync(context);
    verify(user).linkWithInBackground("twitter", authData);
    assertTrue(task.isCompleted());
}
Also used : Context(android.content.Context) HashMap(java.util.HashMap) Matchers.anyString(org.mockito.Matchers.anyString) ParseUser(com.parse.ParseUser) Test(org.junit.Test)

Example 12 with ParseUser

use of com.parse.ParseUser in project Parse-SDK-Android by ParsePlatform.

the class ParseTwitterUtilsTest method testUnlink.

// endregion
@Test
public void testUnlink() {
    ParseTwitterUtils.isInitialized = true;
    ParseUser user = mock(ParseUser.class);
    when(user.unlinkFromInBackground(anyString())).thenReturn(Task.forResult(null));
    Task<Void> task = ParseTwitterUtils.unlinkInBackground(user);
    verify(user).unlinkFromInBackground("twitter");
    verifyNoMoreInteractions(user);
    assertTrue(task.isCompleted());
}
Also used : ParseUser(com.parse.ParseUser) Test(org.junit.Test)

Aggregations

ParseUser (com.parse.ParseUser)12 Test (org.junit.Test)10 Matchers.anyString (org.mockito.Matchers.anyString)8 HashMap (java.util.HashMap)6 Activity (android.app.Activity)2 Context (android.content.Context)2 Fragment (androidx.fragment.app.Fragment)2 AccessToken (com.facebook.AccessToken)2