@Override
  public SecretKeySpec getKey(RestRequest restRequest, short accountId, short containerId)
      throws GeneralSecurityException {
    currentRestRequest.set(restRequest);
    if (exceptionToThrow.get() != null) {
      throw exceptionToThrow.get();
    } else {
      return super.getKey(restRequest, accountId, containerId);
    }
  }
MockKeyManagementService to assist in testing exception cases
ambry-router/src/test/java/com/github/ambry/router/MockKeyManagementService.java