Search in sources :

Example 1 with NoOpClient

use of org.elasticsearch.test.client.NoOpClient in project elasticsearch by elastic.

the class IndexRequestBuilderTests method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    this.testClient = new NoOpClient(getTestName());
}
Also used : NoOpClient(org.elasticsearch.test.client.NoOpClient) Before(org.junit.Before)

Example 2 with NoOpClient

use of org.elasticsearch.test.client.NoOpClient in project elasticsearch by elastic.

the class ParentTaskAssigningClientTests method testSetsParentId.

public void testSetsParentId() {
    TaskId[] parentTaskId = new TaskId[] { new TaskId(randomAsciiOfLength(3), randomLong()) };
    // This mock will do nothing but verify that parentTaskId is set on all requests sent to it.
    NoOpClient mock = new NoOpClient(getTestName()) {

        @Override
        protected <Request extends ActionRequest, Response extends ActionResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder>> void doExecute(Action<Request, Response, RequestBuilder> action, Request request, ActionListener<Response> listener) {
            assertEquals(parentTaskId[0], request.getParentTask());
            super.doExecute(action, request, listener);
        }
    };
    try (ParentTaskAssigningClient client = new ParentTaskAssigningClient(mock, parentTaskId[0])) {
        // All of these should have the parentTaskId set
        client.bulk(new BulkRequest());
        client.search(new SearchRequest());
        client.clearScroll(new ClearScrollRequest());
        // Now lets verify that unwrapped calls don't have the parentTaskId set
        parentTaskId[0] = TaskId.EMPTY_TASK_ID;
        client.unwrap().bulk(new BulkRequest());
        client.unwrap().search(new SearchRequest());
        client.unwrap().clearScroll(new ClearScrollRequest());
    }
}
Also used : SearchRequest(org.elasticsearch.action.search.SearchRequest) Action(org.elasticsearch.action.Action) TaskId(org.elasticsearch.tasks.TaskId) ActionRequest(org.elasticsearch.action.ActionRequest) ClearScrollRequest(org.elasticsearch.action.search.ClearScrollRequest) SearchRequest(org.elasticsearch.action.search.SearchRequest) BulkRequest(org.elasticsearch.action.bulk.BulkRequest) ActionResponse(org.elasticsearch.action.ActionResponse) ActionRequestBuilder(org.elasticsearch.action.ActionRequestBuilder) ActionListener(org.elasticsearch.action.ActionListener) ActionRequest(org.elasticsearch.action.ActionRequest) NoOpClient(org.elasticsearch.test.client.NoOpClient) BulkRequest(org.elasticsearch.action.bulk.BulkRequest) ClearScrollRequest(org.elasticsearch.action.search.ClearScrollRequest)

Example 3 with NoOpClient

use of org.elasticsearch.test.client.NoOpClient in project elasticsearch by elastic.

the class CreateIndexRequestBuilderTests method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    this.testClient = new NoOpClient(getTestName());
}
Also used : NoOpClient(org.elasticsearch.test.client.NoOpClient) Before(org.junit.Before)

Aggregations

NoOpClient (org.elasticsearch.test.client.NoOpClient)3 Before (org.junit.Before)2 Action (org.elasticsearch.action.Action)1 ActionListener (org.elasticsearch.action.ActionListener)1 ActionRequest (org.elasticsearch.action.ActionRequest)1 ActionRequestBuilder (org.elasticsearch.action.ActionRequestBuilder)1 ActionResponse (org.elasticsearch.action.ActionResponse)1 BulkRequest (org.elasticsearch.action.bulk.BulkRequest)1 ClearScrollRequest (org.elasticsearch.action.search.ClearScrollRequest)1 SearchRequest (org.elasticsearch.action.search.SearchRequest)1 TaskId (org.elasticsearch.tasks.TaskId)1