|
10 | 10 |
|
11 | 11 | import org.elasticsearch.action.admin.cluster.stats.CCSTelemetrySnapshot.PerClusterCCSTelemetry; |
12 | 12 | import org.elasticsearch.action.admin.cluster.stats.LongMetric.LongMetricValue; |
| 13 | +import org.elasticsearch.common.bytes.BytesArray; |
13 | 14 | import org.elasticsearch.common.io.stream.Writeable; |
| 15 | +import org.elasticsearch.common.xcontent.XContentHelper; |
14 | 16 | import org.elasticsearch.core.Tuple; |
15 | 17 | import org.elasticsearch.test.AbstractWireSerializingTestCase; |
| 18 | +import org.elasticsearch.xcontent.XContentType; |
16 | 19 |
|
17 | 20 | import java.io.IOException; |
18 | 21 | import java.io.InputStream; |
|
21 | 24 | import java.util.Map; |
22 | 25 | import java.util.TreeMap; |
23 | 26 |
|
| 27 | +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertToXContentEquivalent; |
24 | 28 | import static org.hamcrest.Matchers.closeTo; |
25 | 29 | import static org.hamcrest.Matchers.equalTo; |
26 | 30 |
|
@@ -309,8 +313,12 @@ public void testToXContent() throws IOException { |
309 | 313 | clientCounts, |
310 | 314 | perClusterCCSTelemetries |
311 | 315 | ); |
312 | | - String expected = readJSONFromResource("telemetry_test.json"); |
313 | | - assertEquals(expected, snapshot.toString()); |
| 316 | + String expectedJson = readJSONFromResource("telemetry_test.json"); |
| 317 | + assertToXContentEquivalent( |
| 318 | + new BytesArray(expectedJson), |
| 319 | + XContentHelper.toXContent(snapshot, XContentType.JSON, randomBoolean()), |
| 320 | + XContentType.JSON |
| 321 | + ); |
314 | 322 | } |
315 | 323 |
|
316 | 324 | private String readJSONFromResource(String fileName) throws IOException { |
|
0 commit comments