Class RestActionTestCase.VerifyingClient

java.lang.Object
org.elasticsearch.client.support.AbstractClient
org.elasticsearch.client.node.NodeClient
org.elasticsearch.test.client.NoOpNodeClient
org.elasticsearch.test.rest.RestActionTestCase.VerifyingClient
All Implemented Interfaces:
java.io.Closeable, java.lang.AutoCloseable, org.elasticsearch.client.Client, org.elasticsearch.client.ElasticsearchClient, org.elasticsearch.common.lease.Releasable
Enclosing class:
RestActionTestCase

public static class RestActionTestCase.VerifyingClient
extends NoOpNodeClient
A mocked NodeClient which can be easily reconfigured to verify arbitrary verification functions, and can be reset to allow reconfiguration partway through a test without having to construct a new object. By default, will throw AssertionError when any execution method is called, unless configured otherwise using setExecuteVerifier(BiFunction) or setExecuteLocallyVerifier(BiFunction).
  • Field Summary

    Fields inherited from class org.elasticsearch.client.support.AbstractClient

    logger, settings

    Fields inherited from interface org.elasticsearch.client.Client

    CLIENT_TYPE_SETTING_S
  • Constructor Summary

    Constructors 
    Constructor Description
    VerifyingClient​(java.lang.String testName)  
  • Method Summary

    Modifier and Type Method Description
    <Request extends org.elasticsearch.action.ActionRequest,​ Response extends org.elasticsearch.action.ActionResponse>
    void
    doExecute​(org.elasticsearch.action.ActionType<Response> action, Request request, org.elasticsearch.action.ActionListener<Response> listener)  
    <Request extends org.elasticsearch.action.ActionRequest,​ Response extends org.elasticsearch.action.ActionResponse>
    org.elasticsearch.tasks.Task
    executeLocally​(org.elasticsearch.action.ActionType<Response> action, Request request, org.elasticsearch.action.ActionListener<Response> listener)  
    <Request extends org.elasticsearch.action.ActionRequest,​ Response extends org.elasticsearch.action.ActionResponse>
    org.elasticsearch.tasks.Task
    executeLocally​(org.elasticsearch.action.ActionType<Response> action, Request request, org.elasticsearch.tasks.TaskListener<Response> listener)  
    void reset()
    Clears any previously set verifier functions set by setExecuteVerifier(BiFunction) and/or setExecuteLocallyVerifier(BiFunction).
    <Request extends org.elasticsearch.action.ActionRequest,​ Response extends org.elasticsearch.action.ActionResponse>
    void
    setExecuteLocallyVerifier​(java.util.function.BiFunction<org.elasticsearch.action.ActionType<Response>,​Request,​java.lang.Void> verifier)
    Sets the function that will be called when executeLocally(ActionType, ActionRequest, TaskListener)is called.
    <Request extends org.elasticsearch.action.ActionRequest,​ Response extends org.elasticsearch.action.ActionResponse>
    void
    setExecuteVerifier​(java.util.function.BiFunction<org.elasticsearch.action.ActionType<Response>,​Request,​java.lang.Void> verifier)
    Sets the function that will be called when doExecute(ActionType, ActionRequest, ActionListener) is called.

    Methods inherited from class org.elasticsearch.test.client.NoOpNodeClient

    close, getLocalNodeId, getRemoteClusterClient, initialize

    Methods inherited from class org.elasticsearch.client.node.NodeClient

    getNamedWriteableRegistry

    Methods inherited from class org.elasticsearch.client.support.AbstractClient

    admin, bulk, bulk, clearScroll, clearScroll, delete, delete, execute, execute, explain, explain, fieldCaps, fieldCaps, filterWithHeader, get, get, index, index, multiGet, multiGet, multiSearch, multiSearch, multiTermVectors, multiTermVectors, prepareBulk, prepareBulk, prepareClearScroll, prepareDelete, prepareDelete, prepareExplain, prepareFieldCaps, prepareGet, prepareGet, prepareIndex, prepareIndex, prepareIndex, prepareMultiGet, prepareMultiSearch, prepareMultiTermVectors, prepareSearch, prepareSearchScroll, prepareTermVectors, prepareTermVectors, prepareUpdate, prepareUpdate, search, search, searchScroll, searchScroll, settings, termVectors, termVectors, threadPool, update, update

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • reset

      public void reset()
      Clears any previously set verifier functions set by setExecuteVerifier(BiFunction) and/or setExecuteLocallyVerifier(BiFunction). These functions are replaced with functions which will throw an AssertionError if called.
    • setExecuteVerifier

      public <Request extends org.elasticsearch.action.ActionRequest,​ Response extends org.elasticsearch.action.ActionResponse> void setExecuteVerifier​(java.util.function.BiFunction<org.elasticsearch.action.ActionType<Response>,​Request,​java.lang.Void> verifier)
      Sets the function that will be called when doExecute(ActionType, ActionRequest, ActionListener) is called. The given function should return either a subclass of ActionResponse or null.
      Parameters:
      verifier - A function which is called in place of doExecute(ActionType, ActionRequest, ActionListener)
    • doExecute

      public <Request extends org.elasticsearch.action.ActionRequest,​ Response extends org.elasticsearch.action.ActionResponse> void doExecute​(org.elasticsearch.action.ActionType<Response> action, Request request, org.elasticsearch.action.ActionListener<Response> listener)
      Overrides:
      doExecute in class NoOpNodeClient
    • setExecuteLocallyVerifier

      public <Request extends org.elasticsearch.action.ActionRequest,​ Response extends org.elasticsearch.action.ActionResponse> void setExecuteLocallyVerifier​(java.util.function.BiFunction<org.elasticsearch.action.ActionType<Response>,​Request,​java.lang.Void> verifier)
      Sets the function that will be called when executeLocally(ActionType, ActionRequest, TaskListener)is called. The given function should return either a subclass of ActionResponse or null.
      Parameters:
      verifier - A function which is called in place of executeLocally(ActionType, ActionRequest, TaskListener)
    • executeLocally

      public <Request extends org.elasticsearch.action.ActionRequest,​ Response extends org.elasticsearch.action.ActionResponse> org.elasticsearch.tasks.Task executeLocally​(org.elasticsearch.action.ActionType<Response> action, Request request, org.elasticsearch.action.ActionListener<Response> listener)
      Overrides:
      executeLocally in class NoOpNodeClient
    • executeLocally

      public <Request extends org.elasticsearch.action.ActionRequest,​ Response extends org.elasticsearch.action.ActionResponse> org.elasticsearch.tasks.Task executeLocally​(org.elasticsearch.action.ActionType<Response> action, Request request, org.elasticsearch.tasks.TaskListener<Response> listener)
      Overrides:
      executeLocally in class NoOpNodeClient