### Question:
FactGetAclDelegate implements Delegate { public ResultSet<AclEntry> handle(GetFactAclRequest request) throws AccessDeniedException, AuthenticationFailedException, InvalidArgumentException, ObjectNotFoundException { FactRecord fact = factRequestResolver.resolveFact(request.getFact()); securityContext.checkReadPermission(fact); securityContext.checkPermission(TiFunctionConstants.viewThreatIntelFactAccess, fact.getOrganizationID()); List<AclEntry> acl = ListUtils.list(fact.getAcl(), aclEntryResponseConverter); return StreamingResultSet.<AclEntry>builder() .setCount(acl.size()) .setLimit(0) .setValues(acl) .build(); } @Inject  FactGetAclDelegate(TiSecurityContext securityContext,
                            FactRequestResolver factRequestResolver,
                            AclEntryResponseConverter aclEntryResponseConverter); ResultSet<AclEntry> handle(GetFactAclRequest request);  }### Answer:
@Test(expected = AccessDeniedException.class) public void testGetFactAclNoAccessToFact() throws Exception { GetFactAclRequest request = new GetFactAclRequest().setFact(UUID.randomUUID()); when(factRequestResolver.resolveFact(request.getFact())).thenReturn(new FactRecord()); doThrow(AccessDeniedException.class).when(securityContext).checkReadPermission(isA(FactRecord.class)); delegate.handle(request); }
@Test(expected = AccessDeniedException.class) public void testGetFactAclNoViewPermission() throws Exception { GetFactAclRequest request = new GetFactAclRequest().setFact(UUID.randomUUID()); when(factRequestResolver.resolveFact(request.getFact())).thenReturn(new FactRecord()); doThrow(AccessDeniedException.class).when(securityContext).checkPermission(eq(TiFunctionConstants.viewThreatIntelFactAccess), any()); delegate.handle(request); }
@Test public void testGetFactAcl() throws Exception { GetFactAclRequest request = new GetFactAclRequest().setFact(UUID.randomUUID()); List<FactAclEntryRecord> acl = ListUtils.list(new FactAclEntryRecord(), new FactAclEntryRecord(), new FactAclEntryRecord()); when(factRequestResolver.resolveFact(request.getFact())).thenReturn(new FactRecord().setAcl(acl)); ResultSet<AclEntry> result = delegate.handle(request); assertEquals(acl.size(), result.getCount()); assertEquals(0, result.getLimit()); assertEquals(acl.size(), ListUtils.list(result.iterator()).size()); verify(aclEntryResponseConverter, times(acl.size())).apply(argThat(acl::contains)); }