|
23 | 23 |
|
24 | 24 | import java.io.IOException; |
25 | 25 | import java.util.ArrayList; |
26 | | -import java.util.Base64; |
27 | 26 | import java.util.Collection; |
28 | 27 | import java.util.Collections; |
29 | 28 | import java.util.List; |
@@ -310,31 +309,16 @@ public void testChecksForCancellation() { |
310 | 309 | })); |
311 | 310 | } |
312 | 311 |
|
313 | | - public void testWriteToPre8_0() throws IOException { |
314 | | - FieldStats fieldStats = randomFieldStats("test"); |
315 | | - MappingStats mappingStats = new MappingStats(Collections.singleton(fieldStats), Collections.emptyList()); |
316 | | - Version version = VersionUtils.randomPreviousCompatibleVersion(random(), Version.V_8_0_0); |
| 312 | + public void testWriteTo() throws IOException { |
| 313 | + MappingStats instance = createTestInstance(); |
317 | 314 | BytesStreamOutput out = new BytesStreamOutput(); |
| 315 | + Version version = VersionUtils.randomCompatibleVersion(random(), Version.CURRENT); |
318 | 316 | out.setVersion(version); |
319 | | - mappingStats.writeTo(out); |
| 317 | + instance.writeTo(out); |
320 | 318 | StreamInput in = StreamInput.wrap(out.bytes().toBytesRef().bytes); |
321 | 319 | in.setVersion(version); |
322 | 320 | MappingStats deserialized = new MappingStats(in); |
323 | | - assertEquals("{\"mappings\":{\"field_types\":[" + |
324 | | - "{\"name\":\"test\",\"count\":" + fieldStats.count+ ",\"index_count\":" + fieldStats.indexCount + |
325 | | - ",\"script_count\":0}],\"runtime_field_types\":[]}}", |
326 | | - Strings.toString(deserialized)); |
327 | | - } |
328 | | - |
329 | | - public void testReadFromPre8_0() throws IOException { |
330 | | - String base64EncodedFromPre8_0 = "AQR0ZXN0qebzzQGSg/HlBgAAAAAAAAAA"; |
331 | | - byte[] bytes = Base64.getDecoder().decode(base64EncodedFromPre8_0); |
332 | | - Version version = VersionUtils.randomPreviousCompatibleVersion(random(), Version.V_8_0_0); |
333 | | - StreamInput in = StreamInput.wrap(bytes); |
334 | | - in.setVersion(version); |
335 | | - MappingStats deserialized = new MappingStats(in); |
336 | | - assertEquals("{\"mappings\":{\"field_types\":" + |
337 | | - "[{\"name\":\"test\",\"count\":431813417,\"index_count\":1824276882,\"script_count\":0}],\"runtime_field_types\":[]}}", |
338 | | - Strings.toString(deserialized)); |
| 321 | + assertEquals(instance.getFieldTypeStats(), deserialized.getFieldTypeStats()); |
| 322 | + assertEquals(instance.getRuntimeFieldStats(), deserialized.getRuntimeFieldStats()); |
339 | 323 | } |
340 | 324 | } |
0 commit comments