@Test
public void shouldAggregateBytesStatistics() {

  FeatureNameStatistics stat1 =
      FeatureNameStatistics.newBuilder()
          .setBytesStats(
              BytesStatistics.newBuilder()
                  .setCommonStats(
                      CommonStatistics.newBuilder()
                          .setTotNumValues(5)
                          .setNumNonMissing(5)
                          .setAvgNumValues(1)
                          .setMaxNumValues(1)
                          .setMinNumValues(1)
                          .setNumMissing(0))
                  .setUnique(4)
                  .setAvgNumBytes(6)
                  .setMaxNumBytes(10)
                  .setMinNumBytes(0))
          .setType(Type.BYTES)
          .setPath(Path.newBuilder().addStep("feature").build())
          .build();
  FeatureNameStatistics stat2 =
      FeatureNameStatistics.newBuilder()
          .setBytesStats(
              BytesStatistics.newBuilder()
                  .setCommonStats(
                      CommonStatistics.newBuilder()
                          .setTotNumValues(5)
                          .setNumNonMissing(5)
                          .setAvgNumValues(1)
                          .setMaxNumValues(1)
                          .setMinNumValues(1)
                          .setNumMissing(1))
                  .setUnique(4)
                  .setAvgNumBytes(4)
                  .setMaxNumBytes(20)
                  .setMinNumBytes(1))
          .setType(Type.BYTES)
          .setPath(Path.newBuilder().addStep("feature").build())
          .build();
  FeatureNameStatistics expected =
      FeatureNameStatistics.newBuilder()
          .setBytesStats(
              BytesStatistics.newBuilder()
                  .setCommonStats(
                      CommonStatistics.newBuilder()
                          .setTotNumValues(10)
                          .setNumNonMissing(10)
                          .setAvgNumValues(1)
                          .setMaxNumValues(1)
                          .setMinNumValues(1)
                          .setNumMissing(1))
                  .setAvgNumBytes(5)
                  .setMaxNumBytes(20)
                  .setMinNumBytes(0))
          .setType(Type.BYTES)
          .setPath(Path.newBuilder().addStep("feature").build())
          .build();
  assertThat(
      statsService.mergeStatistics(Arrays.asList(Arrays.asList(stat1, stat2))),
      equalTo(Arrays.asList(expected)));
}