Project

General

Profile

Download (1.82 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2016 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.api.service;
10

    
11
import org.junit.Assert;
12
import org.junit.Test;
13

    
14
import eu.etaxonomy.cdm.model.common.TreeIndex;
15
import eu.etaxonomy.cdm.model.common.TreeIndexComparator;
16

    
17

    
18
/**
19
 * @author a.mueller
20
 * @date 12.09.2016
21
 *
22
 */
23
public class TreeIndexComparatorTest {
24

    
25
    @Test
26
    public void test() {
27
        TreeIndexComparator comparator = new TreeIndexComparator();
28

    
29
        TreeIndex ti10 = TreeIndex.NewInstance("#t10#10#");
30
        TreeIndex ti10_20 = TreeIndex.NewInstance("#t10#10#20#");
31
        TreeIndex ti10_30 = TreeIndex.NewInstance("#t10#10#30#");
32
        TreeIndex ti10_30_11 = TreeIndex.NewInstance("#t10#10#30#11#");
33

    
34
        //both null
35
        Assert.assertTrue(0 == comparator.compare(null, null));
36
        //one null
37
        Assert.assertTrue(0 > comparator.compare(null, ti10));
38
        Assert.assertTrue(0 < comparator.compare(ti10, null));
39
        //equal
40
        Assert.assertTrue(0 == comparator.compare(ti10, ti10));
41

    
42
        //same start
43
        Assert.assertTrue(0 > comparator.compare(ti10, ti10_20));
44
        Assert.assertTrue(0 < comparator.compare(ti10_20, ti10));
45

    
46
        //different ends
47
        Assert.assertTrue(0 > comparator.compare(ti10_20, ti10_30));
48
        Assert.assertTrue(0 < comparator.compare(ti10_30, ti10_20));
49

    
50
        //different ends
51
        Assert.assertTrue(0 > comparator.compare(ti10_20, ti10_30));
52
        Assert.assertTrue(0 > comparator.compare(ti10_20, ti10_30_11));
53

    
54
        Assert.assertTrue(0 < comparator.compare(ti10_30, ti10_20));
55
        Assert.assertTrue(0 < comparator.compare(ti10_30_11, ti10_20));
56

    
57
    }
58

    
59
}
(32-32/34)