@@ -132,73 +132,68 @@ public void testCreateTooManySynonymsUsingRuleUpdates() throws InterruptedExcept
132
132
int rulesToUpdate = randomIntBetween (1 , 10 );
133
133
int synonymsToCreate = maxSynonymSets - rulesToUpdate ;
134
134
String synonymSetId = randomIdentifier ();
135
- synonymsManagementAPIService .putSynonymsSet (
136
- synonymSetId ,
137
- randomSynonymsSet (synonymsToCreate ),
138
- true ,
139
- new ActionListener <>() {
140
- @ Override
141
- public void onResponse (SynonymsManagementAPIService .SynonymsReloadResult synonymsReloadResult ) {
142
- // Create as many rules as should fail
143
- SynonymRule [] rules = randomSynonymsSet (atLeast (rulesToUpdate + 1 ));
144
- CountDownLatch updatedRulesLatch = new CountDownLatch (rulesToUpdate );
145
- for (int i = 0 ; i < rulesToUpdate ; i ++) {
146
- synonymsManagementAPIService .putSynonymRule (synonymSetId , rules [i ], randomBoolean (), new ActionListener <>() {
135
+ synonymsManagementAPIService .putSynonymsSet (synonymSetId , randomSynonymsSet (synonymsToCreate ), true , new ActionListener <>() {
136
+ @ Override
137
+ public void onResponse (SynonymsManagementAPIService .SynonymsReloadResult synonymsReloadResult ) {
138
+ // Create as many rules as should fail
139
+ SynonymRule [] rules = randomSynonymsSet (atLeast (rulesToUpdate + 1 ));
140
+ CountDownLatch updatedRulesLatch = new CountDownLatch (rulesToUpdate );
141
+ for (int i = 0 ; i < rulesToUpdate ; i ++) {
142
+ synonymsManagementAPIService .putSynonymRule (synonymSetId , rules [i ], randomBoolean (), new ActionListener <>() {
143
+ @ Override
144
+ public void onResponse (SynonymsManagementAPIService .SynonymsReloadResult synonymsReloadResult ) {
145
+ updatedRulesLatch .countDown ();
146
+ }
147
+
148
+ @ Override
149
+ public void onFailure (Exception e ) {
150
+ fail (e );
151
+ }
152
+ });
153
+ }
154
+ try {
155
+ updatedRulesLatch .await (5 , TimeUnit .SECONDS );
156
+ } catch (InterruptedException e ) {
157
+ fail (e );
158
+ }
159
+
160
+ // Updating more rules fails
161
+ int rulesToInsert = rules .length - rulesToUpdate ;
162
+ CountDownLatch insertRulesLatch = new CountDownLatch (rulesToInsert );
163
+ for (int i = rulesToUpdate ; i < rulesToInsert ; i ++) {
164
+ synonymsManagementAPIService .putSynonymRule (
165
+ // Error here
166
+ synonymSetId ,
167
+ rules [i ],
168
+ randomBoolean (),
169
+ new ActionListener <>() {
147
170
@ Override
148
171
public void onResponse (SynonymsManagementAPIService .SynonymsReloadResult synonymsReloadResult ) {
149
- updatedRulesLatch . countDown ( );
172
+ fail ( "Shouldn't have been able to update a rule" );
150
173
}
151
174
152
175
@ Override
153
176
public void onFailure (Exception e ) {
154
- fail (e );
155
- }
156
- });
157
- }
158
- try {
159
- updatedRulesLatch .await (5 , TimeUnit .SECONDS );
160
- } catch (InterruptedException e ) {
161
- fail (e );
162
- }
163
-
164
- // Updating more rules fails
165
- int rulesToInsert = rules .length - rulesToUpdate ;
166
- CountDownLatch insertRulesLatch = new CountDownLatch (rulesToInsert );
167
- for (int i = rulesToUpdate ; i < rulesToInsert ; i ++) {
168
- synonymsManagementAPIService .putSynonymRule (
169
- // Error here
170
- synonymSetId ,
171
- rules [i ],
172
- randomBoolean (),
173
- new ActionListener <>() {
174
- @ Override
175
- public void onResponse (SynonymsManagementAPIService .SynonymsReloadResult synonymsReloadResult ) {
176
- fail ("Shouldn't have been able to update a rule" );
177
- }
178
-
179
- @ Override
180
- public void onFailure (Exception e ) {
181
- if (e instanceof IllegalArgumentException == false ) {
182
- fail (e );
183
- }
184
- updatedRulesLatch .countDown ();
177
+ if (e instanceof IllegalArgumentException == false ) {
178
+ fail (e );
185
179
}
180
+ updatedRulesLatch .countDown ();
186
181
}
187
- );
188
- }
189
- try {
190
- insertRulesLatch .await (5 , TimeUnit .SECONDS );
191
- } catch (InterruptedException e ) {
192
- fail (e );
193
- }
182
+ }
183
+ );
194
184
}
195
-
196
- @ Override
197
- public void onFailure ( Exception e ) {
185
+ try {
186
+ insertRulesLatch . await ( 5 , TimeUnit . SECONDS );
187
+ } catch ( InterruptedException e ) {
198
188
fail (e );
199
189
}
200
190
}
201
- );
191
+
192
+ @ Override
193
+ public void onFailure (Exception e ) {
194
+ fail (e );
195
+ }
196
+ });
202
197
203
198
latch .await (5 , TimeUnit .SECONDS );
204
199
}
@@ -247,17 +242,22 @@ public void testCreateRuleWithMaxSynonyms() throws InterruptedException {
247
242
@ Override
248
243
public void onResponse (SynonymsManagementAPIService .SynonymsReloadResult synonymsReloadResult ) {
249
244
// Updating a rule fails
250
- synonymsManagementAPIService .putSynonymRule (synonymSetId , randomSynonymRule (ruleId ), randomBoolean (), new ActionListener <>() {
251
- @ Override
252
- public void onResponse (SynonymsManagementAPIService .SynonymsReloadResult synonymsReloadResult ) {
253
- fail ("Should not create a new rule that does not exist when at max capacity" );
254
- }
245
+ synonymsManagementAPIService .putSynonymRule (
246
+ synonymSetId ,
247
+ randomSynonymRule (ruleId ),
248
+ randomBoolean (),
249
+ new ActionListener <>() {
250
+ @ Override
251
+ public void onResponse (SynonymsManagementAPIService .SynonymsReloadResult synonymsReloadResult ) {
252
+ fail ("Should not create a new rule that does not exist when at max capacity" );
253
+ }
255
254
256
- @ Override
257
- public void onFailure (Exception e ) {
258
- latch .countDown ();
255
+ @ Override
256
+ public void onFailure (Exception e ) {
257
+ latch .countDown ();
258
+ }
259
259
}
260
- } );
260
+ );
261
261
}
262
262
263
263
@ Override
0 commit comments