### Question:
OrcMetadataReader implements MetadataReader { static StringStatistics toStringStatistics(HiveWriterVersion hiveWriterVersion, OrcProto.StringStatistics stringStatistics, boolean isRowGroup) { if (hiveWriterVersion == ORIGINAL && !isRowGroup) { return null; } Slice maximum = stringStatistics.hasMaximum() ? maxStringTruncateToValidRange(byteStringToSlice(stringStatistics.getMaximumBytes()), hiveWriterVersion) : null; Slice minimum = stringStatistics.hasMinimum() ? minStringTruncateToValidRange(byteStringToSlice(stringStatistics.getMinimumBytes()), hiveWriterVersion) : null; long sum = stringStatistics.hasSum() ? stringStatistics.getSum() : 0; return new StringStatistics(minimum, maximum, sum); }  @Override PostScript readPostScript(InputStream inputStream); @Override Metadata readMetadata(HiveWriterVersion hiveWriterVersion, InputStream inputStream); @Override Footer readFooter(HiveWriterVersion hiveWriterVersion, InputStream inputStream); @Override StripeFooter readStripeFooter(ColumnMetadata<OrcType> types, InputStream inputStream, ZoneId legacyFileTimeZone); @Override List<RowGroupIndex> readRowIndexes(HiveWriterVersion hiveWriterVersion, InputStream inputStream); @Override List<BloomFilter> readBloomFilterIndexes(InputStream inputStream); @VisibleForTesting static Slice maxStringTruncateToValidRange(Slice value, HiveWriterVersion version); @VisibleForTesting static Slice minStringTruncateToValidRange(Slice value, HiveWriterVersion version);  }### Answer:
@Test public void testToStringStatistics() { assertNull(OrcMetadataReader.toStringStatistics( ORIGINAL, OrcProto.StringStatistics.newBuilder() .setMinimum("ant") .setMaximum("cat") .setSum(44) .build(), false)); for (boolean isRowGroup : ImmutableList.of(true, false)) { assertEquals( OrcMetadataReader.toStringStatistics( ORC_HIVE_8732, OrcProto.StringStatistics.newBuilder() .setSum(45) .build(), isRowGroup), new StringStatistics(null, null, 45)); } assertEquals( OrcMetadataReader.toStringStatistics( ORIGINAL, OrcProto.StringStatistics.newBuilder() .setSum(45) .build(), true), new StringStatistics(null, null, 45)); assertEquals( OrcMetadataReader.toStringStatistics( ORC_HIVE_8732, OrcProto.StringStatistics.newBuilder() .setMinimum("ant") .build(), true), new StringStatistics(utf8Slice("ant"), null, 0)); assertEquals( OrcMetadataReader.toStringStatistics( ORC_HIVE_8732, OrcProto.StringStatistics.newBuilder() .setMaximum("cat") .build(), true), new StringStatistics(null, utf8Slice("cat"), 0)); assertEquals( OrcMetadataReader.toStringStatistics( ORC_HIVE_8732, OrcProto.StringStatistics.newBuilder() .setMinimum("ant") .setMaximum("cat") .setSum(79) .build(), true), new StringStatistics(utf8Slice("ant"), utf8Slice("cat"), 79)); for (Slice prefix : ALL_UTF8_SEQUENCES) { for (int testCodePoint : TEST_CODE_POINTS) { Slice codePoint = codePointToUtf8(testCodePoint); for (Slice suffix : ALL_UTF8_SEQUENCES) { Slice testValue = concatSlice(prefix, codePoint, suffix); testStringStatisticsTruncation(testValue, ORIGINAL); testStringStatisticsTruncation(testValue, ORC_HIVE_8732); } } } }