Profile implements Comparable<Profile> { @Override public int compareTo(Profile o) { int orderDiff = order - o.order; if (orderDiff != 0) { return orderDiff; } else { return this.id - o.id; } } Profile();  Profile(Profile profile);  Profile(Profile profileA, Profile profileB); String getName(); String getParentProfile(); ProcessorConfig getEnricherConfig(); ProcessorConfig getGeneratorConfig(); ProcessorConfig getWatcherConfig(); void setEnricherConfig(ProcessorConfig config); void setGeneratorConfig(ProcessorConfig config); void setWatcherConfig(ProcessorConfig config); int getOrder(); @Override // Higher order means "larger" int compareTo(Profile o);  }
@Test public void sort1() throws IOException { Profile one = ProfileUtil.readAllFromClasspath("order-test-3", "").get(0);; Profile two = ProfileUtil.fromYaml(getClass().getResourceAsStream("/fabric8/config/ProfileTest.yml")).get(2); assertTrue(one.compareTo(two) < 0); assertTrue(two.compareTo(one) > 0); assertEquals(one.compareTo(one),0); assertEquals(two.compareTo(two),0); }
@Test public void sort3() throws IOException { Profile one = ProfileUtil.readAllFromClasspath("order-test-1", "").get(0);; Profile two = ProfileUtil.fromYaml(getClass().getResourceAsStream("/fabric8/config/ProfileTest.yml")).get(0); assertTrue(one.compareTo(two) < 0); assertTrue(two.compareTo(one) > 0); }
@Test public void sort4_a() throws IOException { Profile firstRead = ProfileUtil.readAllFromClasspath("order-test-3", "").get(0);; Profile secondRead = ProfileUtil.fromYaml(getClass().getResourceAsStream("/fabric8/config/ProfileTest.yml")).get(2); assertTrue(firstRead.compareTo(secondRead) < 0); assertTrue(secondRead.compareTo(firstRead) > 0); }
@Test public void sort4_b() throws IOException { Profile firstRead = ProfileUtil.fromYaml(getClass().getResourceAsStream("/fabric8/config/ProfileTest.yml")).get(2); Profile secondRead = ProfileUtil.readAllFromClasspath("order-test-3", "").get(0);; assertTrue(firstRead.compareTo(secondRead) < 0); assertTrue(secondRead.compareTo(firstRead) > 0); }