Skip to content

Commit 2b932e3

Browse files
Test serialization via REST test
1 parent a141c45 commit 2b932e3

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

rest-api-spec/src/main/resources/rest-api-spec/test/indices.stats/10_index.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ setup:
4747
- match: { _shards.total: 18 }
4848
- is_true: _all
4949
- is_true: indices.test1
50+
- is_true: indices.test1.uuid
5051
- is_true: indices.test2
52+
- is_true: indices.test2.uuid
5153

5254

5355
---

server/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsTests.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,12 @@
2727
import org.elasticsearch.common.settings.Settings;
2828
import org.elasticsearch.common.xcontent.XContentBuilder;
2929
import org.elasticsearch.common.xcontent.XContentFactory;
30-
import org.elasticsearch.common.xcontent.XContentParser;
31-
import org.elasticsearch.common.xcontent.json.JsonXContent;
3230
import org.elasticsearch.index.engine.CommitStats;
3331
import org.elasticsearch.index.engine.SegmentsStats;
3432
import org.elasticsearch.index.translog.Translog;
3533
import org.elasticsearch.test.ESSingleNodeTestCase;
3634

37-
import java.io.IOException;
3835
import java.util.List;
39-
import java.util.Map;
4036
import java.util.concurrent.TimeUnit;
4137

4238
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
@@ -158,15 +154,10 @@ public void testRefreshListeners() throws Exception {
158154
}
159155

160156
@SuppressWarnings("unchecked")
161-
public void testUuidOnRootStatsIndices() throws IOException {
157+
public void testUuidOnRootStatsIndices() {
162158
String uuid = createIndex("test").indexUUID();
163159
IndicesStatsResponse rsp = client().admin().indices().prepareStats().get();
164-
try (XContentParser parser = createParser(JsonXContent.jsonXContent, rsp.toString())) {
165-
assertEquals(
166-
uuid,
167-
((Map<String, Object>)((Map<String,Object>) parser.map().get("indices")).get("test")).get("uuid")
168-
);
169-
}
160+
assertEquals(uuid, rsp.getIndex("test").getUuid());
170161
}
171162

172163
/**

0 commit comments

Comments
 (0)