Skip to content

Commit 7892ca6

Browse files
committed
Update unit tests
1 parent a3c2556 commit 7892ca6

File tree

1 file changed

+11
-23
lines changed

1 file changed

+11
-23
lines changed

Parse/src/test/java/com/parse/ParseUserTest.java

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -399,11 +399,9 @@ public void testLoginWithAsyncWithLinkedLazyUser() throws Exception {
399399
ParseCorePlugins.getInstance().registerCurrentUserController(currentUserController);
400400

401401
String authType = "facebook";
402-
ParseAuthenticationProvider provider = mock(ParseAuthenticationProvider.class);
403-
when(provider.getAuthType()).thenReturn(authType);
404402
Map<String, String> authData = new HashMap<>();
405403
authData.put("token", "123");
406-
ParseUser userAfterLogin = ParseTaskUtils.wait(ParseUser.logInWithAsync(provider, authData));
404+
ParseUser userAfterLogin = ParseTaskUtils.wait(ParseUser.logInWithAsync(authType, authData));
407405

408406
// Make sure we stripAnonymity
409407
assertNull(userAfterLogin.getAuthData().get(ParseAnonymousUtils.AUTH_TYPE));
@@ -430,12 +428,10 @@ public void testLoginWithAsyncWithLinkedLazyUseAndResolveLazinessFailure() throw
430428
ParseCorePlugins.getInstance().registerCurrentUserController(currentUserController);
431429

432430
String authType = "facebook";
433-
ParseAuthenticationProvider provider = mock(ParseAuthenticationProvider.class);
434-
when(provider.getAuthType()).thenReturn(authType);
435431
Map<String, String> authData = new HashMap<>();
436432
authData.put("token", "123");
437433

438-
Task<ParseUser> loginTask = ParseUser.logInWithAsync(provider, authData);
434+
Task<ParseUser> loginTask = ParseUser.logInWithAsync(authType, authData);
439435
loginTask.waitForCompletion();
440436

441437
// Make sure we try to resolveLaziness
@@ -460,23 +456,21 @@ public void testLoginWithAsyncWithLinkedNotLazyUser() throws Exception {
460456
ParseUser partialMockCurrentUser = spy(currentUser); // ParseUser.mutex
461457
doReturn(Task.<Void>forResult(null))
462458
.when(partialMockCurrentUser)
463-
.linkWithAsync(any(ParseAuthenticationProvider.class), Matchers.<Map<String, String>>any());
459+
.linkWithAsync(anyString(), Matchers.<Map<String, String>>any());
464460
ParseCurrentUserController currentUserController = mock(ParseCurrentUserController.class);
465461
when(currentUserController.getAsync()).thenReturn(Task.forResult(partialMockCurrentUser));
466462
when(currentUserController.getAsync(anyBoolean()))
467463
.thenReturn(Task.forResult(partialMockCurrentUser));
468464
ParseCorePlugins.getInstance().registerCurrentUserController(currentUserController);
469465

470466
String authType = "facebook";
471-
ParseAuthenticationProvider provider = mock(ParseAuthenticationProvider.class);
472-
when(provider.getAuthType()).thenReturn(authType);
473467
Map<String, String> authData = new HashMap<>();
474468
authData.put("token", "123");
475469

476-
ParseUser userAfterLogin = ParseTaskUtils.wait(ParseUser.logInWithAsync(provider, authData));
470+
ParseUser userAfterLogin = ParseTaskUtils.wait(ParseUser.logInWithAsync(authType, authData));
477471

478472
// Make sure we link authData
479-
verify(partialMockCurrentUser, times(1)).linkWithAsync(provider, authData);
473+
verify(partialMockCurrentUser, times(1)).linkWithAsync(authType, authData);
480474
assertSame(partialMockCurrentUser, userAfterLogin);
481475
}
482476

@@ -501,7 +495,7 @@ public void testLoginWithAsyncWithLinkedNotLazyUserLinkFailure() throws Exceptio
501495
new ParseException(ParseException.ACCOUNT_ALREADY_LINKED, "Account already linked");
502496
doReturn(Task.<Void>forError(linkException))
503497
.when(partialMockCurrentUser)
504-
.linkWithAsync(any(ParseAuthenticationProvider.class), Matchers.<Map<String, String>>any());
498+
.linkWithAsync(anyString(), Matchers.<Map<String, String>>any());
505499
ParseCurrentUserController currentUserController = mock(ParseCurrentUserController.class);
506500
when(currentUserController.getAsync()).thenReturn(Task.forResult(partialMockCurrentUser));
507501
when(currentUserController.setAsync(any(ParseUser.class)))
@@ -510,14 +504,12 @@ public void testLoginWithAsyncWithLinkedNotLazyUserLinkFailure() throws Exceptio
510504

511505

512506
String authType = "facebook";
513-
ParseAuthenticationProvider provider = mock(ParseAuthenticationProvider.class);
514-
when(provider.getAuthType()).thenReturn(authType);
515507
Map<String, String> authData = new HashMap<>();
516508
authData.put("token", "123");
517-
ParseUser userAfterLogin = ParseTaskUtils.wait(ParseUser.logInWithAsync(provider, authData));
509+
ParseUser userAfterLogin = ParseTaskUtils.wait(ParseUser.logInWithAsync(authType, authData));
518510

519511
// Make sure we link authData
520-
verify(partialMockCurrentUser, times(1)).linkWithAsync( provider, authData);
512+
verify(partialMockCurrentUser, times(1)).linkWithAsync(authType, authData);
521513
// Make sure we login authData
522514
verify(userController, times(1)).logInAsync("facebook", authData);
523515
// Make sure we save the new created user as currentUser
@@ -546,12 +538,10 @@ public void testLoginWithAsyncWithNoCurrentUser() throws Exception {
546538
ParseCorePlugins.getInstance().registerCurrentUserController(currentUserController);
547539

548540
String authType = "facebook";
549-
ParseAuthenticationProvider provider = mock(ParseAuthenticationProvider.class);
550-
when(provider.getAuthType()).thenReturn(authType);
551541
Map<String, String> authData = new HashMap<>();
552542
authData.put("token", "123");
553543

554-
ParseUser userAfterLogin = ParseTaskUtils.wait(ParseUser.logInWithAsync(provider, authData));
544+
ParseUser userAfterLogin = ParseTaskUtils.wait(ParseUser.logInWithAsync(authType, authData));
555545

556546
// Make sure we login authData
557547
verify(userController, times(1)).logInAsync("facebook", authData);
@@ -596,7 +586,7 @@ public void testLinkWithAsyncWithSaveAsyncSuccess() throws Exception {
596586
Map<String, String> authData = new HashMap<>();
597587
authData.put("token", "test");
598588

599-
ParseTaskUtils.wait(partialMockUser.linkWithAsync(provider, authData));
589+
ParseTaskUtils.wait(partialMockUser.linkWithAsync(provider.getAuthType(), authData));
600590

601591
// Make sure we stripAnonymity
602592
assertNull(partialMockUser.getAuthData().get(ParseAnonymousUtils.AUTH_TYPE));
@@ -632,13 +622,11 @@ public void testLinkWithAsyncWithSaveAsyncFailure() throws Exception {
632622
.when(partialMockUser)
633623
.getSessionToken();
634624
String authType = "facebook";
635-
ParseAuthenticationProvider provider = mock(ParseAuthenticationProvider.class);
636-
when(provider.getAuthType()).thenReturn(authType);
637625
Map<String, String> authData = new HashMap<>();
638626
authData.put("facebookToken", "facebookTest");
639627

640628
Task<Void> linkTask =
641-
partialMockUser.linkWithAsync(provider, authData);
629+
partialMockUser.linkWithAsync(authType, authData);
642630
linkTask.waitForCompletion();
643631

644632
// Make sure new authData is added

0 commit comments

Comments
 (0)