@Test public void testGetDefaultACLWithCurrentUserAndLastCurrentUserNotSame() { ParseDefaultACLController controller = new ParseDefaultACLController(); ParseACL acl = mock(ParseACL.class); ParseACL copiedACL = mock(ParseACL.class); when(acl.copy()).thenReturn(copiedACL); controller.defaultACL = acl; controller.defaultACLUsesCurrentUser = true; controller.defaultACLWithCurrentUser = new ParseACL(); ParseCurrentUserController currentUserController = mock(ParseCurrentUserController.class); ParseUser currentUser = mock(ParseUser.class); when(currentUserController.getAsync(anyBoolean())).thenReturn(Task.forResult(currentUser)); ParseCorePlugins.getInstance().registerCurrentUserController(currentUserController); ParseACL defaultACL = controller.get(); verify(copiedACL, times(1)).setShared(true); verify(copiedACL, times(1)).setReadAccess(eq(currentUser), eq(true)); verify(copiedACL, times(1)).setWriteAccess(eq(currentUser), eq(true)); assertSame(currentUser, controller.lastCurrentUser.get()); assertNotSame(acl, defaultACL); assertSame(copiedACL, defaultACL); }
public ParseACL get() { if (defaultACLUsesCurrentUser && defaultACL != null) { ParseUser currentUser = ParseUser.getCurrentUser(); if (currentUser != null) { ParseUser last = lastCurrentUser != null ? lastCurrentUser.get() : null; if (last != currentUser) { ParseACL newDefaultACLWithCurrentUser = defaultACL.copy(); newDefaultACLWithCurrentUser.setShared(true); newDefaultACLWithCurrentUser.setReadAccess(currentUser, true); newDefaultACLWithCurrentUser.setWriteAccess(currentUser, true); defaultACLWithCurrentUser = newDefaultACLWithCurrentUser; lastCurrentUser = new WeakReference<>(currentUser); } return defaultACLWithCurrentUser; } } return defaultACL; }
ParseDefaultACLController { public ParseACL get() { if (defaultACLUsesCurrentUser && defaultACL != null) { ParseUser currentUser = ParseUser.getCurrentUser(); if (currentUser != null) { ParseUser last = lastCurrentUser != null ? lastCurrentUser.get() : null; if (last != currentUser) { ParseACL newDefaultACLWithCurrentUser = defaultACL.copy(); newDefaultACLWithCurrentUser.setShared(true); newDefaultACLWithCurrentUser.setReadAccess(currentUser, true); newDefaultACLWithCurrentUser.setWriteAccess(currentUser, true); defaultACLWithCurrentUser = newDefaultACLWithCurrentUser; lastCurrentUser = new WeakReference<>(currentUser); } return defaultACLWithCurrentUser; } } return defaultACL; } }
ParseDefaultACLController { public ParseACL get() { if (defaultACLUsesCurrentUser && defaultACL != null) { ParseUser currentUser = ParseUser.getCurrentUser(); if (currentUser != null) { ParseUser last = lastCurrentUser != null ? lastCurrentUser.get() : null; if (last != currentUser) { ParseACL newDefaultACLWithCurrentUser = defaultACL.copy(); newDefaultACLWithCurrentUser.setShared(true); newDefaultACLWithCurrentUser.setReadAccess(currentUser, true); newDefaultACLWithCurrentUser.setWriteAccess(currentUser, true); defaultACLWithCurrentUser = newDefaultACLWithCurrentUser; lastCurrentUser = new WeakReference<>(currentUser); } return defaultACLWithCurrentUser; } } return defaultACL; }  }
ParseDefaultACLController { public ParseACL get() { if (defaultACLUsesCurrentUser && defaultACL != null) { ParseUser currentUser = ParseUser.getCurrentUser(); if (currentUser != null) { ParseUser last = lastCurrentUser != null ? lastCurrentUser.get() : null; if (last != currentUser) { ParseACL newDefaultACLWithCurrentUser = defaultACL.copy(); newDefaultACLWithCurrentUser.setShared(true); newDefaultACLWithCurrentUser.setReadAccess(currentUser, true); newDefaultACLWithCurrentUser.setWriteAccess(currentUser, true); defaultACLWithCurrentUser = newDefaultACLWithCurrentUser; lastCurrentUser = new WeakReference<>(currentUser); } return defaultACLWithCurrentUser; } } return defaultACL; }  void set(ParseACL acl, boolean withAccessForCurrentUser); ParseACL get(); }
ParseDefaultACLController { public ParseACL get() { if (defaultACLUsesCurrentUser && defaultACL != null) { ParseUser currentUser = ParseUser.getCurrentUser(); if (currentUser != null) { ParseUser last = lastCurrentUser != null ? lastCurrentUser.get() : null; if (last != currentUser) { ParseACL newDefaultACLWithCurrentUser = defaultACL.copy(); newDefaultACLWithCurrentUser.setShared(true); newDefaultACLWithCurrentUser.setReadAccess(currentUser, true); newDefaultACLWithCurrentUser.setWriteAccess(currentUser, true); defaultACLWithCurrentUser = newDefaultACLWithCurrentUser; lastCurrentUser = new WeakReference<>(currentUser); } return defaultACLWithCurrentUser; } } return defaultACL; }  void set(ParseACL acl, boolean withAccessForCurrentUser); ParseACL get();  }