1111
1212import  org .elasticsearch .action .DocWriteResponse ;
1313import  org .elasticsearch .action .fieldcaps .FieldCapabilities ;
14+ import  org .elasticsearch .action .fieldcaps .FieldCapabilitiesBuilder ;
1415import  org .elasticsearch .action .fieldcaps .FieldCapabilitiesResponse ;
1516import  org .elasticsearch .action .index .IndexRequestBuilder ;
1617import  org .elasticsearch .action .support .ActiveShardCount ;
@@ -76,10 +77,7 @@ public void testOnlyFieldsWithValueInIndex() {
7677        Map <String , FieldCapabilities > fooField  = response .getField ("foo" );
7778        assertEquals (1 , fooField .size ());
7879        assertThat (fooField , Matchers .hasKey ("text" ));
79-         assertEquals (
80-             new  FieldCapabilities ("foo" , "text" , false , true , false , null , null , null , Collections .emptyMap ()),
81-             fooField .get ("text" )
82-         );
80+         assertEquals (new  FieldCapabilitiesBuilder ("foo" , "text" ).isAggregatable (false ).build (), fooField .get ("text" ));
8381    }
8482
8583    public  void  testOnlyFieldsWithValueInAlias () {
@@ -94,10 +92,7 @@ public void testOnlyFieldsWithValueInAlias() {
9492        Map <String , FieldCapabilities > fooField  = response .getField ("foo" );
9593        assertEquals (1 , fooField .size ());
9694        assertThat (fooField , Matchers .hasKey ("text" ));
97-         assertEquals (
98-             new  FieldCapabilities ("foo" , "text" , false , true , false , null , null , null , Collections .emptyMap ()),
99-             fooField .get ("text" )
100-         );
95+         assertEquals (new  FieldCapabilitiesBuilder ("foo" , "text" ).isAggregatable (false ).build (), fooField .get ("text" ));
10196    }
10297
10398    public  void  testOnlyFieldsWithValueInSpecifiedIndex () {
@@ -112,10 +107,7 @@ public void testOnlyFieldsWithValueInSpecifiedIndex() {
112107        Map <String , FieldCapabilities > fooField  = response .getField ("foo" );
113108        assertEquals (1 , fooField .size ());
114109        assertThat (fooField , Matchers .hasKey ("text" ));
115-         assertEquals (
116-             new  FieldCapabilities ("foo" , "text" , false , true , false , null , null , null , Collections .emptyMap ()),
117-             fooField .get ("text" )
118-         );
110+         assertEquals (new  FieldCapabilitiesBuilder ("foo" , "text" ).isAggregatable (false ).build (), fooField .get ("text" ));
119111    }
120112
121113    public  void  testOnlyFieldsWithValueInSpecifiedAlias () {
@@ -130,10 +122,7 @@ public void testOnlyFieldsWithValueInSpecifiedAlias() {
130122        Map <String , FieldCapabilities > fooField  = response .getField ("foo" );
131123        assertEquals (1 , fooField .size ());
132124        assertThat (fooField , Matchers .hasKey ("text" ));
133-         assertEquals (
134-             new  FieldCapabilities ("foo" , "text" , false , true , false , null , null , null , Collections .emptyMap ()),
135-             fooField .get ("text" )
136-         );
125+         assertEquals (new  FieldCapabilitiesBuilder ("foo" , "text" ).isAggregatable (false ).build (), fooField .get ("text" ));
137126    }
138127
139128    public  void  testFieldsWithValueAfterUpdate () {
@@ -150,18 +139,12 @@ public void testFieldsWithValueAfterUpdate() {
150139        Map <String , FieldCapabilities > fooField  = response .getField ("foo" );
151140        assertEquals (1 , fooField .size ());
152141        assertThat (fooField , Matchers .hasKey ("text" ));
153-         assertEquals (
154-             new  FieldCapabilities ("foo" , "text" , false , true , false , null , null , null , Collections .emptyMap ()),
155-             fooField .get ("text" )
156-         );
142+         assertEquals (new  FieldCapabilitiesBuilder ("foo" , "text" ).isAggregatable (false ).build (), fooField .get ("text" ));
157143        // Check the capabilities for the 'bar' field. 
158144        Map <String , FieldCapabilities > barField  = response .getField ("bar" );
159145        assertEquals (1 , barField .size ());
160146        assertThat (barField , Matchers .hasKey ("keyword" ));
161-         assertEquals (
162-             new  FieldCapabilities ("bar" , "keyword" , false , true , true , null , null , null , Collections .emptyMap ()),
163-             barField .get ("keyword" )
164-         );
147+         assertEquals (new  FieldCapabilitiesBuilder ("bar" , "keyword" ).build (), barField .get ("keyword" ));
165148    }
166149
167150    public  void  testOnlyFieldsWithValueAfterNodesRestart () throws  Exception  {
@@ -177,10 +160,7 @@ public void testOnlyFieldsWithValueAfterNodesRestart() throws Exception {
177160        Map <String , FieldCapabilities > fooField  = response .getField ("foo" );
178161        assertEquals (1 , fooField .size ());
179162        assertThat (fooField , Matchers .hasKey ("text" ));
180-         assertEquals (
181-             new  FieldCapabilities ("foo" , "text" , false , true , false , null , null , null , Collections .emptyMap ()),
182-             fooField .get ("text" )
183-         );
163+         assertEquals (new  FieldCapabilitiesBuilder ("foo" , "text" ).isAggregatable (false ).build (), fooField .get ("text" ));
184164    }
185165
186166    public  void  testFieldsAndAliasWithValue () {
@@ -198,26 +178,17 @@ public void testFieldsAndAliasWithValue() {
198178        Map <String , FieldCapabilities > fooField  = response .getField ("foo" );
199179        assertEquals (1 , fooField .size ());
200180        assertThat (fooField , Matchers .hasKey ("text" ));
201-         assertEquals (
202-             new  FieldCapabilities ("foo" , "text" , false , true , false , null , null , null , Collections .emptyMap ()),
203-             fooField .get ("text" )
204-         );
181+         assertEquals (new  FieldCapabilitiesBuilder ("foo" , "text" ).isAggregatable (false ).build (), fooField .get ("text" ));
205182        // Check the capabilities for the 'bar' field. 
206183        Map <String , FieldCapabilities > barField  = response .getField ("bar" );
207184        assertEquals (1 , barField .size ());
208185        assertThat (barField , Matchers .hasKey ("keyword" ));
209-         assertEquals (
210-             new  FieldCapabilities ("bar" , "keyword" , false , true , true , null , null , null , Collections .emptyMap ()),
211-             barField .get ("keyword" )
212-         );
186+         assertEquals (new  FieldCapabilitiesBuilder ("bar" , "keyword" ).build (), barField .get ("keyword" ));
213187        // Check the capabilities for the 'bar-alias' field. 
214188        Map <String , FieldCapabilities > barAlias  = response .getField ("bar-alias" );
215189        assertEquals (1 , barAlias .size ());
216190        assertThat (barAlias , Matchers .hasKey ("keyword" ));
217-         assertEquals (
218-             new  FieldCapabilities ("bar-alias" , "keyword" , false , true , true , null , null , null , Collections .emptyMap ()),
219-             barAlias .get ("keyword" )
220-         );
191+         assertEquals (new  FieldCapabilitiesBuilder ("bar-alias" , "keyword" ).build (), barAlias .get ("keyword" ));
221192    }
222193
223194    public  void  testUnmappedFieldsWithValueAfterRestart () throws  Exception  {
@@ -238,7 +209,7 @@ public void testUnmappedFieldsWithValueAfterRestart() throws Exception {
238209        assertEquals (2 , unmappedField .size ());
239210        assertThat (unmappedField , Matchers .hasKey ("text" ));
240211        assertEquals (
241-             new  FieldCapabilities ("unmapped" , "text" ,  false ,  true ,  false ,  new   String [] {  INDEX1  },  null ,  null ,  Collections . emptyMap () ),
212+             new  FieldCapabilitiesBuilder ("unmapped" , "text" ). isAggregatable ( false ). indices ( INDEX1 ). build ( ),
242213            unmappedField .get ("text" )
243214        );
244215    }
@@ -257,18 +228,12 @@ public void testTwoFieldsNameTwoIndices() {
257228        Map <String , FieldCapabilities > fooField  = response .getField ("foo" );
258229        assertEquals (1 , fooField .size ());
259230        assertThat (fooField , Matchers .hasKey ("text" ));
260-         assertEquals (
261-             new  FieldCapabilities ("foo" , "text" , false , true , false , null , null , null , Collections .emptyMap ()),
262-             fooField .get ("text" )
263-         );
231+         assertEquals (new  FieldCapabilitiesBuilder ("foo" , "text" ).isAggregatable (false ).build (), fooField .get ("text" ));
264232        // Check the capabilities for the 'bar' field. 
265233        Map <String , FieldCapabilities > barField  = response .getField ("bar" );
266234        assertEquals (1 , barField .size ());
267235        assertThat (barField , Matchers .hasKey ("date" ));
268-         assertEquals (
269-             new  FieldCapabilities ("bar" , "date" , false , true , true , null , null , null , Collections .emptyMap ()),
270-             barField .get ("date" )
271-         );
236+         assertEquals (new  FieldCapabilitiesBuilder ("bar" , "date" ).build (), barField .get ("date" ));
272237    }
273238
274239    public  void  testSameFieldNameTwoIndices () {
@@ -284,15 +249,9 @@ public void testSameFieldNameTwoIndices() {
284249        Map <String , FieldCapabilities > barField  = response .getField ("bar" );
285250        assertEquals (2 , barField .size ());
286251        assertThat (barField , Matchers .hasKey ("keyword" ));
287-         assertEquals (
288-             new  FieldCapabilities ("bar" , "keyword" , false , true , true , new  String [] { INDEX1  }, null , null , Collections .emptyMap ()),
289-             barField .get ("keyword" )
290-         );
252+         assertEquals (new  FieldCapabilitiesBuilder ("bar" , "keyword" ).indices (INDEX1 ).build (), barField .get ("keyword" ));
291253        assertThat (barField , Matchers .hasKey ("date" ));
292-         assertEquals (
293-             new  FieldCapabilities ("bar" , "date" , false , true , true , new  String [] { INDEX2  }, null , null , Collections .emptyMap ()),
294-             barField .get ("date" )
295-         );
254+         assertEquals (new  FieldCapabilitiesBuilder ("bar" , "date" ).indices (INDEX2 ).build (), barField .get ("date" ));
296255    }
297256
298257    public  void  testDeletedDocsReturned () {
@@ -311,10 +270,7 @@ public void testDeletedDocsReturned() {
311270        Map <String , FieldCapabilities > fooField  = response .getField ("foo" );
312271        assertEquals (1 , fooField .size ());
313272        assertThat (fooField , Matchers .hasKey ("text" ));
314-         assertEquals (
315-             new  FieldCapabilities ("foo" , "text" , false , true , false , null , null , null , Collections .emptyMap ()),
316-             fooField .get ("text" )
317-         );
273+         assertEquals (new  FieldCapabilitiesBuilder ("foo" , "text" ).isAggregatable (false ).build (), fooField .get ("text" ));
318274    }
319275
320276    public  void  testNoNestedFieldsInEmptyIndex () {
@@ -339,15 +295,15 @@ public void testNestedFields() {
339295        assertEquals (1 , nestedTypeField .size ());
340296        assertThat (nestedTypeField , Matchers .hasKey ("nested" ));
341297        assertEquals (
342-             new  FieldCapabilities ("nested_type" , "nested" ,  false ,  false ,  false ,  null ,  null ,  null ,  Collections . emptyMap () ),
298+             new  FieldCapabilitiesBuilder ("nested_type" , "nested" ). isSearchable ( false ). isAggregatable ( false ). build ( ),
343299            nestedTypeField .get ("nested" )
344300        );
345301        // Check the capabilities for the 'nested_type.nested_field' field. 
346302        Map <String , FieldCapabilities > nestedTypeNestedField  = response .getField ("nested_type.nested_field" );
347303        assertEquals (1 , nestedTypeNestedField .size ());
348304        assertThat (nestedTypeNestedField , Matchers .hasKey ("text" ));
349305        assertEquals (
350-             new  FieldCapabilities ("nested_type.nested_field" , "text" ,  false ,  true ,  false ,  null ,  null ,  null ,  Collections . emptyMap () ),
306+             new  FieldCapabilitiesBuilder ("nested_type.nested_field" , "text" ). isAggregatable ( false ). build ( ),
351307            nestedTypeNestedField .get ("text" )
352308        );
353309    }
@@ -374,17 +330,14 @@ public void testObjectFields() {
374330        assertEquals (1 , objectTypeField .size ());
375331        assertThat (objectTypeField , Matchers .hasKey ("object" ));
376332        assertEquals (
377-             new  FieldCapabilities ("object" , "object" ,  false ,  false ,  false ,  null ,  null ,  null ,  Collections . emptyMap () ),
333+             new  FieldCapabilitiesBuilder ("object" , "object" ). isSearchable ( false ). isAggregatable ( false ). build ( ),
378334            objectTypeField .get ("object" )
379335        );
380336        // Check the capabilities for the 'object.sub_field' field. 
381337        Map <String , FieldCapabilities > objectSubfield  = response .getField ("object.sub_field" );
382338        assertEquals (1 , objectSubfield .size ());
383339        assertThat (objectSubfield , Matchers .hasKey ("keyword" ));
384-         assertEquals (
385-             new  FieldCapabilities ("object.sub_field" , "keyword" , false , true , true , null , null , null , Collections .emptyMap ()),
386-             objectSubfield .get ("keyword" )
387-         );
340+         assertEquals (new  FieldCapabilitiesBuilder ("object.sub_field" , "keyword" ).build (), objectSubfield .get ("keyword" ));
388341    }
389342
390343    public  void  testWithIndexFilter () throws  InterruptedException  {
0 commit comments