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);
}
Aggregations