### Question:
AmbryServerSecurityService implements ServerSecurityService { @Override public void validateRequest(RestRequest restRequest, Callback<Void> callback) { Exception exception = null; serverMetrics.securityServiceValidateRequestRate.mark(); if (!isOpen) { exception = new RestServiceException("ServerSecurityService is closed", RestServiceErrorCode.ServiceUnavailable); } else if (restRequest == null) { throw new IllegalArgumentException("restRequest is null"); } callback.onCompletion(null, exception); } AmbryServerSecurityService(ServerConfig serverConfig, ServerMetrics serverMetrics); @Override void validateConnection(SSLSession sslSession, Callback<Void> callback); @Override void validateRequest(RestRequest restRequest, Callback<Void> callback); @Override void close();  }### Answer:
@Test public void validateRequestTest() throws Exception { TestUtils.assertException(IllegalArgumentException.class, () -> serverSecurityService.validateRequest( null).get(), null); RestRequest request = new MockRestRequest(MockRestRequest.DUMMY_DATA, null); serverSecurityService.validateRequest(request, (r, e) -> { Assert.assertNull("result not null", r); Assert.assertNull("exception not null", e); }); serverSecurityService.close(); 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)", RestServiceErrorCode.ServiceUnavailable, re.getErrorCode()); }; TestUtils.assertException(ExecutionException.class, () -> serverSecurityService.validateRequest(request).get(), errorAction); }