### Question:
FactTypeSearchDelegate implements Delegate { public ResultSet<FactType> handle(SearchFactTypeRequest request) throws AccessDeniedException, AuthenticationFailedException, InvalidArgumentException { securityContext.checkPermission(TiFunctionConstants.viewThreatIntelType); List<FactType> types = factManager .fetchFactTypes() .stream() .map(factTypeResponseConverter) .collect(Collectors.toList()); return StreamingResultSet.<FactType>builder() .setCount(types.size()) .setLimit(0) .setValues(types) .build(); } @Inject  FactTypeSearchDelegate(TiSecurityContext securityContext,
                                FactManager factManager,
                                FactTypeResponseConverter factTypeResponseConverter); ResultSet<FactType> handle(SearchFactTypeRequest request);  }### Answer:
@Test(expected = AccessDeniedException.class) public void testFetchFactTypesWithoutPermission() throws Exception { doThrow(AccessDeniedException.class).when(securityContext).checkPermission(TiFunctionConstants.viewThreatIntelType); delegate.handle(new SearchFactTypeRequest()); }
@Test public void testFetchFactTypes() throws Exception { List<FactTypeEntity> entities = ListUtils.list(new FactTypeEntity(), new FactTypeEntity(), new FactTypeEntity()); when(factManager.fetchFactTypes()).thenReturn(entities); ResultSet<FactType> result = delegate.handle(new SearchFactTypeRequest()); assertEquals(entities.size(), result.getCount()); assertEquals(0, result.getLimit()); assertEquals(entities.size(), ListUtils.list(result.iterator()).size()); verify(factTypeResponseConverter, times(entities.size())).apply(argThat(entities::contains)); }