### Question:
SpaceGuidBasedAuthorizationFilter implements UriAuthorizationFilter { @Override public final boolean ensureUserIsAuthorized(HttpServletRequest request, HttpServletResponse response) throws IOException { String spaceGuid = extractAndLogSpaceGuid(request); try { authorizationChecker.ensureUserIsAuthorized(request, SecurityContextUtil.getUserInfo(), spaceGuid, null); return true; } catch (ResponseStatusException e) { logUnauthorizedRequest(request, e); response.sendError(e.getStatus() .value(), MessageFormat.format(Messages.NOT_AUTHORIZED_TO_OPERATE_IN_SPACE_WITH_GUID_0, spaceGuid)); return false; } } SpaceGuidBasedAuthorizationFilter(AuthorizationChecker authorizationChecker); @Override final boolean ensureUserIsAuthorized(HttpServletRequest request, HttpServletResponse response);  }### Answer:
@Test void testWithSuccessfulAuthorization() throws IOException { dummyUriAuthorizationFilter.ensureUserIsAuthorized(request, response); Mockito.verify(authorizationChecker) .ensureUserIsAuthorized(Mockito.eq(request), Mockito.any(), Mockito.eq(SPACE_GUID), Mockito.any()); }
@Test void testWithException() throws IOException { Mockito.doThrow(new ResponseStatusException(HttpStatus.FORBIDDEN)) .when(authorizationChecker) .ensureUserIsAuthorized(Mockito.eq(request), Mockito.any(), Mockito.eq(SPACE_GUID), Mockito.any()); dummyUriAuthorizationFilter.ensureUserIsAuthorized(request, response); Mockito.verify(response) .sendError(Mockito.eq(HttpStatus.FORBIDDEN.value()), Mockito.any()); }