/[schmitzm]/trunk/src_junit/skrueger/geotools/AttributeMetadataMapTest.java
ViewVC logotype

Contents of /trunk/src_junit/skrueger/geotools/AttributeMetadataMapTest.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1332 - (show annotations)
Tue Dec 7 00:36:48 2010 UTC (14 years, 2 months ago) by alfonx
File MIME type: text/plain
File size: 1910 byte(s)
Used a regex to extends all .*Test classes with TestingClass to initialize logger properly
1 package skrueger.geotools;
2
3 import static org.junit.Assert.assertEquals;
4
5 import java.util.ArrayList;
6 import java.util.List;
7
8 import org.geotools.feature.NameImpl;
9 import org.junit.After;
10 import org.junit.Before;
11 import org.junit.Test;
12
13 import schmitzm.junit.TestingClass;
14 import skrueger.AttributeMetadataImpl;
15 public class AttributeMetadataMapTest extends TestingClass {
16
17 AttributeMetadataMap<AttributeMetadataImpl> amdMap;
18 List<String> langs;
19
20 @Before
21 public void before() {
22 langs = new ArrayList<String>();
23 langs.add("en");
24 langs.add("de");
25
26 amdMap = new AttributeMetadataImplMap();
27
28 }
29
30 @After
31 public void after() {
32 amdMap.clear();
33 langs.clear();
34 }
35
36
37 @Test
38 public void testSortedValues() {
39 AttributeMetadataImpl amdG = new AttributeMetadataImpl("g", langs);
40 amdMap.put(new NameImpl("g"), amdG);
41
42 AttributeMetadataImpl amdA = new AttributeMetadataImpl("a", langs);
43 amdMap.put(new NameImpl("a"), amdA);
44
45 AttributeMetadataImpl amdC = new AttributeMetadataImpl("c", langs);
46 amdMap.put(new NameImpl("c"), amdC);
47
48 assertEquals(3, amdMap.values().size());
49
50 assertEquals(3, amdMap.sortedValues().size());
51
52 assertEquals(3, amdMap.sortedValuesVisibleOnly().size());
53 amdA.setVisible(false);
54 assertEquals(2, amdMap.sortedValuesVisibleOnly().size());
55
56 // Now we are setting some weights and check the correct order
57 amdG.setWeight(-1);
58 amdA.setWeight(4);
59 amdC.setWeight(-4);
60 assertEquals(-4, amdMap.sortedValuesVisibleOnly().get(0).getWeight(), 0.00000001);
61 assertEquals(-1, amdMap.sortedValuesVisibleOnly().get(1).getWeight(), 0.00000001);
62
63 // Now we are setting some weights and check the correct order
64 amdG.setWeight(1);
65 amdA.setWeight(2);
66 amdC.setWeight(3);
67 assertEquals(1, amdMap.sortedValuesVisibleOnly().get(0).getWeight(), 0.00000001);
68 assertEquals(3, amdMap.sortedValuesVisibleOnly().get(1).getWeight(), 0.00000001);
69
70 }
71
72 }

Properties

Name Value
svn:eol-style native
svn:keywords Id URL
svn:mime-type text/plain

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26