@@ -89,10 +89,8 @@ protected StopTransformResponse stopTransform(String id) throws IOException {
89
89
return stopTransform (id , true , null , false );
90
90
}
91
91
92
- protected StopTransformResponse stopTransform (String id ,
93
- boolean waitForCompletion ,
94
- TimeValue timeout ,
95
- boolean waitForCheckpoint ) throws IOException {
92
+ protected StopTransformResponse stopTransform (String id , boolean waitForCompletion , TimeValue timeout , boolean waitForCheckpoint )
93
+ throws IOException {
96
94
RestHighLevelClient restClient = new TestRestHighLevelClient ();
97
95
return restClient .transform ()
98
96
.stopTransform (new StopTransformRequest (id , waitForCompletion , timeout , waitForCheckpoint ), RequestOptions .DEFAULT );
@@ -105,8 +103,7 @@ protected StartTransformResponse startTransform(String id, RequestOptions option
105
103
106
104
protected AcknowledgedResponse deleteTransform (String id ) throws IOException {
107
105
RestHighLevelClient restClient = new TestRestHighLevelClient ();
108
- AcknowledgedResponse response =
109
- restClient .transform ().deleteTransform (new DeleteTransformRequest (id ), RequestOptions .DEFAULT );
106
+ AcknowledgedResponse response = restClient .transform ().deleteTransform (new DeleteTransformRequest (id ), RequestOptions .DEFAULT );
110
107
if (response .isAcknowledged ()) {
111
108
transformConfigs .remove (id );
112
109
}
@@ -118,8 +115,7 @@ protected AcknowledgedResponse putTransform(TransformConfig config, RequestOptio
118
115
throw new IllegalArgumentException ("transform [" + config .getId () + "] is already registered" );
119
116
}
120
117
RestHighLevelClient restClient = new TestRestHighLevelClient ();
121
- AcknowledgedResponse response =
122
- restClient .transform ().putTransform (new PutTransformRequest (config ), options );
118
+ AcknowledgedResponse response = restClient .transform ().putTransform (new PutTransformRequest (config ), options );
123
119
if (response .isAcknowledged ()) {
124
120
transformConfigs .put (config .getId (), config );
125
121
}
@@ -141,30 +137,33 @@ protected void waitUntilCheckpoint(String id, long checkpoint) throws Exception
141
137
}
142
138
143
139
protected void waitUntilCheckpoint (String id , long checkpoint , TimeValue waitTime ) throws Exception {
144
- assertBusy (() ->
145
- assertEquals (checkpoint , getTransformStats (id )
146
- .getTransformsStats ()
147
- .get (0 )
148
- .getCheckpointingInfo ()
149
- .getLast ()
150
- .getCheckpoint ()),
140
+ assertBusy (
141
+ () -> assertEquals (
142
+ checkpoint ,
143
+ getTransformStats (id ).getTransformsStats ().get (0 ).getCheckpointingInfo ().getLast ().getCheckpoint ()
144
+ ),
151
145
waitTime .getMillis (),
152
- TimeUnit .MILLISECONDS );
146
+ TimeUnit .MILLISECONDS
147
+ );
153
148
}
154
149
155
- protected DateHistogramGroupSource createDateHistogramGroupSourceWithFixedInterval (String field ,
156
- DateHistogramInterval interval ,
157
- ZoneId zone ) {
150
+ protected DateHistogramGroupSource createDateHistogramGroupSourceWithFixedInterval (
151
+ String field ,
152
+ DateHistogramInterval interval ,
153
+ ZoneId zone
154
+ ) {
158
155
DateHistogramGroupSource .Builder builder = DateHistogramGroupSource .builder ()
159
156
.setField (field )
160
157
.setInterval (new DateHistogramGroupSource .FixedInterval (interval ))
161
158
.setTimeZone (zone );
162
159
return builder .build ();
163
160
}
164
161
165
- protected DateHistogramGroupSource createDateHistogramGroupSourceWithCalendarInterval (String field ,
166
- DateHistogramInterval interval ,
167
- ZoneId zone ) {
162
+ protected DateHistogramGroupSource createDateHistogramGroupSourceWithCalendarInterval (
163
+ String field ,
164
+ DateHistogramInterval interval ,
165
+ ZoneId zone
166
+ ) {
168
167
DateHistogramGroupSource .Builder builder = DateHistogramGroupSource .builder ()
169
168
.setField (field )
170
169
.setInterval (new DateHistogramGroupSource .CalendarInterval (interval ))
@@ -188,35 +187,38 @@ protected AggregationConfig createAggConfig(AggregatorFactories.Builder aggregat
188
187
return new AggregationConfig (aggregations );
189
188
}
190
189
191
- protected PivotConfig createPivotConfig (Map <String , SingleGroupSource > groups ,
192
- AggregatorFactories . Builder aggregations ) throws Exception {
190
+ protected PivotConfig createPivotConfig (Map <String , SingleGroupSource > groups , AggregatorFactories . Builder aggregations )
191
+ throws Exception {
193
192
return createPivotConfig (groups , aggregations , null );
194
193
}
195
194
196
- protected PivotConfig createPivotConfig (Map <String , SingleGroupSource > groups ,
197
- AggregatorFactories .Builder aggregations ,
198
- Integer size ) throws Exception {
195
+ protected PivotConfig createPivotConfig (Map <String , SingleGroupSource > groups , AggregatorFactories .Builder aggregations , Integer size )
196
+ throws Exception {
199
197
PivotConfig .Builder builder = PivotConfig .builder ()
200
198
.setGroups (createGroupConfig (groups ))
201
199
.setAggregationConfig (createAggConfig (aggregations ))
202
200
.setMaxPageSearchSize (size );
203
201
return builder .build ();
204
202
}
205
203
206
- protected TransformConfig createTransformConfig (String id ,
207
- Map <String , SingleGroupSource > groups ,
208
- AggregatorFactories .Builder aggregations ,
209
- String destinationIndex ,
210
- String ... sourceIndices ) throws Exception {
204
+ protected TransformConfig createTransformConfig (
205
+ String id ,
206
+ Map <String , SingleGroupSource > groups ,
207
+ AggregatorFactories .Builder aggregations ,
208
+ String destinationIndex ,
209
+ String ... sourceIndices
210
+ ) throws Exception {
211
211
return createTransformConfig (id , groups , aggregations , destinationIndex , QueryBuilders .matchAllQuery (), sourceIndices );
212
212
}
213
213
214
- protected TransformConfig .Builder createTransformConfigBuilder (String id ,
215
- Map <String , SingleGroupSource > groups ,
216
- AggregatorFactories .Builder aggregations ,
217
- String destinationIndex ,
218
- QueryBuilder queryBuilder ,
219
- String ... sourceIndices ) throws Exception {
214
+ protected TransformConfig .Builder createTransformConfigBuilder (
215
+ String id ,
216
+ Map <String , SingleGroupSource > groups ,
217
+ AggregatorFactories .Builder aggregations ,
218
+ String destinationIndex ,
219
+ QueryBuilder queryBuilder ,
220
+ String ... sourceIndices
221
+ ) throws Exception {
220
222
return TransformConfig .builder ()
221
223
.setId (id )
222
224
.setSource (SourceConfig .builder ().setIndex (sourceIndices ).setQueryConfig (createQueryConfig (queryBuilder )).build ())
@@ -226,12 +228,14 @@ protected TransformConfig.Builder createTransformConfigBuilder(String id,
226
228
.setDescription ("Test transform config id: " + id );
227
229
}
228
230
229
- protected TransformConfig createTransformConfig (String id ,
230
- Map <String , SingleGroupSource > groups ,
231
- AggregatorFactories .Builder aggregations ,
232
- String destinationIndex ,
233
- QueryBuilder queryBuilder ,
234
- String ... sourceIndices ) throws Exception {
231
+ protected TransformConfig createTransformConfig (
232
+ String id ,
233
+ Map <String , SingleGroupSource > groups ,
234
+ AggregatorFactories .Builder aggregations ,
235
+ String destinationIndex ,
236
+ QueryBuilder queryBuilder ,
237
+ String ... sourceIndices
238
+ ) throws Exception {
235
239
return createTransformConfigBuilder (id , groups , aggregations , destinationIndex , queryBuilder , sourceIndices ).build ();
236
240
}
237
241
@@ -272,8 +276,8 @@ protected void createReviewsIndex(String indexName, int numDocs) throws Exceptio
272
276
.endObject ();
273
277
}
274
278
builder .endObject ();
275
- CreateIndexResponse response =
276
- restClient . indices () .create (new CreateIndexRequest (indexName ).mapping (builder ), RequestOptions .DEFAULT );
279
+ CreateIndexResponse response = restClient . indices ()
280
+ .create (new CreateIndexRequest (indexName ).mapping (builder ), RequestOptions .DEFAULT );
277
281
assertThat (response .isAcknowledged (), is (true ));
278
282
}
279
283
@@ -320,10 +324,14 @@ protected void createReviewsIndex(String indexName, int numDocs) throws Exceptio
320
324
321
325
protected Map <String , Object > toLazy (ToXContent parsedObject ) throws Exception {
322
326
BytesReference bytes = XContentHelper .toXContent (parsedObject , XContentType .JSON , false );
323
- try (XContentParser parser = XContentHelper .createParser (xContentRegistry (),
324
- DeprecationHandler .THROW_UNSUPPORTED_OPERATION ,
325
- bytes ,
326
- XContentType .JSON )) {
327
+ try (
328
+ XContentParser parser = XContentHelper .createParser (
329
+ xContentRegistry (),
330
+ DeprecationHandler .THROW_UNSUPPORTED_OPERATION ,
331
+ bytes ,
332
+ XContentType .JSON
333
+ )
334
+ ) {
327
335
return parser .mapOrdered ();
328
336
}
329
337
}
@@ -349,16 +357,18 @@ protected NamedXContentRegistry xContentRegistry() {
349
357
350
358
@ Override
351
359
protected Settings restClientSettings () {
352
- final String token = "Basic " +
353
- Base64 .getEncoder ().encodeToString (("x_pack_rest_user:x-pack-test-password" ).getBytes (StandardCharsets .UTF_8 ));
354
- return Settings .builder ()
355
- .put (ThreadContext .PREFIX + ".Authorization" , token )
356
- .build ();
360
+ final String token = "Basic "
361
+ + Base64 .getEncoder ().encodeToString (("x_pack_rest_user:x-pack-test-password" ).getBytes (StandardCharsets .UTF_8 ));
362
+ return Settings .builder ().put (ThreadContext .PREFIX + ".Authorization" , token ).build ();
357
363
}
358
364
359
365
protected static class TestRestHighLevelClient extends RestHighLevelClient {
360
- private static final List <NamedXContentRegistry .Entry > X_CONTENT_ENTRIES =
361
- new SearchModule (Settings .EMPTY , false , Collections .emptyList ()).getNamedXContents ();
366
+ private static final List <NamedXContentRegistry .Entry > X_CONTENT_ENTRIES = new SearchModule (
367
+ Settings .EMPTY ,
368
+ false ,
369
+ Collections .emptyList ()
370
+ ).getNamedXContents ();
371
+
362
372
TestRestHighLevelClient () {
363
373
super (client (), restClient -> {}, X_CONTENT_ENTRIES );
364
374
}
0 commit comments