View Javadoc

1   /**
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kns.document;
17  
18  import org.junit.Ignore;
19  import org.junit.Test;
20  import org.kuali.rice.krad.test.KRADTestCase;
21  
22  @Ignore
23  public class DocumentAuthorizerBaseTest extends KRADTestCase {
24  	// TODO rewrite this test
25  //    private static final Logger LOG = Logger.getLogger(DocumentAuthorizerBaseTest.class);
26  //
27  //    private static final String SUPERVISOR_USER = "ABNEY";
28  //    private static final String SUPERVISOR_UNIVERSAL = "2237202707";
29  //    private static final String NONSUPER_USER = "BARTH";
30  //    private static final String NONSUPER_UNIVERSAL = "5998202207";
31  //    private static final String NONSUPER_2_USER = "COOTER";
32  //    private static final String NONSUPER_2_UNIVERSAL = "598746310";
33  //
34  //    private DocumentAuthorizer documentAuthorizer;
35  //    private PessimisticLockService pessimisticLock;
36  //
37  //    @Override
38  //    public void setUp() throws Exception {
39  //        super.setUp();
40  //        documentAuthorizer = new DocumentAuthorizerBase();
41  //        pessimisticLock = KRADServiceLocatorInternal.getPessimisticLockService();
42  //    }
43  //
44  //    @Override
45  //    public void tearDown() throws Exception {
46  //        try {
47  //            new ClearDatabaseLifecycle(Arrays.asList(new String[]{"KNS_PESSIMISTIC_LOCK_T"}), null).start();
48  //        } catch (Exception e) {
49  //            LOG.warn("Caught exception trying to clear Pessimistic Lock table");
50  //        }
51  //        super.tearDown();
52  //    }
53  //
54  //    // following is the Supervisor & Initiator grid
55  //
56  //    // ## Supervisor? UserIsInitiator? ApprovalRequested? canSupervise Result
57  //    // -----------------------------------------------------------------------------------
58  //    // A true true true true
59  //    //
60  //    // B true true false false
61  //    //
62  //    // C true false true true
63  //    //
64  //    // D true false false true
65  //    //
66  //    // E false * * false
67  //    //
68  
69      /* This test can no longer use mock objects because the isSupervisor() method is no longer on the Person object.
70       * To check for supervisor status you know must to through the group service and check membership in the supervisor group.
71       */
72  	@Test
73      public void testCanSuperviseAsInitiatorA() {
74  //
75  //        DocumentActionFlags flags;
76  //        Document document;
77  //
78  //        // scenario A
79  //        //document = new MockDocument(getSuperUser(), true);
80  //        //flags = documentAuthorizer.getDocumentActionFlags(document, getSuperUser());
81  //        //assertTrue(flags.getCanSupervise());
82  //
83  //        // scenario B
84  //        document = new MockDocument(getSuperUser(), false);
85  //        flags = documentAuthorizer.getDocumentActionFlags(document, getSuperUser());
86  //        assertFalse(flags.getCanSupervise());
87  //
88  //        // scenario C
89  //        document = new MockDocument(getNonSuperUser(), true);
90  //        flags = documentAuthorizer.getDocumentActionFlags(document, getSuperUser());
91  //        assertTrue(flags.getCanSupervise());
92  //
93  //        // scenario D
94  //        document = new MockDocument(getNonSuperUser(), false);
95  //        flags = documentAuthorizer.getDocumentActionFlags(document, getSuperUser());
96  //        assertTrue(flags.getCanSupervise());
97  //
98      }
99  
100 //
101 //    private void verifyEditModeExists(Map editMode, String editModeToTest, String expectedValue) {
102 //        assertNotNull("Edit mode map should have a valid value for " + editModeToTest, editMode.get(editModeToTest));
103 //        assertEquals("Edit mode map should contain entry with key '" + editModeToTest + "' and value '" + expectedValue + "'", expectedValue, editMode.get(editModeToTest));
104 //    }
105 //
106 //    private void verifyEditModeDoesNotExist(Map editMode, String editModeToTest) {
107 //        assertNull("Edit mode map should not have an entry for " + editModeToTest, editMode.get(editModeToTest));
108 //    }
109 //
110 //    protected Person getWorkflowPessimisticLockOwnerUser() {
111 //        Person person = KimImplServiceLocator.getPersonService().getPersonByPrincipalName(KNSConstants.SYSTEM_USER);
112 //        if (person == null) {
113 //            throw new RuntimeException("Cannot find user with network id '" + KNSConstants.SYSTEM_USER);
114 //        }
115 //        return person;
116 //    }
117 //
118 //    /**
119 //     * This method tests the Pessimistic locking mechanism when no custom lock descriptors are being used by the document in
120 //     * the default manner (locks are unique to user and document)
121 //     *
122 //     * @throws Exception
123 //     */
124     @Test
125     public void testEstablishLocks_DefaultDocumentAuthorizerBase() throws Exception {
126 //        PessimisticLockService lockService = KRADServiceLocatorInternal.getPessimisticLockService();
127 //
128 //        // test no lock creation needed
129 //        Document document = new MockDocument(getNonSuperUser(), false);
130 //        int originalExpectedLockCount = 0;
131 //        // no lock should be created
132 //        int expectedLockCountIncrease = 0;
133 //        assertEquals("Lock count is incorrect", originalExpectedLockCount, document.getPessimisticLocks().size());
134 //        Map oldEditMode = getEditMode_ReadOnly();
135 //        String testString = "dummyString";
136 //        oldEditMode.put(AuthorizationConstants.EditMode.UNVIEWABLE, testString);
137 //        Map newEditMode = this.pessimisticLock.establishLocks(document, oldEditMode, getNonSuperUser());
138 //        assertEquals("Lock count is incorrect", originalExpectedLockCount + expectedLockCountIncrease, document.getPessimisticLocks().size());
139 //        assertEquals("Establish locks method returned invalid number of edit modes", oldEditMode.size(), newEditMode.size());
140 //        verifyEditModeDoesNotExist(newEditMode, AuthorizationConstants.EditMode.FULL_ENTRY);
141 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.VIEW_ONLY, DocumentAuthorizerBase.EDIT_MODE_DEFAULT_TRUE_VALUE);
142 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.UNVIEWABLE, testString);
143 //
144 //        // test valid lock creation where no user has any locks and edit modes returned are same as passed in
145 //        document = new MockDocument(getNonSuperUser(), false);
146 //        originalExpectedLockCount = 0;
147 //        // one lock should be created
148 //        expectedLockCountIncrease = 1;
149 //        assertEquals("Lock count is incorrect", originalExpectedLockCount, document.getPessimisticLocks().size());
150 //        oldEditMode = getEditMode_FullEntry();
151 //        testString = "dummyString";
152 //        oldEditMode.put(AuthorizationConstants.EditMode.UNVIEWABLE, testString);
153 //        newEditMode = this.pessimisticLock.establishLocks(document, oldEditMode, getNonSuperUser());
154 //        assertEquals("Lock count is incorrect", originalExpectedLockCount + expectedLockCountIncrease, document.getPessimisticLocks().size());
155 //        assertEquals("Establish locks method returned invalid number of edit modes", oldEditMode.size(), newEditMode.size());
156 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.FULL_ENTRY, DocumentAuthorizerBase.EDIT_MODE_DEFAULT_TRUE_VALUE);
157 //        verifyEditModeDoesNotExist(newEditMode, AuthorizationConstants.EditMode.VIEW_ONLY);
158 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.UNVIEWABLE, testString);
159 //
160 //        // test invalid lock status (2 locks by 2 different users) throws exception
161 //        document = new MockDocument(getNonSuperUser(), false);
162 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), getNonSuperUser()));
163 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), getSuperUser()));
164 //        try {
165 //            this.pessimisticLock.establishLocks(document, getEditMode_FullEntry(), getNonSuperUser());
166 //            fail("Document authorizer should have thrown exception of type PessimisticLockingException");
167 //        } catch (PessimisticLockingException e) {
168 //            // expected result
169 //        } catch (Exception e) {
170 //            fail("Document authorizer threw an exception but it was not of type PessimisticLockingException... it was a " + e.getClass().getName());
171 //        }
172 //
173 //        // test valid lock status (2 locks by 2 different users with one user being workflow lock user) does not throw
174 //        // exception
175 //        document = new MockDocument(getNonSuperUser(), false);
176 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), getNonSuperUser()));
177 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), getWorkflowPessimisticLockOwnerUser()));
178 //        try {
179 //            this.pessimisticLock.establishLocks(document, getEditMode_FullEntry(), getNonSuperUser());
180 //        } catch (Exception e) {
181 //            fail("Document authorizer should not have thrown an exception but did with type '" + e.getClass().getName() + "' and message: " + e.getMessage());
182 //        }
183 //
184 //        // test other user already has lock should return editMode of ReadOnly
185 //        document = new MockDocument(getNonSuperUser(), false);
186 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), getSuperUser()));
187 //        originalExpectedLockCount = 1;
188 //        // one lock should be created
189 //        expectedLockCountIncrease = 0;
190 //        assertEquals("Lock count is incorrect", originalExpectedLockCount, document.getPessimisticLocks().size());
191 //        oldEditMode = getEditMode_FullEntry();
192 //        testString = "dummyString";
193 //        oldEditMode.put(AuthorizationConstants.EditMode.UNVIEWABLE, testString);
194 //        newEditMode = this.pessimisticLock.establishLocks(document, oldEditMode, getNonSuperUser());
195 //        assertEquals("Lock count is incorrect", originalExpectedLockCount + expectedLockCountIncrease, document.getPessimisticLocks().size());
196 //        assertEquals("Establish locks method returned invalid number of edit modes", oldEditMode.size(), newEditMode.size());
197 //        verifyEditModeDoesNotExist(newEditMode, AuthorizationConstants.EditMode.FULL_ENTRY);
198 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.VIEW_ONLY, DocumentAuthorizerBase.EDIT_MODE_DEFAULT_TRUE_VALUE);
199 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.UNVIEWABLE, testString);
200 //
201 //        // test current user already has lock and that edit modes returned are same as passed in
202 //        document = new MockDocument(getNonSuperUser(), false);
203 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), getNonSuperUser()));
204 //        originalExpectedLockCount = 1;
205 //        // one lock should be created
206 //        expectedLockCountIncrease = 0;
207 //        assertEquals("Lock count is incorrect", originalExpectedLockCount, document.getPessimisticLocks().size());
208 //        oldEditMode = getEditMode_FullEntry();
209 //        testString = "dummyString";
210 //        oldEditMode.put(AuthorizationConstants.EditMode.VIEW_ONLY, testString);
211 //        newEditMode = this.pessimisticLock.establishLocks(document, oldEditMode, getNonSuperUser());
212 //        assertEquals("Lock count is incorrect", originalExpectedLockCount + expectedLockCountIncrease, document.getPessimisticLocks().size());
213 //        assertEquals("Establish locks method returned invalid number of edit modes", oldEditMode.size(), newEditMode.size());
214 //        verifyEditModeDoesNotExist(newEditMode, AuthorizationConstants.EditMode.UNVIEWABLE);
215 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.FULL_ENTRY, DocumentAuthorizerBase.EDIT_MODE_DEFAULT_TRUE_VALUE);
216 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.VIEW_ONLY, testString);
217 //
218     }
219 //
220 //    /**
221 //     * This method tests the Pessimistic locking mechanism when custom lock descriptors are being used by the document in the
222 //     * default manner (locks are unique to user, document, and lock descriptor)
223 //     *
224 //     * @throws Exception
225 //     */
226     @Test
227     public void testEstablishLocks_CustomDocumentAuthorizerBase() throws Exception {
228 //        GlobalVariables.setUserSession(new UserSession("quickstart"));
229 //        PessimisticLockService lockService = KRADServiceLocatorInternal.getPessimisticLockService();
230 //        DocumentAuthorizer documentAuthorizer = new TestDocumentAuthorizerBase();
231 //        String lockDescriptor1 = "test the first lock";
232 //        String lockDescriptor2 = "this is the second lock";
233 //        String lockDescriptor3 = "booyah locks";
234 //
235 //        // test no lock creation needed
236 //        Document document = new MockDocument(getNonSuperUser(), false);
237 //        String expectedLockDescriptor = lockDescriptor1;
238 //        GlobalVariables.getUserSession().addObject(TestDocumentAuthorizerBase.USER_SESSION_OBJECT_KEY, (Object) expectedLockDescriptor);
239 //        int originalExpectedLockCount = 0;
240 //        // no lock should be created
241 //        int expectedLockCountIncrease = 0;
242 //        assertEquals("Lock count is incorrect", originalExpectedLockCount, document.getPessimisticLocks().size());
243 //        Map oldEditMode = getEditMode_ReadOnly();
244 //        String testString = "dummyString";
245 //        oldEditMode.put(AuthorizationConstants.EditMode.UNVIEWABLE, testString);
246 //        Map newEditMode = this.pessimisticLock.establishLocks(document, oldEditMode, getNonSuperUser());
247 //        assertEquals("Lock count is incorrect", originalExpectedLockCount + expectedLockCountIncrease, document.getPessimisticLocks().size());
248 //        assertEquals("Establish locks method returned invalid number of edit modes", oldEditMode.size(), newEditMode.size());
249 //        verifyEditModeDoesNotExist(newEditMode, AuthorizationConstants.EditMode.FULL_ENTRY);
250 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.VIEW_ONLY, DocumentAuthorizerBase.EDIT_MODE_DEFAULT_TRUE_VALUE);
251 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.UNVIEWABLE, testString);
252 //
253 //        // test lock descriptors nullify PessimisticLockingException throwing
254 //        document = new MockDocument(getNonSuperUser(), false);
255 //        expectedLockDescriptor = lockDescriptor3;
256 //        GlobalVariables.getUserSession().addObject(TestDocumentAuthorizerBase.USER_SESSION_OBJECT_KEY, (Object) expectedLockDescriptor);
257 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), lockDescriptor1, getNonSuperUser()));
258 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), lockDescriptor2, getSuperUser()));
259 //        try {
260 //            this.pessimisticLock.establishLocks(document, getEditMode_FullEntry(), getNonSuperUser());
261 //        } catch (Exception e) {
262 //            fail("Document authorizer should not have thrown an exception but did with type '" + e.getClass().getName() + "' and message: " + e.getMessage());
263 //        }
264 //
265 //        // test valid lock status (2 locks by 2 different users with one user being workflow lock user) does not throw
266 //        // exception
267 //        document = new MockDocument(getNonSuperUser(), false);
268 //        expectedLockDescriptor = lockDescriptor3;
269 //        GlobalVariables.getUserSession().addObject(TestDocumentAuthorizerBase.USER_SESSION_OBJECT_KEY, (Object) expectedLockDescriptor);
270 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), lockDescriptor1, getNonSuperUser()));
271 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), lockDescriptor2, getWorkflowPessimisticLockOwnerUser()));
272 //        try {
273 //            //documentAuthorizer.establishLocks(document, getEditMode_FullEntry(), getNonSuperUser());
274 //            this.pessimisticLock.establishLocks(document,getEditMode_FullEntry(), getNonSuperUser());
275 //        } catch (Exception e) {
276 //            fail("Document authorizer should not have thrown an exception but did with type '" + e.getClass().getName() + "' and message: " + e.getMessage());
277 //        }
278 //
279 //        // test valid lock creation with descriptor where no user has any locks and edit modes returned are same as passed in
280 //        document = new MockDocument(getNonSuperUser(), false);
281 //        expectedLockDescriptor = lockDescriptor3;
282 //        GlobalVariables.getUserSession().addObject(TestDocumentAuthorizerBase.USER_SESSION_OBJECT_KEY, (Object) expectedLockDescriptor);
283 //        originalExpectedLockCount = 0;
284 //        // one lock should be created
285 //        expectedLockCountIncrease = 1;
286 //        assertEquals("Lock count is incorrect", originalExpectedLockCount, document.getPessimisticLocks().size());
287 //        oldEditMode = getEditMode_FullEntry();
288 //        testString = "dummyString";
289 //        oldEditMode.put(AuthorizationConstants.EditMode.UNVIEWABLE, testString);
290 //        newEditMode = this.pessimisticLock.establishLocks(document, oldEditMode, getNonSuperUser());
291 //        assertEquals("Lock count is incorrect", originalExpectedLockCount + expectedLockCountIncrease, document.getPessimisticLocks().size());
292 //        assertEquals("Lock descriptor from new lock is incorrect", expectedLockDescriptor, document.getPessimisticLocks().get(0).getLockDescriptor());
293 //        assertEquals("Establish locks method returned invalid number of edit modes", oldEditMode.size(), newEditMode.size());
294 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.FULL_ENTRY, DocumentAuthorizerBase.EDIT_MODE_DEFAULT_TRUE_VALUE);
295 //        verifyEditModeDoesNotExist(newEditMode, AuthorizationConstants.EditMode.VIEW_ONLY);
296 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.UNVIEWABLE, testString);
297 //
298 //        // test other user already has lock with same descriptor should return editMode of ReadOnly
299 //        document = new MockDocument(getNonSuperUser(), false);
300 //        expectedLockDescriptor = lockDescriptor1;
301 //        GlobalVariables.getUserSession().addObject(TestDocumentAuthorizerBase.USER_SESSION_OBJECT_KEY, (Object) expectedLockDescriptor);
302 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), lockDescriptor1, getSuperUser()));
303 //        originalExpectedLockCount = 1;
304 //        // no lock should be created
305 //        expectedLockCountIncrease = 0;
306 //        assertEquals("Lock count is incorrect", originalExpectedLockCount, document.getPessimisticLocks().size());
307 //        oldEditMode = getEditMode_FullEntry();
308 //        testString = "dummyString";
309 //        oldEditMode.put(AuthorizationConstants.EditMode.UNVIEWABLE, testString);
310 //        newEditMode = this.pessimisticLock.establishLocks(document, oldEditMode, getNonSuperUser());
311 //        assertEquals("Lock count is incorrect", originalExpectedLockCount + expectedLockCountIncrease, document.getPessimisticLocks().size());
312 //        assertEquals("Establish locks method returned invalid number of edit modes", oldEditMode.size(), newEditMode.size());
313 //        verifyEditModeDoesNotExist(newEditMode, AuthorizationConstants.EditMode.FULL_ENTRY);
314 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.VIEW_ONLY, DocumentAuthorizerBase.EDIT_MODE_DEFAULT_TRUE_VALUE);
315 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.UNVIEWABLE, testString);
316 //        assertNotNull("Establish locks should return a UNVIEWABLE edit mode", newEditMode.get(AuthorizationConstants.EditMode.UNVIEWABLE));
317 //        assertEquals("Establish locks method returned invalid UNVIEWABLE edit mode", testString, newEditMode.get(AuthorizationConstants.EditMode.UNVIEWABLE));
318 //
319 //        // test other user already has lock with different descriptor should return given edit modes
320 //        document = new MockDocument(getNonSuperUser(), false);
321 //        expectedLockDescriptor = lockDescriptor1;
322 //        GlobalVariables.getUserSession().addObject(TestDocumentAuthorizerBase.USER_SESSION_OBJECT_KEY, (Object) expectedLockDescriptor);
323 //        PessimisticLock oldLock = lockService.generateNewLock(document.getDocumentNumber(), lockDescriptor2, getNonSuperUser());
324 //        document.addPessimisticLock(oldLock);
325 //        originalExpectedLockCount = 1;
326 //        // one lock should be created
327 //        expectedLockCountIncrease = 1;
328 //        assertEquals("Lock count is incorrect", originalExpectedLockCount, document.getPessimisticLocks().size());
329 //        oldEditMode = getEditMode_FullEntry();
330 //        testString = "is this the string";
331 //        oldEditMode.put(AuthorizationConstants.EditMode.UNVIEWABLE, testString);
332 //        newEditMode = this.pessimisticLock.establishLocks(document, oldEditMode, getNonSuperUser());
333 //        assertEquals("Lock count is incorrect", originalExpectedLockCount + expectedLockCountIncrease, document.getPessimisticLocks().size());
334 //        for (PessimisticLock lock : document.getPessimisticLocks()) {
335 //            if (!lock.getId().equals(oldLock.getId())) {
336 //                assertEquals("Lock descriptor of new lock is incorrect", expectedLockDescriptor, lock.getLockDescriptor());
337 //            }
338 //        }
339 //        assertEquals("Establish locks method returned invalid number of edit modes", oldEditMode.size(), newEditMode.size());
340 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.FULL_ENTRY, DocumentAuthorizerBase.EDIT_MODE_DEFAULT_TRUE_VALUE);
341 //        verifyEditModeDoesNotExist(newEditMode, AuthorizationConstants.EditMode.VIEW_ONLY);
342 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.UNVIEWABLE, testString);
343 //
344 //        // test current user has lock with same lock descriptor and other users have no locks should return given edit modes
345 //        document = new MockDocument(getNonSuperUser(), false);
346 //        expectedLockDescriptor = lockDescriptor1;
347 //        GlobalVariables.getUserSession().addObject(TestDocumentAuthorizerBase.USER_SESSION_OBJECT_KEY, (Object) expectedLockDescriptor);
348 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), expectedLockDescriptor, getNonSuperUser()));
349 //        originalExpectedLockCount = 1;
350 //        // no lock should be created
351 //        expectedLockCountIncrease = 0;
352 //        assertEquals("Lock count is incorrect", originalExpectedLockCount, document.getPessimisticLocks().size());
353 //        oldEditMode = getEditMode_FullEntry();
354 //        testString = "is this the string";
355 //        oldEditMode.put(AuthorizationConstants.EditMode.UNVIEWABLE, testString);
356 //        newEditMode = this.pessimisticLock.establishLocks(document, oldEditMode, getNonSuperUser());
357 //        assertEquals("Lock count is incorrect", originalExpectedLockCount + expectedLockCountIncrease, document.getPessimisticLocks().size());
358 //        assertEquals("Establish locks method returned invalid number of edit modes", oldEditMode.size(), newEditMode.size());
359 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.FULL_ENTRY, DocumentAuthorizerBase.EDIT_MODE_DEFAULT_TRUE_VALUE);
360 //        verifyEditModeDoesNotExist(newEditMode, AuthorizationConstants.EditMode.VIEW_ONLY);
361 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.UNVIEWABLE, testString);
362 //
363 //        // test current user has lock with different lock descriptor and other users have no locks should return given edit
364 //        // modes
365 //        document = new MockDocument(getNonSuperUser(), false);
366 //        expectedLockDescriptor = lockDescriptor1;
367 //        GlobalVariables.getUserSession().addObject(TestDocumentAuthorizerBase.USER_SESSION_OBJECT_KEY, (Object) expectedLockDescriptor);
368 //        oldLock = lockService.generateNewLock(document.getDocumentNumber(), lockDescriptor3, getNonSuperUser());
369 //        document.addPessimisticLock(oldLock);
370 //        originalExpectedLockCount = 1;
371 //        // one lock should be created
372 //        expectedLockCountIncrease = 1;
373 //        assertEquals("Lock count is incorrect", originalExpectedLockCount, document.getPessimisticLocks().size());
374 //        oldEditMode = getEditMode_FullEntry();
375 //        testString = "is this the string";
376 //        oldEditMode.put(AuthorizationConstants.EditMode.VIEW_ONLY, testString);
377 //        newEditMode = this.pessimisticLock.establishLocks(document, oldEditMode, getNonSuperUser());
378 //        assertEquals("Lock count is incorrect", originalExpectedLockCount + expectedLockCountIncrease, document.getPessimisticLocks().size());
379 //        for (PessimisticLock lock : document.getPessimisticLocks()) {
380 //            if (!lock.getId().equals(oldLock.getId())) {
381 //                assertEquals("Lock descriptor of new lock is incorrect", expectedLockDescriptor, lock.getLockDescriptor());
382 //            }
383 //        }
384 //        assertEquals("Establish locks method returned invalid number of edit modes", oldEditMode.size(), newEditMode.size());
385 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.FULL_ENTRY, DocumentAuthorizerBase.EDIT_MODE_DEFAULT_TRUE_VALUE);
386 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.VIEW_ONLY, testString);
387 //        verifyEditModeDoesNotExist(newEditMode, AuthorizationConstants.EditMode.UNVIEWABLE);
388 //
389 //        // test invalid lock status (2 locks with same lock descriptor by 2 different users) throws exception
390 //        document = new MockDocument(getNonSuperUser(), false);
391 //        expectedLockDescriptor = lockDescriptor3;
392 //        GlobalVariables.getUserSession().addObject(TestDocumentAuthorizerBase.USER_SESSION_OBJECT_KEY, (Object) expectedLockDescriptor);
393 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), lockDescriptor1, getNonSuperUser()));
394 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), lockDescriptor3, getSecondNonSuperUser()));
395 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), lockDescriptor1, getSuperUser()));
396 //        try {
397 //            this.pessimisticLock.establishLocks(document, getEditMode_FullEntry(), getNonSuperUser());
398 //            fail("Document authorizer should have thrown exception of type PessimisticLockingException");
399 //        } catch (PessimisticLockingException e) {
400 //            // expected result
401 //        } catch (Exception e) {
402 //            fail("Document authorizer threw an exception but it was not of type PessimisticLockingException... it was a " + e.getClass().getName());
403 //        }
404 //
405 //        // test valid lock status (2 locks by 2 different users with one user being workflow lock user) does not throw
406 //        // exception
407 //        document = new MockDocument(getNonSuperUser(), false);
408 //        expectedLockDescriptor = lockDescriptor3;
409 //        GlobalVariables.getUserSession().addObject(TestDocumentAuthorizerBase.USER_SESSION_OBJECT_KEY, (Object) expectedLockDescriptor);
410 //        Person user = getWorkflowPessimisticLockOwnerUser();
411 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), lockDescriptor3, user));
412 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), lockDescriptor1, getSuperUser()));
413 //        try {
414 //            this.pessimisticLock.establishLocks(document, getEditMode_FullEntry(), getNonSuperUser());
415 //        } catch (Exception e) {
416 //            fail("Document authorizer should not have thrown an exception but did with type '" + e.getClass().getName() + "' and message: " + e.getMessage());
417 //        }
418 //
419 //        // test current user has lock with different descriptor and other users have locks with same descriptors should
420 //        // return read only editmodes
421 //        document = new MockDocument(getNonSuperUser(), false);
422 //        expectedLockDescriptor = lockDescriptor3;
423 //        GlobalVariables.getUserSession().addObject(TestDocumentAuthorizerBase.USER_SESSION_OBJECT_KEY, (Object) expectedLockDescriptor);
424 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), lockDescriptor1, getNonSuperUser()));
425 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), lockDescriptor3, getSuperUser()));
426 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), lockDescriptor2, getSecondNonSuperUser()));
427 //        originalExpectedLockCount = 3;
428 //        // no lock should be created
429 //        expectedLockCountIncrease = 0;
430 //        assertEquals("Lock count is incorrect", originalExpectedLockCount, document.getPessimisticLocks().size());
431 //        oldEditMode = getEditMode_FullEntry();
432 //        testString = "is this the string";
433 //        oldEditMode.put(AuthorizationConstants.EditMode.UNVIEWABLE, testString);
434 //        newEditMode = this.pessimisticLock.establishLocks(document, oldEditMode, getNonSuperUser());
435 //        assertEquals("Lock count is incorrect", originalExpectedLockCount + expectedLockCountIncrease, document.getPessimisticLocks().size());
436 //        assertEquals("Establish locks method returned invalid number of edit modes", oldEditMode.size(), newEditMode.size());
437 //        verifyEditModeDoesNotExist(newEditMode, AuthorizationConstants.EditMode.FULL_ENTRY);
438 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.VIEW_ONLY, DocumentAuthorizerBase.EDIT_MODE_DEFAULT_TRUE_VALUE);
439 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.UNVIEWABLE, testString);
440 //
441 //        // test current user has lock with same descriptor and other users have locks with different descriptors should
442 //        // return given editmodes
443 //        document = new MockDocument(getNonSuperUser(), false);
444 //        expectedLockDescriptor = lockDescriptor3;
445 //        GlobalVariables.getUserSession().addObject(TestDocumentAuthorizerBase.USER_SESSION_OBJECT_KEY, (Object) expectedLockDescriptor);
446 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), expectedLockDescriptor, getNonSuperUser()));
447 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), lockDescriptor1, getSuperUser()));
448 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), lockDescriptor2, getSecondNonSuperUser()));
449 //        originalExpectedLockCount = 3;
450 //        // no lock should be created
451 //        expectedLockCountIncrease = 0;
452 //        assertEquals("Lock count is incorrect", originalExpectedLockCount, document.getPessimisticLocks().size());
453 //        oldEditMode = getEditMode_FullEntry();
454 //        testString = "is this the string";
455 //        oldEditMode.put(AuthorizationConstants.EditMode.UNVIEWABLE, testString);
456 //        newEditMode = this.pessimisticLock.establishLocks(document, oldEditMode, getNonSuperUser());
457 //        assertEquals("Lock count is incorrect", originalExpectedLockCount + expectedLockCountIncrease, document.getPessimisticLocks().size());
458 //        assertEquals("Establish locks method returned invalid number of edit modes", oldEditMode.size(), newEditMode.size());
459 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.FULL_ENTRY, DocumentAuthorizerBase.EDIT_MODE_DEFAULT_TRUE_VALUE);
460 //        verifyEditModeDoesNotExist(newEditMode, AuthorizationConstants.EditMode.VIEW_ONLY);
461 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.UNVIEWABLE, testString);
462 //
463 //        // test current user has lock with different lock descriptor and other users have locks with different lock
464 //        // descriptor should return given edit modes
465 //        document = new MockDocument(getNonSuperUser(), false);
466 //        expectedLockDescriptor = lockDescriptor1;
467 //        List<Long> existingLockIds = new ArrayList<Long>();
468 //        GlobalVariables.getUserSession().addObject(TestDocumentAuthorizerBase.USER_SESSION_OBJECT_KEY, (Object) expectedLockDescriptor);
469 //        oldLock = lockService.generateNewLock(document.getDocumentNumber(), lockDescriptor3, getSecondNonSuperUser());
470 //        existingLockIds.add(oldLock.getId());
471 //        document.addPessimisticLock(oldLock);
472 //        oldLock = lockService.generateNewLock(document.getDocumentNumber(), lockDescriptor2, getSecondNonSuperUser());
473 //        existingLockIds.add(oldLock.getId());
474 //        document.addPessimisticLock(oldLock);
475 //        oldLock = lockService.generateNewLock(document.getDocumentNumber(), lockDescriptor3, getSuperUser());
476 //        existingLockIds.add(oldLock.getId());
477 //        document.addPessimisticLock(oldLock);
478 //        originalExpectedLockCount = existingLockIds.size();
479 //        // one lock should be created
480 //        expectedLockCountIncrease = 1;
481 //        assertEquals("Lock count is incorrect", originalExpectedLockCount, document.getPessimisticLocks().size());
482 //        oldEditMode = getEditMode_FullEntry();
483 //        testString = "is this the string";
484 //        oldEditMode.put(AuthorizationConstants.EditMode.VIEW_ONLY, testString);
485 //        newEditMode = this.pessimisticLock.establishLocks(document, oldEditMode, getNonSuperUser());
486 //        assertEquals("Lock count is incorrect", originalExpectedLockCount + expectedLockCountIncrease, document.getPessimisticLocks().size());
487 //        for (PessimisticLock lock : document.getPessimisticLocks()) {
488 //            if (!existingLockIds.contains(lock.getId())) {
489 //                // this must be the newly created lock
490 //                assertEquals("Lock descriptor of new lock is incorrect", expectedLockDescriptor, lock.getLockDescriptor());
491 //            }
492 //        }
493 //        assertEquals("Establish locks method returned invalid number of edit modes", oldEditMode.size(), newEditMode.size());
494 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.FULL_ENTRY, DocumentAuthorizerBase.EDIT_MODE_DEFAULT_TRUE_VALUE);
495 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.VIEW_ONLY, testString);
496 //        verifyEditModeDoesNotExist(newEditMode, AuthorizationConstants.EditMode.UNVIEWABLE);
497 //
498 //        // test current user has lock with wrong descriptor and no entry edit modes return given editmodes
499 //        document = new MockDocument(getNonSuperUser(), false);
500 //        expectedLockDescriptor = lockDescriptor3;
501 //        GlobalVariables.getUserSession().addObject(TestDocumentAuthorizerBase.USER_SESSION_OBJECT_KEY, (Object) expectedLockDescriptor);
502 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), lockDescriptor1, getNonSuperUser()));
503 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), lockDescriptor3, getSuperUser()));
504 //        document.addPessimisticLock(lockService.generateNewLock(document.getDocumentNumber(), lockDescriptor2, getSecondNonSuperUser()));
505 //        originalExpectedLockCount = 3;
506 //        // no lock should be created
507 //        expectedLockCountIncrease = 0;
508 //        assertEquals("Lock count is incorrect", originalExpectedLockCount, document.getPessimisticLocks().size());
509 //        oldEditMode = getEditMode_ReadOnly();
510 //        testString = "is this the string";
511 //        oldEditMode.put(AuthorizationConstants.EditMode.UNVIEWABLE, testString);
512 //        newEditMode = this.pessimisticLock.establishLocks(document, oldEditMode, getNonSuperUser());
513 //        assertEquals("Lock count is incorrect", originalExpectedLockCount + expectedLockCountIncrease, document.getPessimisticLocks().size());
514 //        assertEquals("Establish locks method returned invalid number of edit modes", oldEditMode.size(), newEditMode.size());
515 //        verifyEditModeDoesNotExist(newEditMode, AuthorizationConstants.EditMode.FULL_ENTRY);
516 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.VIEW_ONLY, DocumentAuthorizerBase.EDIT_MODE_DEFAULT_TRUE_VALUE);
517 //        verifyEditModeExists(newEditMode, AuthorizationConstants.EditMode.UNVIEWABLE, testString);
518     }
519 //
520     @Test
521     public void testHasPreRouteEditAuthorization() throws Exception {
522 //    	//TODO: the test for preRouteEditAuthorization should be removed
523 //        GlobalVariables.setUserSession(new UserSession("quickstart"));
524 //        PessimisticLockTestDocumentAuthorizer lockDocumentAuthorizer = new PessimisticLockTestDocumentAuthorizer();
525 //        lockDocumentAuthorizer.USES_PESSIMISTIC_LOCKING = false;
526 //
527 //        Person initiatorUser = getNonSuperUser();
528 //        Person authorizerUser = getNonSuperUser();
529 //        Document document = new MockDocument(initiatorUser, false);
530 //        assertTrue(authorizerUser + " should have Initiate Authorization due to initator being " + initiatorUser, lockDocumentAuthorizer.hasInitiateAuthorization(document, authorizerUser));
531 //        //assertTrue(authorizerUser + " should have Pre Route Edit Authorization", lockDocumentAuthorizer.hasPreRouteEditAuthorization(document, authorizerUser));
532 //
533 //        initiatorUser = getNonSuperUser();
534 //        authorizerUser = getSuperUser();
535 //        document = new MockDocument(initiatorUser, false);
536 //        assertFalse(authorizerUser + " should not have Initiate Authorization due to initator being " + initiatorUser, lockDocumentAuthorizer.hasInitiateAuthorization(document, authorizerUser));
537 //        //assertFalse(authorizerUser + " should not have Pre Route Edit Authorization", lockDocumentAuthorizer.hasPreRouteEditAuthorization(document, authorizerUser));
538 //
539 //        // switch to using pessimistic locking for the next tests
540 //        lockDocumentAuthorizer.USES_PESSIMISTIC_LOCKING = true;
541 //
542 //        initiatorUser = getNonSuperUser();
543 //        authorizerUser = getSuperUser();
544 //        document = new MockDocument(initiatorUser, false);
545 //        assertFalse(authorizerUser + " should not have Initiate Authorization due to initator being " + initiatorUser, lockDocumentAuthorizer.hasInitiateAuthorization(document, authorizerUser));
546 //        //assertFalse(authorizerUser + " should not have Pre Route Edit Authorization", lockDocumentAuthorizer.hasPreRouteEditAuthorization(document, authorizerUser));
547 //
548 //        initiatorUser = getNonSuperUser();
549 //        authorizerUser = getNonSuperUser();
550 //        document = new MockDocument(initiatorUser, false);
551 //        document.addPessimisticLock(KRADServiceLocatorInternal.getPessimisticLockService().generateNewLock(document.getDocumentNumber(), getSecondNonSuperUser()));
552 //        assertTrue(authorizerUser + " should have Initiate Authorization due to initator being " + initiatorUser, lockDocumentAuthorizer.hasInitiateAuthorization(document, authorizerUser));
553 //        //assertFalse(authorizerUser + " should not have Pre Route Edit Authorization", lockDocumentAuthorizer.hasPreRouteEditAuthorization(document, authorizerUser));
554 //
555 //        initiatorUser = getNonSuperUser();
556 //        authorizerUser = getNonSuperUser();
557 //        document = new MockDocument(initiatorUser, false);
558 //        document.addPessimisticLock(KRADServiceLocatorInternal.getPessimisticLockService().generateNewLock(document.getDocumentNumber(), authorizerUser));
559 //        assertTrue(authorizerUser + " should have Initiate Authorization due to initator being " + initiatorUser, lockDocumentAuthorizer.hasInitiateAuthorization(document, authorizerUser));
560 //        //assertTrue(authorizerUser + " should have Pre Route Edit Authorization", lockDocumentAuthorizer.hasPreRouteEditAuthorization(document, authorizerUser));
561     }
562 //
563     @Test
564     public void testGetDocumentActionFlagsUsingPessimisticLocking() throws Exception {
565 //        GlobalVariables.setUserSession(new UserSession("quickstart"));
566 //        String editModeTrueValue = "TRUE";
567 //        String editModeFalseValue = "FALSE";
568 //        PessimisticLockTestDocumentAuthorizer lockDocumentAuthorizer = new PessimisticLockTestDocumentAuthorizer();
569 //
570 //        Person initiatorUser = getNonSuperUser();
571 //        Person authorizerUser = getNonSuperUser();
572 //        Document document = new MockDocument(initiatorUser, false);
573 //        lockDocumentAuthorizer.USES_PESSIMISTIC_LOCKING = false;
574 //        Map editMode = new HashMap();
575 //        lockDocumentAuthorizer.setEditMode(MapUtils.putAll(editMode, new Map.Entry[]{new DefaultMapEntry(AuthorizationConstants.EditMode.VIEW_ONLY,"TRUE")}));
576 //        DocumentFormPlaceholder formDummy = implementDocumentAuthorizerMethods(lockDocumentAuthorizer, document, new MockPerson(GlobalVariables.getUserSession().getPerson()));
577     }
578 //
579 //    /**
580 //     * This is a stand-in object for a {@link KualiDocumentFormBase} object
581 //     */
582 //    private class DocumentFormPlaceholder {
583 //        public Map editingMode;
584 //        public DocumentActionFlags documentActionFlags;
585 //    }
586 //
587 //    /**
588 //     * This method is a stand-in method to duplicate the behavior of
589 //     * {@link KualiDocumentFormBase#populateAuthorizationFields(DocumentAuthorizer)} and
590 //     * {@link KualiDocumentFormBase#useDocumentAuthorizer(DocumentAuthorizer)}
591 //     *
592 //     * @param document -
593 //     *            document to use for edit modes and action flags
594 //     * @param kualiUser -
595 //     *            user to use in place of what may be in GlobalVariables
596 //     * @return a stand-in object for {@link KualiDocumentFormBase} that holds the edit mode map and the
597 //     *         {@link DocumentActionFlags} object that would be held in the {@link KualiDocumentFormBase}
598 //     */
599 //    private DocumentFormPlaceholder implementDocumentAuthorizerMethods(PessimisticLockTestDocumentAuthorizer documentAuthorizer, Document document, Person kualiUser) {
600 //        // Person kualiUser = GlobalVariables.getUserSession().getPerson();
601 //        // DocumentAuthorizer documentAuthorizer = KRADServiceLocatorInternal.getDocumentAuthorizationService().getDocumentAuthorizer(document);
602 //        Map editMode = documentAuthorizer.getEditMode(document, kualiUser);
603 //        if (documentAuthorizer.usesPessimisticLocking(document)) {
604 //            editMode = this.pessimisticLock.establishLocks(document, editMode, kualiUser);
605 //        }
606 //        DocumentFormPlaceholder formPlaceholder = new DocumentFormPlaceholder();
607 //        formPlaceholder.editingMode = editMode;
608 //        formPlaceholder.documentActionFlags = documentAuthorizer.getDocumentActionFlags(document, kualiUser);
609 //        return formPlaceholder;
610 //    }
611 //
612 //    private Person getSuperUser() {
613 //        return new MockPerson(SUPERVISOR_UNIVERSAL, SUPERVISOR_USER, true);
614 //    }
615 //
616 //    private Person getNonSuperUser() {
617 //        return new MockPerson(NONSUPER_UNIVERSAL, NONSUPER_USER, false);
618 //    }
619 //
620 //    private Person getSecondNonSuperUser() {
621 //        return new MockPerson(NONSUPER_2_UNIVERSAL, NONSUPER_2_USER, false);
622 //    }
623 //
624 //    private Map getEditMode_ReadOnly() {
625 //        return constructEditMode(AuthorizationConstants.EditMode.VIEW_ONLY);
626 //    }
627 //
628 //    private Map getEditMode_FullEntry() {
629 //        return constructEditMode(AuthorizationConstants.EditMode.FULL_ENTRY);
630 //    }
631 //
632 //    private Map constructEditMode(String editModeValue) {
633 //        Map editMode = new HashMap();
634 //        editMode.put(editModeValue, DocumentAuthorizerBase.EDIT_MODE_DEFAULT_TRUE_VALUE);
635 //        return editMode;
636 //    }
637 //
638 //    private class MockDocument extends DocumentBase {
639 //
640 //        private MockDocument() {
641 //            super();
642 //        }
643 //
644 //        public MockDocument(Person initiator, boolean isApprovalRequested) {
645 //            this();
646 //            this.documentNumber = "1234567890";
647 //            getDocumentHeader().setWorkflowDocument(new MockWorkflowDocument(initiator, isApprovalRequested));
648 //        }
649 //
650 //        @Override
651 //        protected LinkedHashMap toStringMapper() {
652 //            LinkedHashMap map = new LinkedHashMap();
653 //            map.put("class", "MockDocument");
654 //            map.put(KNSPropertyConstants.DOCUMENT_NUMBER, documentNumber);
655 //            map.put("initiator", getDocumentHeader().getWorkflowDocument().getInitiatorNetworkId());
656 //            return map;
657 //        }
658 //
659 //        public boolean getAllowsCopy() {
660 //            return false;
661 //        }
662 //
663 //    }
664 //
665 //    private class MockWorkflowDocument extends MockWorkflowDocument {
666 //
667 //        private Person initiator;
668 //        private boolean approvalRequested;
669 //
670 //        private MockWorkflowDocument() {};
671 //
672 //        public MockWorkflowDocument(Person initiator, boolean isApprovalRequested) {
673 //            this.initiator = initiator;
674 //            this.approvalRequested = isApprovalRequested;
675 //        }
676 //
677 //        public String getInitiatorNetworkId() {
678 //            return initiator.getPrincipalName();
679 //        }
680 //
681 //        public boolean isApprovalRequested() {
682 //            return approvalRequested;
683 //        }
684 //
685 //        public boolean userIsInitiator(Person user) {
686 //            return initiator.getPrincipalId().equalsIgnoreCase(user.getPrincipalId());
687 //        }
688 //
689 //		/**
690 //		 * This overridden method ...
691 //		 *
692 //		 * @see org.kuali.rice.krad.workflow.service.KualiWorkflowDocument#appSpecificRouteDocumentToGroup(java.lang.String, java.lang.String, int, java.lang.String, org.kuali.rice.kim.bo.group.dto.GroupInfo, java.lang.String, boolean)
693 //		 */
694 //		public void appSpecificRouteDocumentToGroup(String actionRequested,
695 //				String routeTypeName, String annotation,
696 //				GroupIdDTO groupId, String responsibilityDesc,
697 //				boolean forceAction) throws WorkflowException {
698 //			// TODO sp20369 - THIS METHOD NEEDS JAVADOCS
699 //
700 //		}
701 //
702 //    }
703 //
704 //    private class MockPerson extends PersonImpl {
705 //        private boolean supervisor;
706 //        private String principalId;
707 //        private String principalName;
708 //
709 //        private MockPerson() {};
710 //
711 //        public MockPerson(Person user) {
712 //            this(user.getPrincipalId(), user.getPrincipalName(), KimApiServiceLocator.getIdentityManagementService().isMemberOfGroup(user.getPrincipalId(), org.kuali.rice.kim.util.KimApiConstants.KIM_GROUP_KFS_NAMESPACE_CODE, KRADServiceLocatorInternal.getKualiConfigurationService().getPropertyValueAsString(KNSConstants.KNS_NAMESPACE, KNSConstants.DetailTypes.DOCUMENT_DETAIL_TYPE, KNSConstants.CoreApcParms.SUPERVISOR_WORKGROUP)));
713 //        }
714 //
715 //        public MockPerson(String universalId, String userId, boolean supervisor) {
716 //            this.principalId = universalId;
717 //            this.principalName = userId;
718 //            this.supervisor = supervisor;
719 //        }
720 //
721 //        public boolean isSupervisorUser() {
722 //            return supervisor;
723 //        }
724 //
725 //        public String toString() {
726 //            return ((supervisor) ? "Supervisor " : "") + "User (" + getPrincipalName() + ")";
727 //        }
728 //
729 //		public String getPrincipalId() {
730 //			return this.principalId == null ? super.getPrincipalId() : this.principalId;
731 //		}
732 //
733 //		public String getPrincipalName() {
734 //			return this.principalName == null ? super.getPrincipalName() : this.principalName;
735 //		}
736 //
737 //    }
738 }