private void testExceptionCasesProcessRequest(RestRequest restRequest, RestServiceErrorCode expectedErrorCode,
      boolean testAllRequestProcessing) throws Exception {
    ThrowingConsumer<ExecutionException> errorAction = e -> {
      Assert.assertTrue("Exception should have been an instance of RestServiceException",
          e.getCause() instanceof RestServiceException);
      RestServiceException re = (RestServiceException) e.getCause();
      Assert.assertEquals("Unexpected RestServerErrorCode (Future)", expectedErrorCode, re.getErrorCode());
    };

    TestUtils.assertException(ExecutionException.class, () -> securityService.preProcessRequest(restRequest).get(),
        errorAction);
    if (testAllRequestProcessing) {
      TestUtils.assertException(ExecutionException.class, () -> securityService.processRequest(restRequest).get(),
          errorAction);
      TestUtils.assertException(ExecutionException.class, () -> securityService.postProcessRequest(restRequest).get(),
          errorAction);
    }
  }
Tests exception cases for {@link SecurityService#preProcessRequest(RestRequest, Callback)} and
{@link SecurityService#processRequest(RestRequest, Callback)} and
{@link SecurityService#postProcessRequest(RestRequest)}
@param restRequest the {@link RestRequest} to provide as input.
@param expectedErrorCode the {@link RestServiceErrorCode} expected in the exception returned.
@param testAllRequestProcessing {@code true} if all request processing functions need to be tested for the same
                                             behavior.
@throws Exception
ambry-frontend/src/test/java/com/github/ambry/frontend/AmbrySecurityServiceTest.java