Skip to content

Commit 9f78848

Browse files
[TEST] Fix fix-PutSynonymsActionRequestSerializingTests equality tests (elastic#136677)
Relates elastic#136414 `randomValueOtherThan` does not handle arrays. Fixing this by mutating `synonymRules` as a list before converting back to array. Closes elastic#136652
1 parent ecb6afb commit 9f78848

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

server/src/test/java/org/elasticsearch/action/synonyms/PutSynonymsActionRequestSerializingTests.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import org.elasticsearch.test.AbstractWireSerializingTestCase;
1515

1616
import java.io.IOException;
17+
import java.util.Arrays;
18+
import java.util.List;
1719

1820
import static org.elasticsearch.action.synonyms.SynonymsTestUtils.randomSynonymsSet;
1921

@@ -32,14 +34,14 @@ protected PutSynonymsAction.Request createTestInstance() {
3234
@Override
3335
protected PutSynonymsAction.Request mutateInstance(PutSynonymsAction.Request instance) throws IOException {
3436
String synonymsSetId = instance.synonymsSetId();
35-
SynonymRule[] synonymRules = instance.synonymRules();
37+
List<SynonymRule> synonymRules = Arrays.asList(instance.synonymRules());
3638
boolean refresh = instance.refresh();
3739
switch (between(0, 2)) {
3840
case 0 -> synonymsSetId = randomValueOtherThan(synonymsSetId, () -> randomIdentifier());
39-
case 1 -> synonymRules = randomValueOtherThan(synonymRules, () -> randomSynonymsSet());
41+
case 1 -> synonymRules = randomValueOtherThan(synonymRules, () -> Arrays.asList(randomSynonymsSet()));
4042
case 2 -> refresh = refresh == false;
4143
default -> throw new AssertionError("Illegal randomisation branch");
4244
}
43-
return new PutSynonymsAction.Request(synonymsSetId, synonymRules, refresh);
45+
return new PutSynonymsAction.Request(synonymsSetId, synonymRules.toArray(new SynonymRule[0]), refresh);
4446
}
4547
}

0 commit comments

Comments
 (0)