- changed indention marker #3736
authorPatric Plitzner <p.plitzner@bgbm.org>
Mon, 4 Nov 2013 13:34:15 +0000 (13:34 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Mon, 4 Nov 2013 13:34:15 +0000 (13:34 +0000)
 - enriched test

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java
eu.etaxonomy.taxeditor.store/src/test/java/eu/etaxonomy/taxeditor/store/utility/AbstractUtilityTest.java

index ee7db7b294174c67dc825b4fefadfdb93c894121..7dcf587ef3c66e94f1da8b1620338c3672b0799d 100644 (file)
@@ -970,7 +970,7 @@ public abstract class AbstractUtility {
         for(TermNode<T> node:children){
             String indentString = "";
             for(int i=0;i<depth;i++){
-                indentString += "  ";
+                indentString += "- ";
             }
             result.put(node.term, indentString + node.term.getMessage());
             parseTermTree(node.children, result, depth);
index 2391f91e4ea135d4cff30030b62eed03ebac4273..45c87f4b7a6680ef80b81bb9ccc253d5ae926ad8 100644 (file)
 package eu.etaxonomy.taxeditor.store.utility;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Iterator;
 import java.util.LinkedHashMap;
 
 import org.junit.Test;
@@ -39,27 +42,36 @@ public class AbstractUtilityTest {
         LinkedHashMap<? extends IEnumTerm<?>, String> orderedTerms;
 
         orderedTerms = AbstractUtility.orderTerms(Arrays.asList(SpecimenOrObservationType.values()));
-        checkSize(orderedTerms, Arrays.asList(SpecimenOrObservationType.values()));
+        check(orderedTerms, Arrays.asList(SpecimenOrObservationType.values()));
         orderedTerms = AbstractUtility.orderTerms(Arrays.asList(NomenclaturalCode.values()));
-        checkSize(orderedTerms, Arrays.asList(NomenclaturalCode.values()));
+        check(orderedTerms, Arrays.asList(NomenclaturalCode.values()));
         orderedTerms = AbstractUtility.orderTerms(Arrays.asList(OriginalSourceType.values()));
-        checkSize(orderedTerms, Arrays.asList(OriginalSourceType.values()));
+        check(orderedTerms, Arrays.asList(OriginalSourceType.values()));
         orderedTerms = AbstractUtility.orderTerms(Arrays.asList(PreferencePredicate.values()));
-        checkSize(orderedTerms, Arrays.asList(PreferencePredicate.values()));
+        check(orderedTerms, Arrays.asList(PreferencePredicate.values()));
         orderedTerms = AbstractUtility.orderTerms(Arrays.asList(RankClass.values()));
-        checkSize(orderedTerms, Arrays.asList(RankClass.values()));
+        check(orderedTerms, Arrays.asList(RankClass.values()));
         orderedTerms = AbstractUtility.orderTerms(Arrays.asList(ReferenceType.values()));
-        checkSize(orderedTerms, Arrays.asList(ReferenceType.values()));
+        check(orderedTerms, Arrays.asList(ReferenceType.values()));
         orderedTerms = AbstractUtility.orderTerms(Arrays.asList(TermType.values()));
-        checkSize(orderedTerms, Arrays.asList(TermType.values()));
+        check(orderedTerms, Arrays.asList(TermType.values()));
     }
 
     /**
      * @param orderedTerms
      * @param expectedTerms
      */
-    private void checkSize(LinkedHashMap<? extends IEnumTerm<?>, String> orderedTerms, Collection<? extends IEnumTerm<?>> expectedTerms) {
+    private void check(LinkedHashMap<? extends IEnumTerm<?>, String> orderedTerms, Collection<? extends IEnumTerm<?>> expectedTerms) {
+        assertFalse("Ordered term list is empty!", orderedTerms.isEmpty());
         assertEquals("Some terms got lost while ordering.", expectedTerms.size(), orderedTerms.size());
+        Iterator<String> itti = orderedTerms.values().iterator();
+        String first = itti.next();
+        while (itti.hasNext()) {
+            String next = itti.next();
+            if(next.startsWith(" -")){
+                assertTrue("Sorting is not alphabetically correct.", first.compareTo(next)<0);
+            }
+        }
     }
 
 }