01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.kuali.workflow.workgroup;
18:
19: import java.util.List;
20:
21: import org.junit.Test;
22: import org.kuali.workflow.attribute.Extension;
23: import org.kuali.workflow.attribute.ExtensionData;
24: import org.kuali.workflow.test.WorkflowTestCase;
25:
26: import edu.iu.uis.eden.KEWServiceLocator;
27: import edu.iu.uis.eden.workgroup.GroupNameId;
28: import edu.iu.uis.eden.workgroup.Workgroup;
29: import edu.iu.uis.eden.workgroup.WorkgroupService;
30:
31: /**
32: * Tests parsing of the XML for Workgroups.
33: *
34: * @author ewestfal
35: */
36: public class WorkgroupXmlParserTest extends WorkflowTestCase {
37:
38: @Test
39: public void testParseWorkgroupWithExtensionData() throws Exception {
40: loadXmlFile("WorkgroupConfig.xml");
41: Workgroup workgroup = getWorkgroupService().getWorkgroup(
42: new GroupNameId("WGWithExtData"));
43: assertNotNull("Workgroup should exist.", workgroup);
44: assertEquals("WGWithExtData", workgroup.getDisplayName());
45: assertEquals("Incorrect workgroup type.", "ChartOrgWorkgroup",
46: workgroup.getWorkgroupType());
47: WorkgroupType workgroupType = getWorkgroupTypeService()
48: .findByName(workgroup.getWorkgroupType());
49: assertNotNull(
50: "Failed to find workgroup type 'ChartOrgWorkgroup'",
51: workgroupType);
52: assertEquals("Should have 1 attribute.", 1, workgroupType
53: .getAttributes().size());
54: WorkgroupTypeAttribute attribute = workgroupType
55: .getAttributes().get(0);
56: assertEquals("ChartOrgDataAttribute", attribute.getAttribute()
57: .getName());
58:
59: List<Extension> extensions = workgroup.getExtensions();
60: assertEquals("Workgroup should have 1 extension.", 1,
61: extensions.size());
62:
63: Extension extension = extensions.get(0);
64: assertEquals("ChartOrgDataAttribute", extension
65: .getAttributeName());
66: assertEquals(2, extension.getData().size());
67:
68: ExtensionData data1 = extension.getData().get(0);
69: ExtensionData data2 = extension.getData().get(1);
70: assertEquals("chart", data1.getKey());
71: assertEquals("BL", data1.getValue());
72: assertEquals("org", data2.getKey());
73: assertEquals("BUS", data2.getValue());
74:
75: assertEquals("BL", extension.getDataValue("chart"));
76: assertEquals("BUS", extension.getDataValue("org"));
77: }
78:
79: private WorkgroupService getWorkgroupService() {
80: return KEWServiceLocator.getWorkgroupService();
81: }
82:
83: private WorkgroupTypeService getWorkgroupTypeService() {
84: return KEWServiceLocator.getWorkgroupTypeService();
85: }
86:
87: }
|