### Question:
OfflineQueryLogic { static <T extends ParseObject> boolean hasReadAccess(ParseUser user, T object) { if (user == object) { return true; } ParseACL acl = object.getACL(); if (acl == null) { return true; } if (acl.getPublicReadAccess()) { return true; } if (user != null && acl.getReadAccess(user)) { return true; } return false; } OfflineQueryLogic(OfflineStore store);   }### Answer:
@Test public void testHasReadAccessWithSameObject() { ParseUser user = mock(ParseUser.class); assertTrue(OfflineQueryLogic.hasReadAccess(user, user)); verify(user, never()).getACL(); }
@Test public void testHasReadAccessWithNoACL() { ParseObject object = mock(ParseObject.class); when(object.getACL()).thenReturn(null); assertTrue(OfflineQueryLogic.hasReadAccess(null, object)); }
@Test public void testHasReadAccessWithPublicReadAccess() { ParseACL acl = mock(ParseACL.class); when(acl.getPublicReadAccess()).thenReturn(true); ParseObject object = mock(ParseObject.class); when(object.getACL()).thenReturn(acl); assertTrue(OfflineQueryLogic.hasReadAccess(null, object)); }
@Test public void testHasReadAccessWithReadAccess() { ParseUser user = mock(ParseUser.class); when(user.getObjectId()).thenReturn("test"); ParseACL acl = mock(ParseACL.class); when(acl.getReadAccess(user)).thenReturn(true); ParseObject object = mock(ParseObject.class); when(object.getACL()).thenReturn(acl); assertTrue(OfflineQueryLogic.hasReadAccess(user, object)); }
@Test public void testHasReadAccessWithNoReadAccess() { ParseACL acl = mock(ParseACL.class); when(acl.getPublicReadAccess()).thenReturn(false); when(acl.getReadAccess(any(ParseUser.class))).thenReturn(false); ParseObject object = mock(ParseObject.class); when(object.getACL()).thenReturn(acl); assertFalse(OfflineQueryLogic.hasReadAccess(null, object)); }