@@ -138,66 +138,67 @@ public void testCreateTooManySynonymsUsingRuleUpdates() throws InterruptedExcept
138
138
randomBoolean (),
139
139
new ActionListener <>() {
140
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 ], true , new ActionListener <>() {
147
- @ Override
148
- public void onResponse (SynonymsManagementAPIService .SynonymsReloadResult synonymsReloadResult ) {
149
- updatedRulesLatch .countDown ();
150
- }
151
-
152
- @ Override
153
- 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 <>() {
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 ], true , new ActionListener <>() {
174
147
@ Override
175
148
public void onResponse (SynonymsManagementAPIService .SynonymsReloadResult synonymsReloadResult ) {
176
- fail ( "Shouldn't have been able to update a rule" );
149
+ updatedRulesLatch . countDown ( );
177
150
}
178
151
179
152
@ Override
180
153
public void onFailure (Exception e ) {
181
- if (e instanceof IllegalArgumentException == false ) {
182
- fail (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 ();
183
185
}
184
- updatedRulesLatch .countDown ();
185
186
}
186
- }
187
- );
187
+ );
188
+ }
189
+ try {
190
+ insertRulesLatch .await (5 , TimeUnit .SECONDS );
191
+ } catch (InterruptedException e ) {
192
+ fail (e );
193
+ }
188
194
}
189
- try {
190
- insertRulesLatch . await ( 5 , TimeUnit . SECONDS );
191
- } catch ( InterruptedException e ) {
195
+
196
+ @ Override
197
+ public void onFailure ( Exception e ) {
192
198
fail (e );
193
199
}
194
200
}
195
-
196
- @ Override
197
- public void onFailure (Exception e ) {
198
- fail (e );
199
- }
200
- });
201
+ );
201
202
202
203
latch .await (5 , TimeUnit .SECONDS );
203
204
}
0 commit comments