1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.view;
17
18 import org.junit.Before;
19 import org.junit.Test;
20 import org.kuali.rice.krad.uif.component.BindingInfo;
21 import org.kuali.rice.krad.uif.component.Component;
22 import org.kuali.rice.krad.uif.control.TextControl;
23 import org.kuali.rice.krad.uif.field.InputField;
24
25 import static junit.framework.Assert.assertNotNull;
26 import static junit.framework.Assert.assertTrue;
27
28
29
30
31
32
33 public class ViewIndexTest {
34 @Before
35 public void setUp() throws Exception {
36
37 }
38
39
40
41
42
43
44 @Test
45 public void testClearIndexesAfterRender() throws Exception {
46 ViewIndex viewIndex = new ViewIndex();
47
48 InputField field = new InputField();
49 BindingInfo bindingInfo = new BindingInfo();
50 bindingInfo.setBindingPath("property1");
51 field.setBindingInfo(bindingInfo);
52 String fieldId = "field1";
53 field.setId(fieldId);
54 field.getRefreshWhenChangedPropertyNames().add("#lp.allDay eq true");
55
56 TextControl textControl = new TextControl();
57 String controlId = "text1";
58 textControl.setId(controlId);
59 field.setControl(textControl);
60
61
62 Component[] components = {field};
63 for (Component component: components) {
64 viewIndex.indexComponent(component);
65 viewIndex.addInitialComponentStateIfNeeded(component);
66 }
67
68
69 for (Component component: components) {
70 assertNotNull(viewIndex.getComponentById(component.getId()));
71 }
72
73
74 viewIndex.clearIndexesAfterRender();
75
76 for (Component component: components) {
77 assertNotNull(viewIndex.getComponentById(component.getId()));
78 assertTrue(viewIndex.getInitialComponentStates().containsKey(component.getId()));
79 }
80 }
81 }