public static List<SlowDiskReportProto> convertSlowDiskInfo(
      SlowDiskReports slowDisks) {
    if (slowDisks.getSlowDisks().size() == 0) {
      return Collections.emptyList();
    }

    List<SlowDiskReportProto> slowDiskInfoProtos =
        new ArrayList<>(slowDisks.getSlowDisks().size());
    for (Map.Entry<String, Map<SlowDiskReports.DiskOp, Double>> entry :
        slowDisks.getSlowDisks().entrySet()) {
      SlowDiskReportProto.Builder builder = SlowDiskReportProto.newBuilder();
      builder.setBasePath(entry.getKey());
      Map<SlowDiskReports.DiskOp, Double> value = entry.getValue();
      if (value.get(SlowDiskReports.DiskOp.METADATA) != null) {
        builder.setMeanMetadataOpLatency(value.get(
            SlowDiskReports.DiskOp.METADATA));
      }
      if (value.get(SlowDiskReports.DiskOp.READ) != null) {
        builder.setMeanReadIoLatency(value.get(
            SlowDiskReports.DiskOp.READ));
      }
      if (value.get(SlowDiskReports.DiskOp.WRITE) != null) {
        builder.setMeanWriteIoLatency(value.get(
            SlowDiskReports.DiskOp.WRITE));
      }
      slowDiskInfoProtos.add(builder.build());
    }

    return slowDiskInfoProtos;
  }
@Test
  public void testSlowDiskInfoPBHelper() {
    // Test with a map that has a few slow disk entries.
    final SlowDiskReports slowDisks = SlowDiskReports.create(
        ImmutableMap.of(
            "disk1", ImmutableMap.of(SlowDiskReports.DiskOp.METADATA, 0.5),
            "disk2", ImmutableMap.of(SlowDiskReports.DiskOp.READ, 1.0,
                SlowDiskReports.DiskOp.WRITE, 1.0),
            "disk3", ImmutableMap.of(SlowDiskReports.DiskOp.METADATA, 1.2,
                SlowDiskReports.DiskOp.READ, 1.5,
                SlowDiskReports.DiskOp.WRITE, 1.3)));
    SlowDiskReports slowDisksConverted1 = PBHelper.convertSlowDiskInfo(
        PBHelper.convertSlowDiskInfo(slowDisks));
    assertTrue(
        "Expected map:" + slowDisks + ", got map:" +
            slowDisksConverted1.getSlowDisks(),
        slowDisksConverted1.equals(slowDisks));

    // Test with an empty map
    SlowDiskReports slowDisksConverted2 = PBHelper.convertSlowDiskInfo(
        PBHelper.convertSlowDiskInfo(SlowDiskReports.EMPTY_REPORT));
    assertTrue(
        "Expected empty map:" + ", got map:" + slowDisksConverted2,
        slowDisksConverted2.equals(SlowDiskReports.EMPTY_REPORT));
  }