### Question:
OfflineQueryLogic { static <T extends ParseObject> boolean hasWriteAccess(ParseUser user, T object) { if (user == object) { return true; } ParseACL acl = object.getACL(); if (acl == null) { return true; } if (acl.getPublicWriteAccess()) { return true; } if (user != null && acl.getWriteAccess(user)) { return true; } return false; } OfflineQueryLogic(OfflineStore store);   }### Answer:
@Test public void testHasWriteAccessWithSameObject() { ParseUser user = mock(ParseUser.class); assertTrue(OfflineQueryLogic.hasWriteAccess(user, user)); verify(user, never()).getACL(); }
@Test public void testHasWriteAccessWithNoACL() { ParseObject object = mock(ParseObject.class); when(object.getACL()).thenReturn(null); assertTrue(OfflineQueryLogic.hasWriteAccess(null, object)); }
@Test public void testHasWriteAccessWithPublicWriteAccess() { ParseACL acl = mock(ParseACL.class); when(acl.getPublicWriteAccess()).thenReturn(true); ParseObject object = mock(ParseObject.class); when(object.getACL()).thenReturn(acl); assertTrue(OfflineQueryLogic.hasWriteAccess(null, object)); }
@Test public void testHasWriteAccessWithWriteAccess() { ParseUser user = mock(ParseUser.class); ParseACL acl = mock(ParseACL.class); when(acl.getWriteAccess(user)).thenReturn(true); ParseObject object = mock(ParseObject.class); when(object.getACL()).thenReturn(acl); assertTrue(OfflineQueryLogic.hasWriteAccess(user, object)); }
@Test public void testHasWriteAccessWithNoWriteAccess() { ParseACL acl = mock(ParseACL.class); when(acl.getPublicReadAccess()).thenReturn(false); ParseObject object = mock(ParseObject.class); when(object.getACL()).thenReturn(acl); assertFalse(OfflineQueryLogic.hasWriteAccess(null, object)); }