### Question:
IndexMatch implements WritableComparable<IndexMatch> { @Override public int compareTo(IndexMatch other) { Preconditions.checkNotNull(other); return uid.compareTo(other.uid); } IndexMatch(final String uid); protected  IndexMatch();  IndexMatch(final String uid, final JexlNode myNode);  IndexMatch(final String uid, final JexlNode myNode, final String shard);  IndexMatch(final String uid, final JexlNode myNode, final IndexMatchType type);  IndexMatch(Set<JexlNode> nodes, String uid, final IndexMatchType type); String getUid(); JexlNode getNode(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(IndexMatch other); void setType(IndexMatchType type); void set(JexlNode node); void add(JexlNode node); @Override String toString(); @Override void readFields(DataInput in); @Override void write(DataOutput out);  }### Answer:
@Test public void testCompareTo() { IndexMatch left = new IndexMatch("uid0"); IndexMatch right = new IndexMatch("uid0"); assertEquals(0, left.compareTo(right)); assertEquals(0, right.compareTo(left)); }
@Test public void testCompareToWithDifferentUids() { IndexMatch left = new IndexMatch("uid0"); IndexMatch right = new IndexMatch("uid2"); assertEquals(-2, left.compareTo(right)); assertEquals(2, right.compareTo(left)); }
@Test public void testCompareToWithDifferentShards() { JexlNode eqNode = JexlNodeFactory.buildEQNode("FIELD", "value"); IndexMatch left = new IndexMatch("uid0", eqNode, "20190413_0"); IndexMatch right = new IndexMatch("uid0", eqNode, "20190413_1"); assertEquals(0, left.compareTo(right)); assertEquals(0, right.compareTo(left)); }
@Test public void testCompareToWithDifferentJexlNodes() { JexlNode leftNode = JexlNodeFactory.buildEQNode("FIELD0", "value0"); JexlNode rightNode = JexlNodeFactory.buildEQNode("FIELD2", "value2"); IndexMatch left = new IndexMatch("uid0", leftNode); IndexMatch right = new IndexMatch("uid0", rightNode); assertEquals(0, left.compareTo(right)); assertEquals(0, right.compareTo(left)); }