001/** 002 * Copyright 2005-2014 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.kew.actions; 017 018import org.junit.Test; 019import org.kuali.rice.kew.api.WorkflowDocument; 020import org.kuali.rice.kew.api.WorkflowDocumentFactory; 021import org.kuali.rice.kew.api.action.ActionRequestType; 022import org.kuali.rice.kew.test.KEWTestCase; 023import org.kuali.rice.kew.api.KewApiConstants; 024import org.kuali.rice.kim.api.KimConstants; 025 026import static org.junit.Assert.assertTrue; 027import static org.junit.Assert.fail; 028 029/** 030 * 031 * @author delyea 032 */ 033public class ClearFYIActionTest extends KEWTestCase { 034 035 private String getSavedStatusDisplayValue() { 036 return (String) KewApiConstants.DOCUMENT_STATUSES.get(KewApiConstants.ROUTE_HEADER_SAVED_CD); 037 } 038 039 @Test public void testSavedDocumentAdhocRequest() throws Exception { 040 WorkflowDocument doc = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), "TestDocumentType"); 041 doc.saveDocument(""); 042 doc.adHocToPrincipal(ActionRequestType.FYI, "annotation1", getPrincipalIdForName("dewey"), "respDesc1", false); 043 String userId = getPrincipalIdForName("dewey"); 044 doc = WorkflowDocumentFactory.loadDocument(userId, doc.getDocumentId()); 045 assertTrue("FYI should be requested of user " + userId, doc.isFYIRequested()); 046 try { 047 doc.fyi(); 048 } catch (Exception e) { 049 fail("A non-initator with an FYI request should be allowed to take the FYI action on a " + getSavedStatusDisplayValue() + " document"); 050 } 051 assertTrue("Document should be " + getSavedStatusDisplayValue(), doc.isSaved()); 052 053 String workgroupUserId = getPrincipalIdForName("dewey"); 054 doc = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), "TestDocumentType"); 055 doc.saveDocument(""); 056 057 doc.adHocToGroup(ActionRequestType.FYI, "annotation1", getGroupIdForName(KimConstants.KIM_GROUP_WORKFLOW_NAMESPACE_CODE, "NonSIT"), "respDesc1", false); 058 doc = WorkflowDocumentFactory.loadDocument(workgroupUserId, doc.getDocumentId()); 059 assertTrue("FYI should be requested of user " + workgroupUserId, doc.isFYIRequested()); 060 try { 061 doc.fyi(); 062 } catch (Exception e) { 063 fail("A non-initator with an FYI request should be allowed to take the FYI action on a " + getSavedStatusDisplayValue() + " document"); 064 } 065 assertTrue("Document should be " + getSavedStatusDisplayValue(), doc.isSaved()); 066 } 067}