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.core.api.util.KeyValue;
21 import org.kuali.rice.krad.keyvalues.KeyValuesBase;
22 import org.kuali.rice.krad.keyvalues.KeyValuesFinder;
23 import org.kuali.rice.krad.keyvalues.KeyValuesFinderFactory;
24 import org.kuali.rice.krad.keyvalues.PlaceholderKeyValuesFinder;
25 import org.kuali.rice.krad.uif.UifConstants;
26 import org.kuali.rice.krad.uif.component.BindingInfo;
27 import org.kuali.rice.krad.uif.view.View;
28 import org.kuali.rice.krad.uif.view.ViewModel;
29 import org.kuali.rice.krad.web.form.UifFormBase;
30 import org.mockito.Mockito;
31
32 import static org.mockito.Mockito.*;
33
34 import java.util.*;
35
36
37
38
39
40 public class InputFieldTest {
41
42 View view = null;
43 TestModel model = null;
44 KeyValuesFinder optionsFinder = null;
45 BindingInfo bindingInfo = null;
46
47
48 @Before
49 public void setUp() {
50 view = Mockito.mock(View.class);
51 optionsFinder = Mockito.mock(KeyValuesFinder.class);
52 bindingInfo = Mockito.mock(BindingInfo.class);
53 model = new TestModel();
54 }
55
56 @Test
57 public void testPerformFinalizeWithNonStringFieldOptions() throws Exception {
58
59 Map<String, String> map = new HashMap<String, String>();
60 map.put("testInteger", "1");
61 optionsFinder = KeyValuesFinderFactory.fromMap(map);
62
63
64 when(view.getViewStatus()).thenReturn(UifConstants.ViewStatus.FINAL);
65 when(bindingInfo.getBindingPath()).thenReturn("testInteger");
66
67
68 InputField testObj = new InputField();
69 testObj.setBindingInfo(bindingInfo);
70 testObj.setReadOnly(true);
71 testObj.setOptionsFinder(optionsFinder);
72
73 testObj.performFinalize(view, model, testObj);
74
75 }
76
77
78 private class TestModel {
79 public int getTestInteger() {
80 return 1;
81 }
82 }
83
84 }