001    /*
002     * Copyright 2007-2008 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     */
016    package mocks;
017    
018    import java.sql.Timestamp;
019    import java.util.Collection;
020    import java.util.Date;
021    
022    import org.kuali.rice.kew.actionitem.ActionItem;
023    import org.kuali.rice.kew.doctype.bo.DocumentType;
024    import org.kuali.rice.kew.feedback.web.FeedbackForm;
025    import org.kuali.rice.kew.mail.EmailContent;
026    import org.kuali.rice.kew.mail.service.impl.StyleableEmailContentServiceImpl;
027    import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
028    import org.kuali.rice.kew.util.KEWConstants;
029    import org.kuali.rice.kim.bo.Person;
030    
031    
032    /**
033     * This is a class used to substitute for a StyleableEmailContentServiceImpl class
034     *
035     * @author Kuali Rice Team (rice.collab@kuali.org)
036     *
037     */
038    public class MockStyleableEmailContentServiceImpl extends StyleableEmailContentServiceImpl implements MockStyleableEmailContentService {
039    
040        private boolean wasAccessed = false;
041    
042        @Override
043        public EmailContent generateImmediateReminder(Person user, ActionItem actionItem, DocumentType documentType) {
044            wasAccessed = true;
045            return super.generateImmediateReminder(user, actionItem, documentType);
046        }
047    
048        @Override
049        public EmailContent generateDailyReminder(Person user, Collection<ActionItem> actionItems) {
050            wasAccessed = true;
051            return super.generateDailyReminder(user, actionItems);
052        }
053    
054        @Override
055        public EmailContent generateWeeklyReminder(Person user, Collection<ActionItem> actionItems) {
056            wasAccessed = true;
057            return super.generateWeeklyReminder(user, actionItems);
058        }
059    
060        @Override
061        public EmailContent generateFeedback(FeedbackForm form) {
062            wasAccessed = true;
063            return super.generateFeedback(form);
064        }
065    
066        /**
067         * This overridden method is used in case the action item has an null route header attached
068         *
069         * @see org.kuali.rice.kew.mail.service.impl.StyleableEmailContentServiceImpl#getRouteHeader(org.kuali.rice.kew.actionitem.ActionItem)
070         */
071        @Override
072        public DocumentRouteHeaderValue getRouteHeader(ActionItem actionItem) {
073            if (actionItem.getRouteHeader() != null) {
074                return super.getRouteHeader(actionItem);
075            }
076            DocumentRouteHeaderValue routeHeader = new DocumentRouteHeaderValue();
077            routeHeader.setDocRouteStatus(KEWConstants.ROUTE_HEADER_ENROUTE_CD);
078            routeHeader.setCreateDate(new Timestamp(new Date().getTime()));
079            return routeHeader;
080        }
081    
082        /**
083         * This method returns whether this service is being used
084         */
085        public boolean wasServiceAccessed() {
086            return this.wasAccessed;
087        }
088    
089        /**
090         * This method returns whether this service is being used
091         */
092        public void resetServiceAccessed() {
093            this.wasAccessed = false;
094        }
095    
096    }