01: package edu.iu.uis.eden.lookupable;
02:
03: import java.lang.reflect.Field;
04: import java.util.HashMap;
05: import java.util.Iterator;
06: import java.util.List;
07: import java.util.Map;
08:
09: import junit.framework.TestCase;
10: import edu.iu.uis.eden.SpringServiceLocator;
11: import edu.iu.uis.eden.plugin.attributes.WorkflowLookupable;
12: import edu.iu.uis.eden.user.web.WebWorkflowUser;
13:
14: public class UserLookupableImplTestPENDING extends TestCase {
15: private WorkflowLookupable workflowLookupable;
16: private Map fieldValues;
17: private Map conversionFields;
18:
19: protected void setUp() throws Exception {
20: SpringServiceLocator.setToTestMode(null);
21: workflowLookupable = new UserLookupableImpl();
22:
23: fieldValues = new HashMap();
24: fieldValues.put("lastName", "hopf");
25: fieldValues.put("firstName", "jeremy");
26:
27: conversionFields = new HashMap();
28: conversionFields.put("networkId", "test_networkId");
29: }
30:
31: public void testGetSearchResults() throws Exception {
32: List results = workflowLookupable.getSearchResults(fieldValues,
33: conversionFields);
34: assertEquals("Too many results listed.", 1, results.size());
35: WebWorkflowUser user = (WebWorkflowUser) results.get(0);
36:
37: assertEquals("AuthenticationId is incorrect.", "jhopf", user
38: .getAuthenticationUserId().getAuthenticationId());
39: assertEquals("Display Name is incorrect.", "Jeremy R Hopf",
40: user.getDisplayName());
41: assertTrue("Return parameter networkId is not correct.", user
42: .getReturnUrl().indexOf("test_networkId=jhopf") > 0);
43:
44: Map fieldValues2 = new HashMap();
45: fieldValues2.put("networkId", "rkirkend");
46:
47: WorkflowLookupable workflowLookupable2 = new UserLookupableImpl();
48:
49: List results2 = workflowLookupable2.getSearchResults(
50: fieldValues2, new HashMap());
51: assertEquals("Too many results listed.", 1, results2.size());
52: WebWorkflowUser user2 = (WebWorkflowUser) results2.get(0);
53:
54: assertEquals("AuthenticationId is incorrect.", "rkirkend",
55: user2.getAuthenticationUserId().getAuthenticationId());
56: assertEquals("Display Name is incorrect.",
57: "Ryan Andrew Kirkendall", user2.getDisplayName());
58: assertTrue("Return parameter approver is not correct.", user2
59: .getReturnUrl().indexOf("approver=rkirkend") > 0);
60: }
61:
62: public void testGetColumns() {
63: for (Iterator iter = workflowLookupable.getColumns().iterator(); iter
64: .hasNext();) {
65: Column column = (Column) iter.next();
66: try {
67: if (column.getPropertyName().equals(
68: "authenticationUserId.authenticationId")) {
69: column.setPropertyName("authenticationId");
70: }
71: Field field = WebWorkflowUser.class
72: .getDeclaredField(column.getPropertyName());
73: } catch (NoSuchFieldException e) {
74: assertTrue(
75: "Column property name on UserLookupableImpl does not equal a property on the WebWorkflowUser bean. Column: "
76: + column.getPropertyName(), false);
77: }
78: }
79: }
80:
81: public void testGetNoReturnParams() {
82: String parameters = workflowLookupable
83: .getNoReturnParams(conversionFields);
84: assertTrue("Return parameter networkId is not correct.",
85: parameters.indexOf("test_networkId=") > 0);
86: }
87: }
|