View Javadoc

1   /**
2    * Copyright 2005-2013 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.krad.uif.util;
17  
18  import java.util.Collection;
19  import java.util.Collections;
20  
21  import org.kuali.rice.krad.messages.Message;
22  import org.kuali.rice.krad.messages.MessageService;
23  
24  /**
25   * Provides mock messages for UIF unit tests.
26   * 
27   * @author Kuali Rice Team (rice.collab@kuali.org)
28   */
29  public class MockMessageService implements MessageService {
30  
31      /**
32       * @see org.kuali.rice.krad.messages.MessageService#getMessage(java.lang.String,
33       *      java.lang.String, java.lang.String)
34       */
35      @Override
36      public Message getMessage(String namespace, String component, String key) {
37          Message rv = new Message();
38          rv.setNamespaceCode(namespace);
39          rv.setComponentCode(component);
40          rv.setKey(key);
41          rv.setText(getMessageText(namespace, component, key));
42          return rv;
43      }
44  
45      /**
46       * @see org.kuali.rice.krad.messages.MessageService#getMessage(java.lang.String,
47       *      java.lang.String, java.lang.String, java.lang.String)
48       */
49      @Override
50      public Message getMessage(String namespace, String component, String key, String locale) {
51          Message rv = new Message();
52          rv.setNamespaceCode(namespace);
53          rv.setComponentCode(component);
54          rv.setKey(key);
55          rv.setLocale(locale);
56          rv.setText(namespace + ":" + component + ":" + key + ":" + locale);
57          return rv;
58      }
59  
60      /**
61       * @see org.kuali.rice.krad.messages.MessageService#getMessageText(java.lang.String,
62       *      java.lang.String, java.lang.String)
63       */
64      @Override
65      public String getMessageText(String namespace, String component, String key) {
66          return namespace + ":" + component + ":" + key;
67      }
68  
69      /**
70       * @see org.kuali.rice.krad.messages.MessageService#getMessageText(java.lang.String,
71       *      java.lang.String, java.lang.String, java.lang.String)
72       */
73      @Override
74      public String getMessageText(String namespace, String component, String key, String locale) {
75          return namespace + ":" + component + ":" + key + ":" + locale;
76      }
77  
78      /**
79       * @see org.kuali.rice.krad.messages.MessageService#getMessageText(java.lang.String)
80       */
81      @Override
82      public String getMessageText(String key) {
83          return key;
84      }
85  
86      /**
87       * @see org.kuali.rice.krad.messages.MessageService#getMessageText(java.lang.String,
88       *      java.lang.String)
89       */
90      @Override
91      public String getMessageText(String key, String locale) {
92          return key + ":" + locale;
93      }
94  
95      /**
96       * @see org.kuali.rice.krad.messages.MessageService#getAllMessagesForComponent(java.lang.String,
97       *      java.lang.String)
98       */
99      @Override
100     public Collection<Message> getAllMessagesForComponent(String namespace, String component) {
101         Message rv = new Message();
102         rv.setNamespaceCode(namespace);
103         rv.setComponentCode(component);
104         rv.setText(namespace + ":" + component);
105         return Collections.singletonList(rv);
106     }
107 
108     /**
109      * @see org.kuali.rice.krad.messages.MessageService#getAllMessagesForComponent(java.lang.String,
110      *      java.lang.String, java.lang.String)
111      */
112     @Override
113     public Collection<Message> getAllMessagesForComponent(String namespace, String component, String locale) {
114         Message rv = new Message();
115         rv.setNamespaceCode(namespace);
116         rv.setComponentCode(component);
117         rv.setLocale(locale);
118         rv.setText(namespace + ":" + component + ":" + locale);
119         return Collections.singletonList(rv);
120     }
121 
122 }