### Question:
TreeFacetField implements Comparable<TreeFacetField>, Serializable, Cloneable { @Override public int compareTo(TreeFacetField o) { int ret = 0; if (o == null) { ret = 1; } else if (this.equals(o)) { ret = 0; } else { ret = (int) (getTotal() - o.getTotal()) | (int) (count - o.count); if (ret == 0) { ret = getValue().compareTo(o.getValue()); if (ret == 0 && StringUtils.isNotBlank(label) && StringUtils.isNotBlank(o.getLabel())) { ret = getLabel().compareTo(o.getLabel()); } } } return ret; } TreeFacetField(String label, String value, long count, long childCount, SortedSet<TreeFacetField> hierarchy); String getLabel(); String getValue(); long getCount(); long getChildCount(); long getTotal(); SortedSet<TreeFacetField> getHierarchy(); boolean hasChildren(); long recalculateChildCount(); @Override int compareTo(TreeFacetField o); SimpleOrderedMap<Object> toMap(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); @Override TreeFacetField clone();  }### Answer:
@Test public void compareTo_null() { final TreeFacetField tff = new TreeFacetField("A", "a", 1, 2, null); assertTrue(tff.compareTo(null) > 0); }
@Test public void compareTo_identical() { final TreeFacetField tff = new TreeFacetField("A", "a", 1, 2, null); final TreeFacetField other = new TreeFacetField("A", "a", 1, 2, null); assertTrue(tff.compareTo(other) == 0); assertTrue(other.compareTo(tff) == 0); }
@Test public void compareTo_total() { final TreeFacetField tff = new TreeFacetField("A", "a", 1, 2, null); final TreeFacetField other = new TreeFacetField("A", "a", 1, 3, null); assertTrue(tff.compareTo(other) < 0); assertTrue(other.compareTo(tff) > 0); }
@Test public void compareTo_nodeCount() { final TreeFacetField tff = new TreeFacetField("A", "a", 1, 2, null); final TreeFacetField other = new TreeFacetField("A", "a", 2, 1, null); assertTrue(tff.compareTo(other) < 0); assertTrue(other.compareTo(tff) > 0); final TreeFacetField other2 = new TreeFacetField("A", "a", 3, 0, null); assertTrue(tff.compareTo(other2) < 0); assertTrue(other2.compareTo(tff) > 0); }
@Test public void compareTo_value() { final TreeFacetField tff = new TreeFacetField("A", "a", 1, 2, null); final TreeFacetField other = new TreeFacetField("A", "b", 1, 2, null); assertTrue(tff.compareTo(other) < 0); assertTrue(other.compareTo(tff) > 0); }
@Test public void compareTo_blankLabel() { final TreeFacetField tff = new TreeFacetField(null, "a", 1, 2, null); final TreeFacetField other = new TreeFacetField("A", "a", 1, 2, null); assertTrue(tff.compareTo(other) == 0); assertTrue(other.compareTo(tff) == 0); }
@Test public void compareTo_byLabel() { final TreeFacetField tff = new TreeFacetField("A", "a", 1, 2, null); final TreeFacetField other = new TreeFacetField("B", "a", 1, 2, null); assertTrue(tff.compareTo(other) < 0); assertTrue(other.compareTo(tff) > 0); }