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.SelectControl;
29 import org.kuali.rice.krad.uif.control.TextAreaControl;
30 import org.kuali.rice.krad.uif.field.InputField;
31
32
33
34
35
36
37 public class CollectionGroupTest {
38 private CollectionGroup group;
39
40 @Before
41 public void setup() {
42 group = new CollectionGroup();
43 List<Component> items = new ArrayList<Component>();
44 InputField field = new InputField();
45 field.setControl(new SelectControl());
46 items.add(field);
47 items.add(new TextAreaControl());
48 group.setItems(items);
49 }
50
51
52
53
54 @Test
55 public void testPushCollectionGroupToReference() {
56 group.pushCollectionGroupToReference();
57 for (Component component : group.getItems()) {
58 testForCollectionGroupInContext(component, group);
59 }
60 Control innerControl = ((InputField) group.getItems().get(0)).getControl();
61 testForCollectionGroupInContext(innerControl, group);
62 }
63
64
65
66
67
68
69 private void testForCollectionGroupInContext(Component component, CollectionGroup group) {
70 assertTrue("The component does not have the collection group key in the context",
71 component.getContext().containsKey(UifConstants.ContextVariableNames.COLLECTION_GROUP));
72 assertTrue("The collection group found is not the parent group",
73 component.getContext().get(UifConstants.ContextVariableNames.COLLECTION_GROUP) == group);
74 }
75
76 }