Search in sources :

Example 1 with ActionFuture

use of org.elasticsearch.action.ActionFuture in project metron by apache.

the class ElasticsearchColumnMetadataDaoTest method setup.

/**
 * @param indices The names of all indices that will exist.
 * @param mappings The index mappings.
 * @return An object to test.
 */
public ElasticsearchColumnMetadataDao setup(String[] indices, ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappings) {
    AdminClient adminClient = mock(AdminClient.class);
    IndicesAdminClient indicesAdminClient = mock(IndicesAdminClient.class);
    GetIndexRequestBuilder getIndexRequestBuilder = mock(GetIndexRequestBuilder.class);
    GetIndexResponse getIndexResponse = mock(GetIndexResponse.class);
    ActionFuture getMappingsActionFuture = mock(ActionFuture.class);
    GetMappingsResponse getMappingsResponse = mock(GetMappingsResponse.class);
    // setup the mocks so that a set of indices are available to the DAO
    when(adminClient.indices()).thenReturn(indicesAdminClient);
    when(indicesAdminClient.prepareGetIndex()).thenReturn(getIndexRequestBuilder);
    when(getIndexRequestBuilder.setFeatures()).thenReturn(getIndexRequestBuilder);
    when(getIndexRequestBuilder.get()).thenReturn(getIndexResponse);
    when(getIndexResponse.getIndices()).thenReturn(indices);
    // setup the mocks so that a set of mappings are available to the DAO
    when(indicesAdminClient.getMappings(any())).thenReturn(getMappingsActionFuture);
    when(getMappingsActionFuture.actionGet()).thenReturn(getMappingsResponse);
    when(getMappingsResponse.getMappings()).thenReturn(mappings);
    return new ElasticsearchColumnMetadataDao(adminClient);
}
Also used : GetIndexResponse(org.elasticsearch.action.admin.indices.get.GetIndexResponse) ActionFuture(org.elasticsearch.action.ActionFuture) IndicesAdminClient(org.elasticsearch.client.IndicesAdminClient) GetIndexRequestBuilder(org.elasticsearch.action.admin.indices.get.GetIndexRequestBuilder) IndicesAdminClient(org.elasticsearch.client.IndicesAdminClient) AdminClient(org.elasticsearch.client.AdminClient) GetMappingsResponse(org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse)

Aggregations

ActionFuture (org.elasticsearch.action.ActionFuture)1 GetIndexRequestBuilder (org.elasticsearch.action.admin.indices.get.GetIndexRequestBuilder)1 GetIndexResponse (org.elasticsearch.action.admin.indices.get.GetIndexResponse)1 GetMappingsResponse (org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse)1 AdminClient (org.elasticsearch.client.AdminClient)1 IndicesAdminClient (org.elasticsearch.client.IndicesAdminClient)1