### Question:
FactTypeGetByIdDelegate implements Delegate { public FactType handle(GetFactTypeByIdRequest request) throws AccessDeniedException, AuthenticationFailedException, InvalidArgumentException, ObjectNotFoundException { securityContext.checkPermission(TiFunctionConstants.viewThreatIntelType); return factTypeResponseConverter.apply(factTypeRequestResolver.fetchExistingFactType(request.getId())); } @Inject  FactTypeGetByIdDelegate(TiSecurityContext securityContext,
                                 FactTypeResponseConverter factTypeResponseConverter,
                                 FactTypeRequestResolver factTypeRequestResolver); FactType handle(GetFactTypeByIdRequest request);  }### Answer:
@Test(expected = AccessDeniedException.class) public void testFetchFactTypeWithoutPermission() throws Exception { doThrow(AccessDeniedException.class).when(securityContext).checkPermission(TiFunctionConstants.viewThreatIntelType); delegate.handle(new GetFactTypeByIdRequest()); }
@Test public void testFetchFactType() throws Exception { UUID id = UUID.randomUUID(); FactTypeEntity entity = new FactTypeEntity(); when(factTypeRequestResolver.fetchExistingFactType(id)).thenReturn(entity); delegate.handle(new GetFactTypeByIdRequest().setId(id)); verify(factTypeResponseConverter).apply(entity); }