Skip to content

Commit 0b97e99

Browse files
[CI] Auto commit changes from spotless
1 parent e334330 commit 0b97e99

File tree

1 file changed

+67
-67
lines changed

1 file changed

+67
-67
lines changed

server/src/internalClusterTest/java/org/elasticsearch/synonyms/SynonymsManagementAPIServiceIT.java

+67-67
Original file line numberDiff line numberDiff line change
@@ -129,84 +129,79 @@ public void onFailure(Exception e) {
129129
latch.await(5, TimeUnit.SECONDS);
130130
}
131131

132-
@Repeat(iterations=500)
132+
@Repeat(iterations = 500)
133133
public void testCreateTooManySynonymsUsingRuleUpdates() throws InterruptedException {
134134
CountDownLatch latch = new CountDownLatch(1);
135135
int rulesToUpdate = randomIntBetween(1, 10);
136136
int synonymsToCreate = maxSynonymSets - rulesToUpdate;
137137
String synonymSetId = randomIdentifier();
138-
synonymsManagementAPIService.putSynonymsSet(
139-
synonymSetId,
140-
randomSynonymsSet(synonymsToCreate),
141-
true,
142-
new ActionListener<>() {
143-
@Override
144-
public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) {
145-
// Create as many rules as should fail
146-
SynonymRule[] rules = randomSynonymsSet(atLeast(rulesToUpdate + 1));
147-
CountDownLatch updatedRulesLatch = new CountDownLatch(rulesToUpdate);
148-
for (int i = 0; i < rulesToUpdate; i++) {
149-
synonymsManagementAPIService.putSynonymRule(synonymSetId, rules[i], randomBoolean(), new ActionListener<>() {
138+
synonymsManagementAPIService.putSynonymsSet(synonymSetId, randomSynonymsSet(synonymsToCreate), true, new ActionListener<>() {
139+
@Override
140+
public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) {
141+
// Create as many rules as should fail
142+
SynonymRule[] rules = randomSynonymsSet(atLeast(rulesToUpdate + 1));
143+
CountDownLatch updatedRulesLatch = new CountDownLatch(rulesToUpdate);
144+
for (int i = 0; i < rulesToUpdate; i++) {
145+
synonymsManagementAPIService.putSynonymRule(synonymSetId, rules[i], randomBoolean(), new ActionListener<>() {
146+
@Override
147+
public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) {
148+
updatedRulesLatch.countDown();
149+
}
150+
151+
@Override
152+
public void onFailure(Exception e) {
153+
fail(e);
154+
}
155+
});
156+
}
157+
try {
158+
updatedRulesLatch.await(5, TimeUnit.SECONDS);
159+
} catch (InterruptedException e) {
160+
fail(e);
161+
}
162+
163+
// Updating more rules fails
164+
int rulesToInsert = rules.length - rulesToUpdate;
165+
CountDownLatch insertRulesLatch = new CountDownLatch(rulesToInsert);
166+
for (int i = rulesToUpdate; i < rulesToInsert; i++) {
167+
synonymsManagementAPIService.putSynonymRule(
168+
// Error here
169+
synonymSetId,
170+
rules[i],
171+
randomBoolean(),
172+
new ActionListener<>() {
150173
@Override
151174
public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) {
152-
updatedRulesLatch.countDown();
175+
fail("Shouldn't have been able to update a rule");
153176
}
154177

155178
@Override
156179
public void onFailure(Exception e) {
157-
fail(e);
158-
}
159-
});
160-
}
161-
try {
162-
updatedRulesLatch.await(5, TimeUnit.SECONDS);
163-
} catch (InterruptedException e) {
164-
fail(e);
165-
}
166-
167-
// Updating more rules fails
168-
int rulesToInsert = rules.length - rulesToUpdate;
169-
CountDownLatch insertRulesLatch = new CountDownLatch(rulesToInsert);
170-
for (int i = rulesToUpdate; i < rulesToInsert; i++) {
171-
synonymsManagementAPIService.putSynonymRule(
172-
// Error here
173-
synonymSetId,
174-
rules[i],
175-
randomBoolean(),
176-
new ActionListener<>() {
177-
@Override
178-
public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) {
179-
fail("Shouldn't have been able to update a rule");
180-
}
181-
182-
@Override
183-
public void onFailure(Exception e) {
184-
if (e instanceof IllegalArgumentException == false) {
185-
fail(e);
186-
}
187-
updatedRulesLatch.countDown();
180+
if (e instanceof IllegalArgumentException == false) {
181+
fail(e);
188182
}
183+
updatedRulesLatch.countDown();
189184
}
190-
);
191-
}
192-
try {
193-
insertRulesLatch.await(5, TimeUnit.SECONDS);
194-
} catch (InterruptedException e) {
195-
fail(e);
196-
}
185+
}
186+
);
197187
}
198-
199-
@Override
200-
public void onFailure(Exception e) {
188+
try {
189+
insertRulesLatch.await(5, TimeUnit.SECONDS);
190+
} catch (InterruptedException e) {
201191
fail(e);
202192
}
203193
}
204-
);
194+
195+
@Override
196+
public void onFailure(Exception e) {
197+
fail(e);
198+
}
199+
});
205200

206201
latch.await(5, TimeUnit.SECONDS);
207202
}
208203

209-
@Repeat(iterations=500)
204+
@Repeat(iterations = 500)
210205
public void testUpdateRuleWithMaxSynonyms() throws InterruptedException {
211206
CountDownLatch latch = new CountDownLatch(1);
212207
String synonymSetId = randomIdentifier();
@@ -242,7 +237,7 @@ public void onFailure(Exception e) {
242237
latch.await(5, TimeUnit.SECONDS);
243238
}
244239

245-
@Repeat(iterations=500)
240+
@Repeat(iterations = 500)
246241
public void testCreateRuleWithMaxSynonyms() throws InterruptedException {
247242
CountDownLatch latch = new CountDownLatch(1);
248243
String synonymSetId = randomIdentifier();
@@ -252,17 +247,22 @@ public void testCreateRuleWithMaxSynonyms() throws InterruptedException {
252247
@Override
253248
public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) {
254249
// Updating a rule fails
255-
synonymsManagementAPIService.putSynonymRule(synonymSetId, randomSynonymRule(ruleId), randomBoolean(), new ActionListener<>() {
256-
@Override
257-
public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) {
258-
fail("Should not create a new rule that does not exist when at max capacity");
259-
}
250+
synonymsManagementAPIService.putSynonymRule(
251+
synonymSetId,
252+
randomSynonymRule(ruleId),
253+
randomBoolean(),
254+
new ActionListener<>() {
255+
@Override
256+
public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) {
257+
fail("Should not create a new rule that does not exist when at max capacity");
258+
}
260259

261-
@Override
262-
public void onFailure(Exception e) {
263-
latch.countDown();
260+
@Override
261+
public void onFailure(Exception e) {
262+
latch.countDown();
263+
}
264264
}
265-
});
265+
);
266266
}
267267

268268
@Override

0 commit comments

Comments
 (0)