### Question:
AuthorizeResource extends ConsentRequiredResource { @Get public Representation authorize() throws OAuth2RestletException { final OAuth2Request request = requestFactory.create(getRequest()); for (AuthorizeRequestHook hook : hooks) { hook.beforeAuthorizeHandling(request, getRequest(), getResponse()); } try { final AuthorizationToken authorizationToken = authorizationService.authorize(request); final String redirectUri = getQueryValue("redirect_uri"); Representation response = representation.toRepresentation(getContext(), getRequest(), getResponse(), authorizationToken, redirectUri); for (AuthorizeRequestHook hook : hooks) { hook.afterAuthorizeSuccess(request, getRequest(), getResponse()); } return response; } catch (IllegalArgumentException e) { if (e.getMessage().contains("client_id")) { throw new OAuth2RestletException(400, "invalid_request", e.getMessage(), request.<String>getParameter("state")); } throw new OAuth2RestletException(400, "invalid_request", e.getMessage(), request.<String>getParameter("redirect_uri"), request.<String>getParameter("state")); } catch (ResourceOwnerAuthenticationRequired e) { throw new OAuth2RestletException(e.getStatusCode(), e.getError(), e.getMessage(), e.getRedirectUri().toString(), null); } catch (ResourceOwnerConsentRequired e) { return representation.getRepresentation(getContext(), request, "authorize.ftl", getDataModel(e, request)); } catch (InvalidClientException e) { throw new OAuth2RestletException(e.getStatusCode(), e.getError(), e.getMessage(), request.<String>getParameter("state")); } catch (RedirectUriMismatchException e) { throw new OAuth2RestletException(e.getStatusCode(), e.getError(), e.getMessage(), request.<String>getParameter("state")); } catch (OAuth2Exception e) { throw new OAuth2RestletException(e.getStatusCode(), e.getError(), e.getMessage(), request.<String>getParameter("redirect_uri"), request.<String>getParameter("state"), e.getParameterLocation()); } } @Inject  AuthorizeResource(OAuth2RequestFactory<?, Request> requestFactory, AuthorizationService authorizationService,
            ExceptionHandler exceptionHandler, OAuth2Representation representation, Set<AuthorizeRequestHook> hooks,
            XUIState xuiState, @Named("OAuth2Router") Router router, BaseURLProviderFactory baseURLProviderFactory); @Get Representation authorize(); @Post Representation authorize(Representation entity);  }### Answer:
@Test public void shouldCallHooksInGet() throws Exception { when(service.authorize(o2request)).thenReturn(authToken); resource.authorize(); verify(hook).beforeAuthorizeHandling(o2request, request, response); verify(hook).afterAuthorizeSuccess(o2request, request, response); }
@Test public void shouldCallHooksInPost() throws Exception { when(service.authorize(o2request)).thenReturn(authToken); resource.authorize(new EmptyRepresentation()); verify(hook).beforeAuthorizeHandling(o2request, request, response); verify(hook).afterAuthorizeSuccess(o2request, request, response); }