Project

General

Profile

Download (1.48 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2017 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 java.util.Set;
12

    
13
import org.junit.Assert;
14
import org.junit.Test;
15

    
16
import eu.etaxonomy.cdm.common.TreeNode;
17
import eu.etaxonomy.cdm.model.description.Distribution;
18
import eu.etaxonomy.cdm.model.location.NamedArea;
19
import eu.etaxonomy.cdm.test.TermTestBase;
20

    
21
/**
22
 * @author a.mueller
23
 * @since 10.03.2017
24
 *
25
 */
26
public class DistributionNodeByAreaLabelComparatorTest extends TermTestBase {
27

    
28
    private static DistributionNodeByAreaLabelComparator comparator = new DistributionNodeByAreaLabelComparator();
29

    
30

    
31
    @Test
32
    public void testComparatorContract() {
33
        NamedArea nodeId1 = NamedArea.NewInstance();
34
        TreeNode<Set<Distribution>,NamedArea> node1 = new TreeNode<>(nodeId1);
35
        nodeId1.setLabel("Germany");
36

    
37
        NamedArea nodeId2 = NamedArea.NewInstance();
38
        TreeNode<Set<Distribution>,NamedArea> node2 = new TreeNode<>(nodeId2);
39
        nodeId2.setLabel("Germany");
40

    
41
        Integer result1 = comparator.compare(node1, node2);
42
        Assert.assertNotEquals(Integer.valueOf(0), result1);
43

    
44
        Integer result2 = comparator.compare(node2, node1);
45
        Assert.assertNotEquals(Integer.valueOf(0), result2);
46

    
47
        Assert.assertTrue(result1.equals(-result2));
48
    }
49

    
50
}
(7-7/40)