1   package net.sf.chainedoptions.support;
2   
3   import java.util.LinkedList;
4   import java.util.List;
5   
6   import net.sf.chainedoptions.LabelValueBean;
7   import net.sf.chainedoptions.support.NoSortStrategy;
8   
9   import junit.framework.TestCase;
10  
11  /***
12   * @author Mattias Arthursson
13   */
14  public class NoSortStrategyTest extends TestCase {
15  
16      private NoSortStrategy tested;
17  
18      /*
19       * @see TestCase#setUp()
20       */
21      protected void setUp() throws Exception {
22          super.setUp();
23  
24          tested = new NoSortStrategy();
25  }
26  
27      /*
28       * @see TestCase#tearDown()
29       */
30      protected void tearDown() throws Exception {
31          super.tearDown();
32  
33          tested = null;
34      }
35  
36      public void testAdjustAndSort() throws Exception{
37          List list = new LinkedList();
38          list.add(new LabelValueBean("xLabel", "xValue"));
39          list.add(new LabelValueBean("aLabel", "aValue"));
40          
41          List result = tested.adjustAndSort(list, null);
42          
43          assertSame(list, result);
44      }
45      
46      public void testGetDefaultValue() {
47          List originalList = new LinkedList();
48          LabelValueBean bean1 = new LabelValueBean("aLabel", "aValue");
49          originalList.add(bean1);
50          LabelValueBean bean2 = new LabelValueBean("xLabel", "xValue");
51          originalList.add(bean2);
52  
53          String result = tested.getDefaultValue(originalList, null);
54  
55          assertEquals("aValue", result);
56      }
57  
58      public void testGetDefaultValue_noValues() {
59          List originalList = new LinkedList();
60  
61          String result = tested.getDefaultValue(originalList, null);
62  
63          assertEquals("", result);
64      }
65  }