View Javadoc

1   /*
2    * Copyright 2007-2008 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 mocks;
17  
18  import java.sql.Timestamp;
19  import java.util.Collection;
20  import java.util.Date;
21  
22  import org.kuali.rice.kew.actionitem.ActionItem;
23  import org.kuali.rice.kew.doctype.bo.DocumentType;
24  import org.kuali.rice.kew.feedback.web.FeedbackForm;
25  import org.kuali.rice.kew.mail.EmailContent;
26  import org.kuali.rice.kew.mail.service.impl.StyleableEmailContentServiceImpl;
27  import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
28  import org.kuali.rice.kew.util.KEWConstants;
29  import org.kuali.rice.kim.bo.Person;
30  
31  
32  /**
33   * This is a class used to substitute for a StyleableEmailContentServiceImpl class
34   *
35   * @author Kuali Rice Team (rice.collab@kuali.org)
36   *
37   */
38  public class MockStyleableEmailContentServiceImpl extends StyleableEmailContentServiceImpl implements MockStyleableEmailContentService {
39  
40      private boolean wasAccessed = false;
41  
42      @Override
43      public EmailContent generateImmediateReminder(Person user, ActionItem actionItem, DocumentType documentType) {
44          wasAccessed = true;
45          return super.generateImmediateReminder(user, actionItem, documentType);
46      }
47  
48      @Override
49      public EmailContent generateDailyReminder(Person user, Collection<ActionItem> actionItems) {
50          wasAccessed = true;
51          return super.generateDailyReminder(user, actionItems);
52      }
53  
54      @Override
55      public EmailContent generateWeeklyReminder(Person user, Collection<ActionItem> actionItems) {
56          wasAccessed = true;
57          return super.generateWeeklyReminder(user, actionItems);
58      }
59  
60      @Override
61      public EmailContent generateFeedback(FeedbackForm form) {
62          wasAccessed = true;
63          return super.generateFeedback(form);
64      }
65  
66      /**
67       * This overridden method is used in case the action item has an null route header attached
68       *
69       * @see org.kuali.rice.kew.mail.service.impl.StyleableEmailContentServiceImpl#getRouteHeader(org.kuali.rice.kew.actionitem.ActionItem)
70       */
71      @Override
72      public DocumentRouteHeaderValue getRouteHeader(ActionItem actionItem) {
73          if (actionItem.getRouteHeader() != null) {
74              return super.getRouteHeader(actionItem);
75          }
76          DocumentRouteHeaderValue routeHeader = new DocumentRouteHeaderValue();
77          routeHeader.setDocRouteStatus(KEWConstants.ROUTE_HEADER_ENROUTE_CD);
78          routeHeader.setCreateDate(new Timestamp(new Date().getTime()));
79          return routeHeader;
80      }
81  
82      /**
83       * This method returns whether this service is being used
84       */
85      public boolean wasServiceAccessed() {
86          return this.wasAccessed;
87      }
88  
89      /**
90       * This method returns whether this service is being used
91       */
92      public void resetServiceAccessed() {
93          this.wasAccessed = false;
94      }
95  
96  }