### Question:
ObjectTypeSearchDelegate implements Delegate { public ResultSet<ObjectType> handle(SearchObjectTypeRequest request) throws AccessDeniedException, AuthenticationFailedException, InvalidArgumentException { securityContext.checkPermission(TiFunctionConstants.viewThreatIntelType); List<ObjectType> types = objectManager .fetchObjectTypes() .stream() .map(objectTypeResponseConverter) .collect(Collectors.toList()); return StreamingResultSet.<ObjectType>builder() .setCount(types.size()) .setLimit(0) .setValues(types) .build(); } @Inject  ObjectTypeSearchDelegate(TiSecurityContext securityContext,
                                  ObjectManager objectManager,
                                  ObjectTypeResponseConverter objectTypeResponseConverter); ResultSet<ObjectType> handle(SearchObjectTypeRequest request);  }### Answer:
@Test(expected = AccessDeniedException.class) public void testFetchObjectTypesWithoutPermission() throws Exception { doThrow(AccessDeniedException.class).when(securityContext).checkPermission(TiFunctionConstants.viewThreatIntelType); delegate.handle(new SearchObjectTypeRequest()); }
@Test public void testFetchObjectTypes() throws Exception { List<ObjectTypeEntity> entities = ListUtils.list(new ObjectTypeEntity(), new ObjectTypeEntity(), new ObjectTypeEntity()); when(objectManager.fetchObjectTypes()).thenReturn(entities); ResultSet<ObjectType> result = delegate.handle(new SearchObjectTypeRequest()); assertEquals(entities.size(), result.getCount()); assertEquals(0, result.getLimit()); assertEquals(entities.size(), ListUtils.list(result.iterator()).size()); verify(objectTypeResponseConverter, times(entities.size())).apply(argThat(entities::contains)); }