TemplateComparator implements Comparator<TemplateQuery> { @Override public int compare(TemplateQuery t0, TemplateQuery t1) { if (t0.getTitle().equals(t1.getTitle())) { return t0.getName().compareTo(t1.getName()); } else { return t0.getTitle().compareTo(t1.getTitle()); } }  @Override int compare(TemplateQuery t0, TemplateQuery t1);  }
@Test public static void testComparison() throws Exception { Model model = Model.getInstanceByName("testmodel"); PathQuery pq = new PathQuery(model); TemplateComparator comparator = new TemplateComparator(); TemplateQuery template = new TemplateQuery(TEMPLATE_NAME, TEMPLATE_TITLE, COMMENT, pq); TemplateQuery anotherTemplate = new TemplateQuery(ATEMPLATE_NAME, ATEMPLATE_TITLE, ACOMMENT, pq); int comparison = comparator.compare(template, anotherTemplate); assertTrue(comparison >1); }