# Integration Testing Aggregation Plugin

**URL:** <https://discuss.elastic.co/t/integration-testing-aggregation-plugin/91375>\
**Category:** Elasticsearch\
**Created:** [June 30, 2017, 6:36am UTC](https://discuss.elastic.co/t/integration-testing-aggregation-plugin/91375 "2017-06-30T06:36:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nirmalc](https://avatars.discourse-cdn.com/v4/letter/n/ecae2f/32.png) [@nirmalc](https://discuss.elastic.co/u/nirmalc)\
**Post date:** [June 30, 2017, 6:36am UTC](https://discuss.elastic.co/t/integration-testing-aggregation-plugin/91375/1 "2017-06-30T06:36:06Z")

</div>

I was trying to get my custom Aggregation Plugin work with ESIntegTestCase derived Test . Not sure how to get the Plugin registered properly for test to work .. I'm able to get the aggregation working fine with REST API , but not sure how to wire a plugin based aggregation to TranportClient.

1 - Registered plugin by overriding getMockPlugins

@Override  
protected Collection\<Class\<? extends Plugin\>\> getMockPlugins(){  
ArrayList\<Class\<? extends Plugin\>\> mocks = new ArrayList\<\>(super.getMockPlugins());  
mocks.add(CustomAggregationPlugin.class);  
return mocks;  
}

2 - Test aggregation using client and Builder

SearchResponse searchResponse = client().prepareSearch("empty\_bucket\_idx")  
.setQuery(matchAllQuery())  
.addAggregation(new CustomAggregationBuilder("fred").field("field1"))  
.execute().actionGet();

ends up throwing error:

`Caused by: java.lang.IllegalArgumentException: Unknown NamedWriteable [org.elasticsearch.search.aggregations.AggregationBuilder] ...`

AFAIK - SearchModule does register NamedWritable in case plugin was registered just like it does for main cluster, but not sure how to get that done in TransportClient

Appreciate any help !

Thanks  
Nirmal

---

<div class="post-metadata">

**Author:** ![nirmalc](https://avatars.discourse-cdn.com/v4/letter/n/ecae2f/32.png) [@nirmalc](https://discuss.elastic.co/u/nirmalc)\
**Post date:** [June 30, 2017, 7:17am UTC](https://discuss.elastic.co/t/integration-testing-aggregation-plugin/91375/2 "2017-06-30T07:17:07Z")

</div>

Ah - there was an override 🙂

`protected Collection<Class<? extends Plugin>> transportClientPlugins() {`

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 28, 2017, 7:17am UTC](https://discuss.elastic.co/t/integration-testing-aggregation-plugin/91375/3 "2017-07-28T07:17:29Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
