### Question:
TiSecurityContext extends SecurityContext { @Deprecated public boolean hasReadPermission(FactEntity fact) { try { checkReadPermission(fact); return true; } catch (AccessDeniedException | AuthenticationFailedException ignored) { return false; } } private  TiSecurityContext(AccessController accessController,
                            IdentityResolver identityResolver,
                            Credentials credentials,
                            ObjectFactDao objectFactDao,
                            Function<UUID, List<FactAclEntity>> aclResolver); static TiSecurityContext get(); static Builder builder(); @Deprecated void checkReadPermission(FactEntity fact); void checkReadPermission(FactRecord fact); void checkReadPermission(ObjectRecord object); void checkReadPermission(OriginEntity origin); void checkReadPermission(Organization organization); @Deprecated boolean hasReadPermission(FactEntity fact); boolean hasReadPermission(FactRecord fact); boolean hasReadPermission(ObjectRecord object); boolean hasReadPermission(OriginEntity origin); boolean hasReadPermission(Organization organization);  }### Answer:
@Test public void testHasReadPermissionForFactRecordReturnsFalseOnNoAccess() throws Exception { when(accessController.hasPermission(credentials, viewThreatIntelFact)).thenReturn(false); assertFalse(context.hasReadPermission(new FactRecord().setAccessMode(FactRecord.AccessMode.Public))); }
@Test public void testHasReadPermissionForObjectRecordReturnsTrueOnAccess() throws Exception { ObjectRecord object = mockCheckPermissionForObjectRecord(true); assertTrue(context.hasReadPermission(object)); }
@Test public void testHasReadPermissionForObjectRecordReturnsFalseOnNoAccess() throws Exception { ObjectRecord object = mockCheckPermissionForObjectRecord(false); assertFalse(context.hasReadPermission(object)); }
@Test public void testHasReadPermissionForOriginReturnsTrueOnAccess() throws Exception { when(accessController.hasPermission(credentials, viewThreatIntelOrigin)).thenReturn(true); assertTrue(context.hasReadPermission(new OriginEntity())); }
@Test public void testHasReadPermissionForOriginReturnsFalseOnNoAccess() throws Exception { when(accessController.hasPermission(credentials, viewThreatIntelOrigin)).thenReturn(false); assertFalse(context.hasReadPermission(new OriginEntity())); }
@Test public void testHasReadPermissionForOrganizationReturnsTrueOnAccess() throws Exception { Organization org = mockAvailableOrganization(); assertTrue(context.hasReadPermission(org)); }
@Test public void testHasReadPermissionReturnsTrueOnAccess() throws Exception { when(accessController.hasPermission(credentials, viewThreatIntelFact)).thenReturn(true); assertTrue(context.hasReadPermission(new FactEntity().setAccessMode(AccessMode.Public))); }
@Test public void testHasReadPermissionReturnsFalseOnNoAccess() throws Exception { when(accessController.hasPermission(credentials, viewThreatIntelFact)).thenReturn(false); assertFalse(context.hasReadPermission(new FactEntity().setAccessMode(AccessMode.Public))); }
@Test public void testHasReadPermissionForFactRecordReturnsTrueOnAccess() throws Exception { when(accessController.hasPermission(credentials, viewThreatIntelFact)).thenReturn(true); assertTrue(context.hasReadPermission(new FactRecord().setAccessMode(FactRecord.AccessMode.Public))); }