View Javadoc
1   /**
2    * Copyright 2005-2014 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.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   * @author Kuali Rice Team (rice.collab@kuali.org)
33   */
34  @Ignore //SessionDocumentServiceImpl has been Deprecated and removed from use in KRAD
35  public class SessionDocumentServiceImplTest {
36  
37      // Generate sample objects for mocks and testing
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 //SessionDocumentServiceImpl has been Deprecated and removed from use in KRAD
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 //SessionDocumentServiceImpl has been Deprecated and removed from use in KRAD
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 //SessionDocumentServiceImpl has been Deprecated and removed from use in KRAD
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