1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.service.impl;
17
18 import org.junit.Assert;
19 import org.junit.Before;
20 import org.junit.Ignore;
21 import org.junit.Test;
22 import org.kuali.rice.kew.api.KewApiConstants;
23 import org.kuali.rice.kew.api.WorkflowDocument;
24 import org.kuali.rice.kew.impl.document.WorkflowDocumentImpl;
25 import org.kuali.rice.krad.UserSession;
26 import org.mockito.Mockito;
27
28
29 import java.util.concurrent.*;
30
31
32
33
34 @Ignore
35 public class SessionDocumentServiceImplTest {
36
37
38 private SessionDocumentServiceImpl sessionDocumentServiceImpl = new SessionDocumentServiceImpl();
39 private UserSession session;
40 private WorkflowDocument doc;
41 private String docId = "1";
42 private ConcurrentHashMap<String, WorkflowDocument> map = new ConcurrentHashMap<String, WorkflowDocument>();
43
44 @Before
45 public void setUp() {
46 session = Mockito.mock(UserSession.class);
47 doc = Mockito.mock(WorkflowDocumentImpl.class);
48 Mockito.when(doc.getDocumentId()).thenReturn(docId);
49 map.put(docId,doc);
50 }
51
52 @Test
53 @Ignore
54 public void testAddDocumentToUserSession() {
55 try {
56 sessionDocumentServiceImpl.addDocumentToUserSession(session, doc);
57 } catch(Exception e) {
58 Assert.fail("Exception occurred adding document to user session");
59 }
60 }
61 @Test
62 @Ignore
63 public void testGetDocumentFromSessionWithEntry() {
64 try {
65 Mockito.when(session.retrieveObject(KewApiConstants.WORKFLOW_DOCUMENT_MAP_ATTR_NAME)).thenReturn(map);
66 WorkflowDocument returnedDoc = sessionDocumentServiceImpl.getDocumentFromSession(session,docId);
67 Assert.assertEquals("Document should match mock document", doc, returnedDoc);
68 } catch(Exception e) {
69 Assert.fail("Exception occurred retrieving document to user session");
70 }
71 }
72
73 @Test
74 @Ignore
75 public void testGetDocumentFromSessionWithNoEntry() {
76 try {
77 Mockito.when(session.retrieveObject(KewApiConstants.WORKFLOW_DOCUMENT_MAP_ATTR_NAME)).thenReturn(null);
78 WorkflowDocument returnedDoc = sessionDocumentServiceImpl.getDocumentFromSession(session,docId);
79 Assert.assertNull("Document should have returned null", returnedDoc);
80 } catch(Exception e) {
81 Assert.fail("Exception occurred retrieving document to user session");
82 }
83 }
84
85 }
86