TagComparator implements Comparator<Tag>, Serializable { @Override public int compare(Tag tag, Tag tag1) { if (tag.getKey().equals(tag1.getKey())) { return tag.getValue().compareTo(tag1.getValue()); } return tag.getKey().compareTo(tag1.getKey()); }  @Override int compare(Tag tag, Tag tag1);  }
@Test public void testCompareFirstLevel() throws Exception { assertTrue(comparator.compare(a, b) < 0); assertTrue(comparator.compare(b, a) > 0); }
@Test public void testCompareSecondLevel() throws Exception { assertTrue(comparator.compare(aa, ab) < 0); assertTrue(comparator.compare(ab, aa) > 0); }
@Test public void testCompareEqual() throws Exception { assertTrue(comparator.compare(a, aa) == 0); }