Remove fromXContent from IndexUpgradeInfoResponse (#35934)
Such method is there only for testing purposes, it is not needed.
This commit is contained in:
parent
ad1f0dccd4
commit
7e772e311d
|
@ -9,54 +9,18 @@ import org.elasticsearch.action.ActionResponse;
|
|||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg;
|
||||
|
||||
public class IndexUpgradeInfoResponse extends ActionResponse implements ToXContentObject {
|
||||
|
||||
private static final ParseField INDICES = new ParseField("indices");
|
||||
private static final ParseField ACTION_REQUIRED = new ParseField("action_required");
|
||||
|
||||
private static final ConstructingObjectParser<IndexUpgradeInfoResponse, String> PARSER =
|
||||
new ConstructingObjectParser<>("IndexUpgradeInfoResponse",
|
||||
true,
|
||||
(a, c) -> {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> map = (Map<String, Object>)a[0];
|
||||
Map<String, UpgradeActionRequired> actionsRequired = map.entrySet().stream()
|
||||
.filter(e -> {
|
||||
if (e.getValue() instanceof Map == false) {
|
||||
return false;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> value =(Map<String, Object>)e.getValue();
|
||||
return value.containsKey(ACTION_REQUIRED.getPreferredName());
|
||||
})
|
||||
.collect(Collectors.toMap(
|
||||
Map.Entry::getKey,
|
||||
e -> {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> value = (Map<String, Object>) e.getValue();
|
||||
return UpgradeActionRequired.fromString((String)value.get(ACTION_REQUIRED.getPreferredName()));
|
||||
}
|
||||
));
|
||||
return new IndexUpgradeInfoResponse(actionsRequired);
|
||||
});
|
||||
|
||||
static {
|
||||
PARSER.declareObject(constructorArg(), (p, c) -> p.map(), INDICES);
|
||||
}
|
||||
|
||||
|
||||
private Map<String, UpgradeActionRequired> actions;
|
||||
|
||||
public IndexUpgradeInfoResponse() {
|
||||
|
@ -113,8 +77,4 @@ public class IndexUpgradeInfoResponse extends ActionResponse implements ToXConte
|
|||
public int hashCode() {
|
||||
return Objects.hash(actions);
|
||||
}
|
||||
|
||||
public static IndexUpgradeInfoResponse fromXContent(XContentParser parser) {
|
||||
return PARSER.apply(parser, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.elasticsearch.protocol.xpack.migration;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.protocol.AbstractHlrcStreamableXContentTestCase;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
@ -19,12 +18,7 @@ public class IndexUpgradeInfoResponseTests extends
|
|||
AbstractHlrcStreamableXContentTestCase<IndexUpgradeInfoResponse, org.elasticsearch.client.migration.IndexUpgradeInfoResponse> {
|
||||
|
||||
@Override
|
||||
protected IndexUpgradeInfoResponse doParseInstance(XContentParser parser) {
|
||||
return IndexUpgradeInfoResponse.fromXContent(parser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.elasticsearch.client.migration.IndexUpgradeInfoResponse doHlrcParseInstance(XContentParser parser) throws IOException {
|
||||
public org.elasticsearch.client.migration.IndexUpgradeInfoResponse doHlrcParseInstance(XContentParser parser) {
|
||||
return org.elasticsearch.client.migration.IndexUpgradeInfoResponse.fromXContent(parser);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue