Skip to content

Commit 8091fd2

Browse files
Fix HLRC MigrateAction equals (#70360)
HLRC MigrateAction.equals did not consider the `enabled` flag, fixed
1 parent be38621 commit 8091fd2

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

client/rest-high-level/src/main/java/org/elasticsearch/client/ilm/MigrateAction.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ public String getName() {
5656
return NAME;
5757
}
5858

59+
boolean isEnabled() {
60+
return enabled;
61+
}
62+
5963
@Override
6064
public int hashCode() {
6165
return Objects.hashCode(enabled);
@@ -69,7 +73,7 @@ public boolean equals(Object obj) {
6973
if (obj.getClass() != getClass()) {
7074
return false;
7175
}
72-
return true;
76+
return enabled == ((MigrateAction) obj).enabled;
7377
}
7478

7579
@Override

client/rest-high-level/src/test/java/org/elasticsearch/client/ilm/MigrateActionTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import org.elasticsearch.common.xcontent.XContentParser;
1111
import org.elasticsearch.test.AbstractXContentTestCase;
12+
import org.elasticsearch.test.EqualsHashCodeTestUtils;
1213

1314
import java.io.IOException;
1415

@@ -32,4 +33,10 @@ static MigrateAction randomInstance() {
3233
protected boolean supportsUnknownFields() {
3334
return false;
3435
}
36+
37+
public void testEqualsHashCode() {
38+
EqualsHashCodeTestUtils.checkEqualsAndHashCode(createTestInstance(),
39+
m -> new MigrateAction(m.isEnabled()),
40+
m -> new MigrateAction(m.isEnabled() == false));
41+
}
3542
}

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/MigrateActionTests.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ protected MigrateAction doParseInstance(XContentParser parser) throws IOExceptio
4242

4343
@Override
4444
protected MigrateAction createTestInstance() {
45-
return new MigrateAction();
45+
return new MigrateAction(randomBoolean());
46+
}
47+
48+
@Override
49+
protected MigrateAction mutateInstance(MigrateAction instance) throws IOException {
50+
return new MigrateAction(instance.isEnabled() == false);
4651
}
4752

4853
@Override

0 commit comments

Comments
 (0)