Project

General

Profile

« Previous | Next » 

Revision db4096d2

Added by Patrick Plitzner about 9 years ago

  • changed indention marker #3736
    • enriched test

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java
970 970
        for(TermNode<T> node:children){
971 971
            String indentString = "";
972 972
            for(int i=0;i<depth;i++){
973
                indentString += "  ";
973
                indentString += "- ";
974 974
            }
975 975
            result.put(node.term, indentString + node.term.getMessage());
976 976
            parseTermTree(node.children, result, depth);
eu.etaxonomy.taxeditor.store/src/test/java/eu/etaxonomy/taxeditor/store/utility/AbstractUtilityTest.java
10 10
package eu.etaxonomy.taxeditor.store.utility;
11 11

  
12 12
import static org.junit.Assert.assertEquals;
13
import static org.junit.Assert.assertFalse;
14
import static org.junit.Assert.assertTrue;
13 15

  
14 16
import java.util.Arrays;
15 17
import java.util.Collection;
18
import java.util.Iterator;
16 19
import java.util.LinkedHashMap;
17 20

  
18 21
import org.junit.Test;
......
39 42
        LinkedHashMap<? extends IEnumTerm<?>, String> orderedTerms;
40 43

  
41 44
        orderedTerms = AbstractUtility.orderTerms(Arrays.asList(SpecimenOrObservationType.values()));
42
        checkSize(orderedTerms, Arrays.asList(SpecimenOrObservationType.values()));
45
        check(orderedTerms, Arrays.asList(SpecimenOrObservationType.values()));
43 46
        orderedTerms = AbstractUtility.orderTerms(Arrays.asList(NomenclaturalCode.values()));
44
        checkSize(orderedTerms, Arrays.asList(NomenclaturalCode.values()));
47
        check(orderedTerms, Arrays.asList(NomenclaturalCode.values()));
45 48
        orderedTerms = AbstractUtility.orderTerms(Arrays.asList(OriginalSourceType.values()));
46
        checkSize(orderedTerms, Arrays.asList(OriginalSourceType.values()));
49
        check(orderedTerms, Arrays.asList(OriginalSourceType.values()));
47 50
        orderedTerms = AbstractUtility.orderTerms(Arrays.asList(PreferencePredicate.values()));
48
        checkSize(orderedTerms, Arrays.asList(PreferencePredicate.values()));
51
        check(orderedTerms, Arrays.asList(PreferencePredicate.values()));
49 52
        orderedTerms = AbstractUtility.orderTerms(Arrays.asList(RankClass.values()));
50
        checkSize(orderedTerms, Arrays.asList(RankClass.values()));
53
        check(orderedTerms, Arrays.asList(RankClass.values()));
51 54
        orderedTerms = AbstractUtility.orderTerms(Arrays.asList(ReferenceType.values()));
52
        checkSize(orderedTerms, Arrays.asList(ReferenceType.values()));
55
        check(orderedTerms, Arrays.asList(ReferenceType.values()));
53 56
        orderedTerms = AbstractUtility.orderTerms(Arrays.asList(TermType.values()));
54
        checkSize(orderedTerms, Arrays.asList(TermType.values()));
57
        check(orderedTerms, Arrays.asList(TermType.values()));
55 58
    }
56 59

  
57 60
    /**
58 61
     * @param orderedTerms
59 62
     * @param expectedTerms
60 63
     */
61
    private void checkSize(LinkedHashMap<? extends IEnumTerm<?>, String> orderedTerms, Collection<? extends IEnumTerm<?>> expectedTerms) {
64
    private void check(LinkedHashMap<? extends IEnumTerm<?>, String> orderedTerms, Collection<? extends IEnumTerm<?>> expectedTerms) {
65
        assertFalse("Ordered term list is empty!", orderedTerms.isEmpty());
62 66
        assertEquals("Some terms got lost while ordering.", expectedTerms.size(), orderedTerms.size());
67
        Iterator<String> itti = orderedTerms.values().iterator();
68
        String first = itti.next();
69
        while (itti.hasNext()) {
70
            String next = itti.next();
71
            if(next.startsWith(" -")){
72
                assertTrue("Sorting is not alphabetically correct.", first.compareTo(next)<0);
73
            }
74
        }
63 75
    }
64 76

  
65 77
}

Also available in: Unified diff