|
25 | 25 | import org.elasticsearch.cluster.metadata.MetaData.Custom;
|
26 | 26 | import org.elasticsearch.common.ParseField;
|
27 | 27 | import org.elasticsearch.common.UUIDs;
|
| 28 | +import org.elasticsearch.common.bytes.BytesReference; |
28 | 29 | import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
29 | 30 | import org.elasticsearch.common.io.stream.NamedWriteableRegistry.Entry;
|
30 | 31 | import org.elasticsearch.common.io.stream.Writeable;
|
31 | 32 | import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
32 | 33 | import org.elasticsearch.common.xcontent.ToXContent;
|
33 |
| -import org.elasticsearch.common.xcontent.XContentBuilder; |
34 | 34 | import org.elasticsearch.common.xcontent.XContentFactory;
|
35 | 35 | import org.elasticsearch.common.xcontent.XContentParser;
|
36 | 36 | import org.elasticsearch.common.xcontent.XContentType;
|
|
40 | 40 | import org.elasticsearch.persistent.PersistentTasksCustomMetaData.Builder;
|
41 | 41 | import org.elasticsearch.persistent.PersistentTasksCustomMetaData.PersistentTask;
|
42 | 42 | import org.elasticsearch.persistent.TestPersistentTasksPlugin.Status;
|
43 |
| -import org.elasticsearch.persistent.TestPersistentTasksPlugin.TestPersistentTasksExecutor; |
44 | 43 | import org.elasticsearch.persistent.TestPersistentTasksPlugin.TestParams;
|
| 44 | +import org.elasticsearch.persistent.TestPersistentTasksPlugin.TestPersistentTasksExecutor; |
45 | 45 |
|
46 | 46 | import java.io.IOException;
|
47 | 47 | import java.util.ArrayList;
|
@@ -127,27 +127,13 @@ protected PersistentTasksCustomMetaData doParseInstance(XContentParser parser) t
|
127 | 127 | return PersistentTasksCustomMetaData.fromXContent(parser);
|
128 | 128 | }
|
129 | 129 |
|
| 130 | +/* |
130 | 131 | @Override
|
131 | 132 | protected XContentBuilder toXContent(Custom instance, XContentType contentType) throws IOException {
|
132 | 133 | return toXContent(instance, contentType, new ToXContent.MapParams(
|
133 | 134 | Collections.singletonMap(MetaData.CONTEXT_MODE_PARAM, MetaData.XContentContext.API.toString())));
|
134 | 135 | }
|
135 |
| - |
136 |
| - protected XContentBuilder toXContent(Custom instance, XContentType contentType, ToXContent.MapParams params) throws IOException { |
137 |
| - // We need all attribute to be serialized/de-serialized for testing |
138 |
| - XContentBuilder builder = XContentFactory.contentBuilder(contentType); |
139 |
| - if (randomBoolean()) { |
140 |
| - builder.prettyPrint(); |
141 |
| - } |
142 |
| - if (instance.isFragment()) { |
143 |
| - builder.startObject(); |
144 |
| - } |
145 |
| - instance.toXContent(builder, params); |
146 |
| - if (instance.isFragment()) { |
147 |
| - builder.endObject(); |
148 |
| - } |
149 |
| - return builder; |
150 |
| - } |
| 136 | +*/ |
151 | 137 |
|
152 | 138 | private String addRandomTask(Builder builder) {
|
153 | 139 | String taskId = UUIDs.base64UUID();
|
@@ -179,10 +165,9 @@ public void testSerializationContext() throws Exception {
|
179 | 165 | Collections.singletonMap(MetaData.CONTEXT_MODE_PARAM, randomFrom(CONTEXT_MODE_SNAPSHOT, CONTEXT_MODE_GATEWAY)));
|
180 | 166 |
|
181 | 167 | XContentType xContentType = randomFrom(XContentType.values());
|
182 |
| - XContentBuilder builder = toXContent(testInstance, xContentType, params); |
183 |
| - XContentBuilder shuffled = shuffleXContent(builder); |
| 168 | + BytesReference shuffled = toShuffledXContent(testInstance, xContentType, params, false); |
184 | 169 |
|
185 |
| - XContentParser parser = createParser(XContentFactory.xContent(xContentType), shuffled.bytes()); |
| 170 | + XContentParser parser = createParser(XContentFactory.xContent(xContentType), shuffled); |
186 | 171 | PersistentTasksCustomMetaData newInstance = doParseInstance(parser);
|
187 | 172 | assertNotSame(newInstance, testInstance);
|
188 | 173 |
|
|
0 commit comments