Skip to content

Commit aa0b957

Browse files
committed
added missing serialization tests
1 parent 636751b commit aa0b957

File tree

5 files changed

+124
-0
lines changed

5 files changed

+124
-0
lines changed

x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexAction.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import java.io.IOException;
4848
import java.util.List;
4949
import java.util.Map;
50+
import java.util.Objects;
5051

5152
public class CreateAndFollowIndexAction extends Action<CreateAndFollowIndexAction.Request, CreateAndFollowIndexAction.Response,
5253
CreateAndFollowIndexAction.RequestBuilder> {
@@ -97,6 +98,19 @@ public void writeTo(StreamOutput out) throws IOException {
9798
super.writeTo(out);
9899
followRequest.writeTo(out);
99100
}
101+
102+
@Override
103+
public boolean equals(Object o) {
104+
if (this == o) return true;
105+
if (o == null || getClass() != o.getClass()) return false;
106+
Request request = (Request) o;
107+
return Objects.equals(followRequest, request.followRequest);
108+
}
109+
110+
@Override
111+
public int hashCode() {
112+
return Objects.hash(followRequest);
113+
}
100114
}
101115

102116
public static class Response extends ActionResponse implements ToXContentObject {
@@ -153,6 +167,21 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
153167
builder.endObject();
154168
return builder;
155169
}
170+
171+
@Override
172+
public boolean equals(Object o) {
173+
if (this == o) return true;
174+
if (o == null || getClass() != o.getClass()) return false;
175+
Response response = (Response) o;
176+
return followIndexCreated == response.followIndexCreated &&
177+
followIndexShardsAcked == response.followIndexShardsAcked &&
178+
indexFollowingStarted == response.indexFollowingStarted;
179+
}
180+
181+
@Override
182+
public int hashCode() {
183+
return Objects.hash(followIndexCreated, followIndexShardsAcked, indexFollowingStarted);
184+
}
156185
}
157186

158187
public static class RequestBuilder extends ActionRequestBuilder<Request, Response, CreateAndFollowIndexAction.RequestBuilder> {

x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/FollowIndexAction.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import java.util.Iterator;
5050
import java.util.List;
5151
import java.util.Map;
52+
import java.util.Objects;
5253
import java.util.Set;
5354
import java.util.concurrent.atomic.AtomicInteger;
5455
import java.util.concurrent.atomic.AtomicReferenceArray;
@@ -135,6 +136,7 @@ public void readFrom(StreamInput in) throws IOException {
135136
leaderIndex = in.readString();
136137
followIndex = in.readString();
137138
batchSize = in.readVLong();
139+
concurrentProcessors = in.readVInt();
138140
processorMaxTranslogBytes = in.readVLong();
139141
}
140142

@@ -144,8 +146,26 @@ public void writeTo(StreamOutput out) throws IOException {
144146
out.writeString(leaderIndex);
145147
out.writeString(followIndex);
146148
out.writeVLong(batchSize);
149+
out.writeVInt(concurrentProcessors);
147150
out.writeVLong(processorMaxTranslogBytes);
148151
}
152+
153+
@Override
154+
public boolean equals(Object o) {
155+
if (this == o) return true;
156+
if (o == null || getClass() != o.getClass()) return false;
157+
Request request = (Request) o;
158+
return batchSize == request.batchSize &&
159+
concurrentProcessors == request.concurrentProcessors &&
160+
processorMaxTranslogBytes == request.processorMaxTranslogBytes &&
161+
Objects.equals(leaderIndex, request.leaderIndex) &&
162+
Objects.equals(followIndex, request.followIndex);
163+
}
164+
165+
@Override
166+
public int hashCode() {
167+
return Objects.hash(leaderIndex, followIndex, batchSize, concurrentProcessors, processorMaxTranslogBytes);
168+
}
149169
}
150170

151171
public static class RequestBuilder extends ActionRequestBuilder<Request, Response, FollowIndexAction.RequestBuilder> {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
package org.elasticsearch.xpack.ccr.action;
7+
8+
import org.elasticsearch.test.AbstractStreamableTestCase;
9+
10+
public class CreateAndFollowIndexRequestTests extends AbstractStreamableTestCase<CreateAndFollowIndexAction.Request> {
11+
12+
@Override
13+
protected CreateAndFollowIndexAction.Request createBlankInstance() {
14+
return new CreateAndFollowIndexAction.Request();
15+
}
16+
17+
@Override
18+
protected CreateAndFollowIndexAction.Request createTestInstance() {
19+
CreateAndFollowIndexAction.Request request = new CreateAndFollowIndexAction.Request();
20+
request.setFollowRequest(FollowIndexRequestTests.createTestRequest());
21+
return request;
22+
}
23+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
package org.elasticsearch.xpack.ccr.action;
7+
8+
import org.elasticsearch.test.AbstractStreamableTestCase;
9+
10+
public class CreateAndFollowIndexResponseTests extends AbstractStreamableTestCase<CreateAndFollowIndexAction.Response> {
11+
12+
@Override
13+
protected CreateAndFollowIndexAction.Response createBlankInstance() {
14+
return new CreateAndFollowIndexAction.Response();
15+
}
16+
17+
@Override
18+
protected CreateAndFollowIndexAction.Response createTestInstance() {
19+
return new CreateAndFollowIndexAction.Response(randomBoolean(), randomBoolean(), randomBoolean());
20+
}
21+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
package org.elasticsearch.xpack.ccr.action;
7+
8+
import org.elasticsearch.test.AbstractStreamableTestCase;
9+
10+
public class FollowIndexRequestTests extends AbstractStreamableTestCase<FollowIndexAction.Request> {
11+
12+
@Override
13+
protected FollowIndexAction.Request createBlankInstance() {
14+
return new FollowIndexAction.Request();
15+
}
16+
17+
@Override
18+
protected FollowIndexAction.Request createTestInstance() {
19+
return createTestRequest();
20+
}
21+
22+
static FollowIndexAction.Request createTestRequest() {
23+
FollowIndexAction.Request request = new FollowIndexAction.Request();
24+
request.setLeaderIndex(randomAlphaOfLength(4));
25+
request.setFollowIndex(randomAlphaOfLength(4));
26+
request.setBatchSize(randomNonNegativeLong());
27+
request.setConcurrentProcessors(randomIntBetween(0, Integer.MAX_VALUE));
28+
request.setProcessorMaxTranslogBytes(randomNonNegativeLong());
29+
return request;
30+
}
31+
}

0 commit comments

Comments
 (0)