001 /** 002 * Copyright 2005-2013 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 org.kuali.rice.krad.uif.util; 017 018 import java.util.Collection; 019 import java.util.Collections; 020 021 import org.kuali.rice.krad.messages.Message; 022 import org.kuali.rice.krad.messages.MessageService; 023 024 /** 025 * Provides mock messages for UIF unit tests. 026 * 027 * @author Kuali Rice Team (rice.collab@kuali.org) 028 */ 029 public class MockMessageService implements MessageService { 030 031 /** 032 * @see org.kuali.rice.krad.messages.MessageService#getMessage(java.lang.String, 033 * java.lang.String, java.lang.String) 034 */ 035 @Override 036 public Message getMessage(String namespace, String component, String key) { 037 Message rv = new Message(); 038 rv.setNamespaceCode(namespace); 039 rv.setComponentCode(component); 040 rv.setKey(key); 041 rv.setText(getMessageText(namespace, component, key)); 042 return rv; 043 } 044 045 /** 046 * @see org.kuali.rice.krad.messages.MessageService#getMessage(java.lang.String, 047 * java.lang.String, java.lang.String, java.lang.String) 048 */ 049 @Override 050 public Message getMessage(String namespace, String component, String key, String locale) { 051 Message rv = new Message(); 052 rv.setNamespaceCode(namespace); 053 rv.setComponentCode(component); 054 rv.setKey(key); 055 rv.setLocale(locale); 056 rv.setText(namespace + ":" + component + ":" + key + ":" + locale); 057 return rv; 058 } 059 060 /** 061 * @see org.kuali.rice.krad.messages.MessageService#getMessageText(java.lang.String, 062 * java.lang.String, java.lang.String) 063 */ 064 @Override 065 public String getMessageText(String namespace, String component, String key) { 066 return namespace + ":" + component + ":" + key; 067 } 068 069 /** 070 * @see org.kuali.rice.krad.messages.MessageService#getMessageText(java.lang.String, 071 * java.lang.String, java.lang.String, java.lang.String) 072 */ 073 @Override 074 public String getMessageText(String namespace, String component, String key, String locale) { 075 return namespace + ":" + component + ":" + key + ":" + locale; 076 } 077 078 /** 079 * @see org.kuali.rice.krad.messages.MessageService#getMessageText(java.lang.String) 080 */ 081 @Override 082 public String getMessageText(String key) { 083 return key; 084 } 085 086 /** 087 * @see org.kuali.rice.krad.messages.MessageService#getMessageText(java.lang.String, 088 * java.lang.String) 089 */ 090 @Override 091 public String getMessageText(String key, String locale) { 092 return key + ":" + locale; 093 } 094 095 /** 096 * @see org.kuali.rice.krad.messages.MessageService#getAllMessagesForComponent(java.lang.String, 097 * java.lang.String) 098 */ 099 @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 }