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