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.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   * Copyright 2005-2012 The Kuali Foundation
35   *
36   * Licensed under the Educational Community License, Version 2.0 (the "License");
37   * you may not use this file except in compliance with the License.
38   * You may obtain a copy of the License at
39   *
40   * http://www.opensource.org/licenses/ecl2.php
41   *
42   * Unless required by applicable law or agreed to in writing, software
43   * distributed under the License is distributed on an "AS IS" BASIS,
44   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
45   * See the License for the specific language governing permissions and
46   * limitations under the License.
47   */
48  @Ignore //SessionDocumentServiceImpl has been Deprecated and removed from use in KRAD
49  public class SessionDocumentServiceImplTest {
50  
51      // Generate sample objects for mocks and testing
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 //SessionDocumentServiceImpl has been Deprecated and removed from use in KRAD
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 //SessionDocumentServiceImpl has been Deprecated and removed from use in KRAD
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 //SessionDocumentServiceImpl has been Deprecated and removed from use in KRAD
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