1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.field;
17
18 import org.junit.Before;
19 import org.junit.Test;
20 import org.kuali.rice.krad.keyvalues.KeyValuesFinder;
21 import org.kuali.rice.krad.keyvalues.KeyValuesFinderFactory;
22 import org.kuali.rice.krad.uif.UifConstants;
23 import org.kuali.rice.krad.uif.component.BindingInfo;
24 import org.kuali.rice.krad.uif.service.ViewHelperService;
25 import org.kuali.rice.krad.uif.view.View;
26 import org.mockito.Mockito;
27
28 import static org.mockito.Mockito.*;
29
30 import java.util.*;
31
32
33
34
35
36 public class InputFieldTest {
37
38 View view = null;
39 TestModel model = null;
40 KeyValuesFinder optionsFinder = null;
41 BindingInfo bindingInfo = null;
42
43
44 @Before
45 public void setUp() {
46 view = Mockito.mock(View.class);
47 ViewHelperService mockViewHelperService = mock(ViewHelperService.class);
48 when(view.getViewHelperService()).thenReturn(mockViewHelperService);
49
50 optionsFinder = Mockito.mock(KeyValuesFinder.class);
51 bindingInfo = Mockito.mock(BindingInfo.class);
52 model = new TestModel();
53 }
54
55 @Test
56 public void testPerformFinalizeWithNonStringFieldOptions() throws Exception {
57
58 Map<String, String> map = new HashMap<String, String>();
59 map.put("testInteger", "1");
60 optionsFinder = KeyValuesFinderFactory.fromMap(map);
61
62
63 when(view.getViewStatus()).thenReturn(UifConstants.ViewStatus.FINAL);
64 when(bindingInfo.getBindingPath()).thenReturn("testInteger");
65
66
67 InputField testObj = new InputField();
68 testObj.setBindingInfo(bindingInfo);
69 testObj.setReadOnly(true);
70 testObj.setOptionsFinder(optionsFinder);
71
72 testObj.performFinalize(view, model, testObj);
73
74 }
75
76
77 private class TestModel {
78 public int getTestInteger() {
79 return 1;
80 }
81 }
82 }