### Question:
HServerInfo extends VersionedWritable implements WritableComparable<HServerInfo> { public int compareTo(HServerInfo o) { int compare = this.serverAddress.compareTo(o.getServerAddress()); if (compare != 0) return compare; if (this.webuiport != o.getInfoPort()) return this.webuiport - o.getInfoPort(); if (this.startCode != o.getStartCode()) return (int)(this.startCode - o.getStartCode()); return 0; } HServerInfo();  HServerInfo(final HServerAddress serverAddress, final int webuiport);  HServerInfo(HServerAddress serverAddress, long startCode,
      final int webuiport);  HServerInfo(HServerInfo other); byte getVersion(); synchronized HServerAddress getServerAddress(); synchronized long getStartCode(); int getInfoPort(); int getWebuiPort(); String getHostname(); @Override synchronized String toString(); @Override boolean equals(Object obj); @Override int hashCode(); void readFields(DataInput in); void write(DataOutput out); int compareTo(HServerInfo o);  }### Answer:
@Test public void testCompareTo() { HServerAddress hsa1 = new HServerAddress("localhost", 1234); HServerInfo hsi1 = new HServerInfo(hsa1, 1L, 5678); HServerAddress hsa2 = new HServerAddress("localhost", 1235); HServerInfo hsi2 = new HServerInfo(hsa2, 1L, 5678); assertTrue(hsi1.compareTo(hsi1) == 0); assertTrue(hsi2.compareTo(hsi2) == 0); int compare1 = hsi1.compareTo(hsi2); int compare2 = hsi2.compareTo(hsi1); assertTrue((compare1 > 0)? compare2 < 0: compare2 > 0); }