001: /*
002: * Copyright 2006-2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.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/ecl1.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: */
016: package org.kuali.core.service.mock;
017:
018: import java.util.LinkedHashMap;
019:
020: import org.kuali.core.bo.DocumentHeader;
021: import org.kuali.core.document.DocumentBase;
022: import org.kuali.core.workflow.service.KualiWorkflowDocument;
023: import org.kuali.core.workflow.service.impl.KualiWorkflowDocumentImpl;
024:
025: import edu.iu.uis.eden.exception.WorkflowException;
026:
027: /**
028: *
029: *
030: */
031: public class MockDocument extends DocumentBase implements
032: MockDocumentInterface {
033:
034: private static final String NONE = "none";
035: private static final String ROUTE_DOCUMENT = "routeDoc";
036: private static final String APPROVE_DOCUMENT = "approveDoc";
037: private static final String SAVE_DOCUMENT = "saveDoc";
038: private static final String ADD_LINE = "addLine";
039: private static final String DELETE_LINE = "deleteLine";
040: private static final String UPDATE_LINE = "updateLine";
041: private static final String REVIEW_LINE = "reviewLine";
042: private static final String GENERATE_PENDING = "generatePending";
043: private static final String ADD_DOC_NOTE = "addDocNote";
044: // made these static (ugly hack) because
045: // a) events now store a deepCopy of their document, which means that when MockRule changes its document's state,
046: // that state change is being made to a copy of the document (and the copy never makes it back out to the tests,
047: // so the tests can't see that the change ever happened); since static fields are shared between the original
048: // and all copies, changes to these fields will survive the whole copying experience
049: // b) within the lifetime of a given test, there should only be one MockDocument or descendent active, so
050: // this shouldn't be introducing any threading-related heisenbugs (and no, I don't want to add the
051: // synchornization necessary to guarantee that; at least, not yet)
052: private static boolean processed;
053: private static String eventType;
054: private static String prevEventType;
055:
056: public MockDocument() {
057: processed = false;
058: eventType = NONE;
059: prevEventType = NONE;
060:
061: this .documentHeader = new DocumentHeader();
062: try {
063: KualiWorkflowDocument wfDoc = new KualiWorkflowDocumentImpl(
064: null, "RuleMockDocument");
065: documentHeader.setWorkflowDocument(wfDoc);
066: } catch (WorkflowException e) {
067: throw new RuntimeException(e.getMessage());
068: }
069: }
070:
071: public String getDocumentTitle() {
072: return "MockDocument title";
073: }
074:
075: public final void handleRouteStatusChange() {
076: throw new UnsupportedOperationException();
077: }
078:
079: protected LinkedHashMap toStringMapper() {
080: return new LinkedHashMap();
081: }
082:
083: public void setProcessed(boolean processed) {
084: MockDocument.processed = processed;
085: }
086:
087: public boolean isProcessed() {
088: return processed;
089: }
090:
091: public void setEventType(String eventType) {
092: MockDocument.prevEventType = MockDocument.eventType;
093: MockDocument.eventType = eventType;
094: }
095:
096: public String getEventType() {
097: return eventType;
098: }
099:
100: public String getPrevEventType() {
101: return prevEventType;
102: }
103:
104: public boolean getAllowsCopy() {
105: return false;
106: }
107: }
|