1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.container;
17
18 import static org.junit.Assert.assertTrue;
19
20 import java.util.ArrayList;
21 import java.util.List;
22
23 import org.junit.Before;
24 import org.junit.Test;
25 import org.kuali.rice.krad.uif.UifConstants;
26 import org.kuali.rice.krad.uif.component.Component;
27 import org.kuali.rice.krad.uif.control.Control;
28 import org.kuali.rice.krad.uif.control.SelectControlBase;
29 import org.kuali.rice.krad.uif.control.TextAreaControl;
30 import org.kuali.rice.krad.uif.field.InputField;
31 import org.kuali.rice.krad.uif.field.InputFieldBase;
32
33
34
35
36
37
38 public class CollectionGroupTest {
39 private CollectionGroup group;
40
41 @Before
42 public void setup() {
43 group = new CollectionGroupBase();
44 List<Component> items = new ArrayList<Component>();
45 InputField field = new InputFieldBase();
46 field.setControl(new SelectControlBase());
47 items.add(field);
48 items.add(new TextAreaControl());
49 group.setItems(items);
50 }
51
52
53
54
55 @Test
56 public void testPushCollectionGroupToReference() {
57 group.pushCollectionGroupToReference();
58 for (Component component : group.getItems()) {
59 testForCollectionGroupInContext(component, group);
60 }
61 Control innerControl = ((InputField) group.getItems().get(0)).getControl();
62 testForCollectionGroupInContext(innerControl, group);
63 }
64
65
66
67
68
69
70 private void testForCollectionGroupInContext(Component component, CollectionGroup group) {
71 assertTrue("The component does not have the collection group key in the context",
72 component.getContext().containsKey(UifConstants.ContextVariableNames.COLLECTION_GROUP));
73 assertTrue("The collection group found is not the parent group",
74 component.getContext().get(UifConstants.ContextVariableNames.COLLECTION_GROUP) == group);
75 }
76
77 }