public int run() throws IOException {
    String[] header = new String[]{"Address", "State", "Start Time", "Last Heartbeat Time",
        "Version", "Revision"};

    try {
      List<ProxyStatus> allProxyStatus = mMetaMasterClient.listProxyStatus();
      int liveCount = 0;
      int lostCount = 0;
      int maxAddressLength = 24;
      for (ProxyStatus proxyStatus : allProxyStatus) {
        String state = proxyStatus.getState();
        if (state.equals("ACTIVE")) {
          liveCount++;
        } else if (state.equals("LOST")) {
          lostCount++;
        }
        NetAddress address = proxyStatus.getAddress();
        String addressStr = address.getHost() + ":" + address.getRpcPort();
        if (maxAddressLength < addressStr.length()) {
          maxAddressLength = addressStr.length();
        }
      }
      mPrintStream.printf("%s Proxy instances in the cluster, %s serving and %s lost%n%n",
              liveCount + lostCount, liveCount, lostCount);

      String format = "%-" + maxAddressLength + "s %-8s %-16s %-20s %-32s %-8s%n";
      mPrintStream.printf(format, header);
      for (ProxyStatus proxyStatus : allProxyStatus) {
        NetAddress address = proxyStatus.getAddress();
        BuildVersion version = proxyStatus.getVersion();
        mPrintStream.printf(format,
                address.getHost() + ":" + address.getRpcPort(),
                proxyStatus.getState(),
                DATETIME_FORMAT.format(Instant.ofEpochMilli(proxyStatus.getStartTime())),
                DATETIME_FORMAT.format(Instant.ofEpochMilli(proxyStatus.getLastHeartbeatTime())),
                version.getVersion(), version.getRevision());
      }
      return 0;
    } catch (Exception e) {
      e.printStackTrace();
      return 1;
    }
  }
@Test
  public void listProxyInstancesLongName() throws IOException {
    List<ProxyStatus> longInfoList = prepareInfoListLongName();
    Mockito.when(mMetaMasterClient.listProxyStatus())
            .thenReturn(longInfoList);

    try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
         PrintStream printStream = new PrintStream(outputStream, true, "utf-8")) {
      ProxyCommand proxyCommand = new ProxyCommand(mMetaMasterClient, printStream);
      proxyCommand.run();
      String output = new String(outputStream.toByteArray(), StandardCharsets.UTF_8);
      // CHECKSTYLE.OFF: LineLengthExceed - Much more readable
      List<String> expectedOutput = Arrays.asList("2 Proxy instances in the cluster, 1 serving and 1 lost",
          "",
          "Address                                       State    Start Time       Last Heartbeat Time  Version                          Revision",
          "datacenter-namespace-department-proxy-0:12345 ACTIVE   20230421-182944  20230421-183005      1.0                              abc     ",
          "datacenter-namespace-department-proxy-1:23456 LOST     20230421-182707  20230421-190507      1.1                              abc     ");
      // CHECKSTYLE.ON: LineLengthExceed
      List<String> testOutput = Arrays.asList(output.split("\n"));
      Assert.assertThat(testOutput,
          IsIterableContainingInOrder.contains(expectedOutput.toArray()));
    }
  }