Fix sort order for nom illeg with date #3338
authorAndreas Müller <a.mueller@bgbm.org>
Tue, 26 Apr 2016 20:49:00 +0000 (22:49 +0200)
committerAndreas Müller <a.mueller@bgbm.org>
Tue, 26 Apr 2016 20:49:00 +0000 (22:49 +0200)
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/taxon/TaxonComparator.java
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/taxon/HomotypicGroupTaxonComparatorTest.java

index 23cd963a2347ce6ceed6786a8b111be314aceba0..4c089000773734b7bab42e8b80ee1f87cd4a337e 100644 (file)
@@ -243,7 +243,7 @@ public class TaxonComparator implements Comparator<TaxonBase>, Serializable {
         }
 
         //nom. illeg.
-        if (includeNomIlleg){
+        if (result == 0 && includeNomIlleg){
             result = compareNomIlleg(name1, name2);
             if (result != 0){
                 return result;
index a1955bf555154acbdf0f36b73ff556a9ccc69717..3b59f64525fdc4a5107089a6b3a14f07520d3229 100644 (file)
@@ -380,6 +380,24 @@ public class HomotypicGroupTaxonComparatorTest {
 
     }
 
+    @Test  //failing selenium test
+    public void testCompare_NomIllegWithDate() {
+        NomenclaturalStatus illegStatus = NomenclaturalStatus.NewInstance(NomenclaturalStatusType.ILLEGITIMATE());
+        botName3.addStatus(illegStatus);
+        botName3.setNomenclaturalReference(ref1);
+        botName2.setNomenclaturalReference(ref2);
+
+        taxon1.addHomotypicSynonymName(botName3, null, null);
+        taxon1.addHomotypicSynonymName(botName2, null, null);
+
+        list.addAll(taxon1.getSynonyms());
+        Collections.sort(list, new HomotypicGroupTaxonComparator(taxon1));
+
+        Assert.assertEquals("Earlier nom. illeg. should come next", botName3, list.get(0).getName());
+        Assert.assertEquals("Later name should come last", botName2, list.get(1).getName());
+
+    }
+
     @Test
     public void testCompare_NoCircularProblemsWithBasionyms() {