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.BeforeClass;
|
15
|
import org.junit.Test;
|
16
|
|
17
|
import eu.etaxonomy.cdm.common.TreeNode;
|
18
|
import eu.etaxonomy.cdm.model.common.DefaultTermInitializer;
|
19
|
import eu.etaxonomy.cdm.model.common.Language;
|
20
|
import eu.etaxonomy.cdm.model.description.Distribution;
|
21
|
import eu.etaxonomy.cdm.model.location.NamedArea;
|
22
|
|
23
|
/**
|
24
|
* @author a.mueller
|
25
|
* @date 10.03.2017
|
26
|
*
|
27
|
*/
|
28
|
public class DistributionNodeByAreaLabelComparatorTest {
|
29
|
|
30
|
private static DistributionNodeByAreaLabelComparator comparator;
|
31
|
|
32
|
|
33
|
|
34
|
/**
|
35
|
* @throws java.lang.Exception
|
36
|
*/
|
37
|
@BeforeClass
|
38
|
public static void setUpClass() throws Exception {
|
39
|
comparator = new DistributionNodeByAreaLabelComparator();
|
40
|
if (Language.DEFAULT() == null){
|
41
|
new DefaultTermInitializer().initialize();
|
42
|
}
|
43
|
}
|
44
|
|
45
|
@Test
|
46
|
public void testComparatorContract() {
|
47
|
NamedArea nodeId1 = NamedArea.NewInstance();
|
48
|
TreeNode<Set<Distribution>,NamedArea> node1 = new TreeNode<>(nodeId1);
|
49
|
nodeId1.setLabel("Germany");
|
50
|
|
51
|
NamedArea nodeId2 = NamedArea.NewInstance();
|
52
|
TreeNode<Set<Distribution>,NamedArea> node2 = new TreeNode<>(nodeId2);
|
53
|
nodeId2.setLabel("Germany");
|
54
|
|
55
|
Integer result1 = comparator.compare(node1, node2);
|
56
|
Assert.assertNotEquals(Integer.valueOf(0), result1);
|
57
|
|
58
|
Integer result2 = comparator.compare(node2, node1);
|
59
|
Assert.assertNotEquals(Integer.valueOf(0), result2);
|
60
|
|
61
|
Assert.assertTrue(result1.equals(-result2));
|
62
|
}
|
63
|
|
64
|
}
|