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.kns.workflow;
17  
18  import org.junit.Test;
19  import org.kuali.rice.kew.doctype.bo.DocumentType;
20  import org.kuali.rice.kew.engine.RouteContext;
21  import org.kuali.rice.kew.service.KEWServiceLocator;
22  import org.kuali.rice.kim.api.services.KimApiServiceLocator;
23  import org.kuali.rice.krad.UserSession;
24  import org.kuali.rice.krad.document.Document;
25  import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
26  import org.kuali.rice.krad.test.document.SearchAttributeIndexTestDocumentOjb;
27  import org.kuali.rice.krad.util.GlobalVariables;
28  
29  
30  /**
31   * tests that a document, which goes through a regular or blanket approval process, is indexed correctly
32   * 
33   * @author Kuali Rice Team (rice.collab@kuali.org)
34   *
35   * @deprecated KNS test class, convert to KRAD equivalent if applicable.
36   */
37  @Deprecated
38  public class SearchAttributeIndexRequestOjbTest extends SearchAttributeIndexRequestTest {
39  
40      private static final String SEARCH_ATTRIBUTE_INDEX_DOCUMENT_TEST_DOC_TYPE = "SearchAttributeIndexTestDocumentOjb";
41  	
42  	private enum DOCUMENT_FIXTURE {
43  		NORMAL_DOCUMENT("hippo","routing");
44  		
45  		private String constantString;
46  		private String routingString;
47  		private DOCUMENT_FIXTURE(String constantString, String routingString) {
48  			this.constantString = constantString;
49  			this.routingString = routingString;
50  		}
51  
52          public Document getDocument() throws Exception {
53              Document document = KRADServiceLocatorWeb.getDocumentService().getNewDocument(SEARCH_ATTRIBUTE_INDEX_DOCUMENT_TEST_DOC_TYPE);
54              SearchAttributeIndexTestDocumentOjb searchAttributeIndexTestDocument = (SearchAttributeIndexTestDocumentOjb) document;
55              searchAttributeIndexTestDocument.initialize(constantString, routingString);
56  
57              return searchAttributeIndexTestDocument;
58          }
59  	}
60  
61      @Test
62      public void regularApproveTest() throws Exception {
63          final String principalName = "quickstart";
64          final String principalId = KimApiServiceLocator.getPersonService().getPersonByPrincipalName(principalName).getPrincipalId();
65          GlobalVariables.setUserSession(new UserSession(principalName));
66          RouteContext.clearCurrentRouteContext();
67  
68          Document document = DOCUMENT_FIXTURE.NORMAL_DOCUMENT.getDocument();
69          document.getDocumentHeader().setDocumentDescription("Routed SAIndexTestDoc");
70          final DocumentType documentType = KEWServiceLocator.getDocumentTypeService().findByName(SEARCH_ATTRIBUTE_INDEX_DOCUMENT_TEST_DOC_TYPE);
71  
72          assertApproveAttributes(document, documentType, principalId);
73      }
74  
75      @Test
76      public void blanketApproveTest() throws Exception {
77          final String principalName = "admin";
78          final String principalId = KimApiServiceLocator.getPersonService().getPersonByPrincipalName(principalName).getPrincipalId();
79          GlobalVariables.setUserSession(new UserSession(principalName));
80  
81          Document document = DOCUMENT_FIXTURE.NORMAL_DOCUMENT.getDocument();
82          document.getDocumentHeader().setDocumentDescription("Blanket Approved SAIndexTestDoc");
83          final DocumentType documentType = KEWServiceLocator.getDocumentTypeService().findByName(SEARCH_ATTRIBUTE_INDEX_DOCUMENT_TEST_DOC_TYPE);
84  
85          assertBlanketApproveAttributes(document, documentType, principalId);
86      }
87  
88  
89  }