001: /* Copyright 2005 The JA-SIG Collaborative. All rights reserved.
002: * See license distributed with this file and
003: * available online at http://www.uportal.org/license.html
004: */
005:
006: package org.jasig.portal.services.stats;
007:
008: import org.jasig.portal.ChannelDefinition;
009: import org.jasig.portal.UserProfile;
010: import org.jasig.portal.layout.node.IUserLayoutChannelDescription;
011: import org.jasig.portal.layout.node.IUserLayoutFolderDescription;
012: import org.jasig.portal.security.IPerson;
013:
014: /**
015: * This is a Mock Object stats recorder. It exists to support stats recorder
016: * unit testing.
017: *
018: * This object maintains internal counters of received "events" on the
019: * IStatsRecorder API and exposes those lists for interrogation. Test code can examine these counters to implement
020: * sanity checking.
021: * @since uPortal 2.5.2
022: */
023: public class MockStatsRecorder implements IStatsRecorder {
024:
025: private int logins = 0;
026:
027: private int logouts = 0;
028:
029: private int sessionCreates = 0;
030:
031: private int sessionDestroys = 0;
032:
033: private int channelDefinitionPublishes = 0;
034:
035: private int channelDefinitionModifies = 0;
036:
037: private int channelDefinitionRemoves = 0;
038:
039: private int channelAddsToLayout = 0;
040:
041: private int channelUpdatesInLayout = 0;
042:
043: private int channelMovesInLayout = 0;
044:
045: private int channelRemovesFromLayout = 0;
046:
047: private int folderAddsToLayout = 0;
048:
049: private int folderUpdatesInLayout = 0;
050:
051: private int folderMovesInLayout = 0;
052:
053: private int folderRemovesFromLayout = 0;
054:
055: private int channelInstantiates = 0;
056:
057: private int channelRenders = 0;
058:
059: private int channelTargets = 0;
060:
061: // IStatsRecorder methods
062:
063: public void recordLogin(IPerson person) {
064: this .logins++;
065: }
066:
067: public void recordLogout(IPerson person) {
068: this .logouts++;
069: }
070:
071: public void recordSessionCreated(IPerson person) {
072: this .sessionCreates++;
073: }
074:
075: public void recordSessionDestroyed(IPerson person) {
076: this .sessionDestroys++;
077: }
078:
079: public void recordChannelDefinitionPublished(IPerson person,
080: ChannelDefinition channelDef) {
081: this .channelDefinitionPublishes++;
082: }
083:
084: public void recordChannelDefinitionModified(IPerson person,
085: ChannelDefinition channelDef) {
086: this .channelDefinitionModifies++;
087: }
088:
089: public void recordChannelDefinitionRemoved(IPerson person,
090: ChannelDefinition channelDef) {
091: this .channelDefinitionRemoves++;
092: }
093:
094: public void recordChannelAddedToLayout(IPerson person,
095: UserProfile profile,
096: IUserLayoutChannelDescription channelDesc) {
097: this .channelAddsToLayout++;
098: }
099:
100: public void recordChannelUpdatedInLayout(IPerson person,
101: UserProfile profile,
102: IUserLayoutChannelDescription channelDesc) {
103: this .channelUpdatesInLayout++;
104: }
105:
106: public void recordChannelMovedInLayout(IPerson person,
107: UserProfile profile,
108: IUserLayoutChannelDescription channelDesc) {
109: this .channelMovesInLayout++;
110: }
111:
112: public void recordChannelRemovedFromLayout(IPerson person,
113: UserProfile profile,
114: IUserLayoutChannelDescription channelDesc) {
115: this .channelRemovesFromLayout++;
116: }
117:
118: public void recordFolderAddedToLayout(IPerson person,
119: UserProfile profile, IUserLayoutFolderDescription folderDesc) {
120: this .folderAddsToLayout++;
121: }
122:
123: public void recordFolderUpdatedInLayout(IPerson person,
124: UserProfile profile, IUserLayoutFolderDescription folderDesc) {
125: this .folderUpdatesInLayout++;
126: }
127:
128: public void recordFolderMovedInLayout(IPerson person,
129: UserProfile profile, IUserLayoutFolderDescription folderDesc) {
130: this .folderMovesInLayout++;
131: }
132:
133: public void recordFolderRemovedFromLayout(IPerson person,
134: UserProfile profile, IUserLayoutFolderDescription folderDesc) {
135: this .folderRemovesFromLayout++;
136: }
137:
138: public void recordChannelInstantiated(IPerson person,
139: UserProfile profile,
140: IUserLayoutChannelDescription channelDesc) {
141: this .channelInstantiates++;
142: }
143:
144: public void recordChannelRendered(IPerson person,
145: UserProfile profile,
146: IUserLayoutChannelDescription channelDesc) {
147: this .channelRenders++;
148: }
149:
150: public void recordChannelTargeted(IPerson person,
151: UserProfile profile,
152: IUserLayoutChannelDescription channelDesc) {
153: this .channelTargets++;
154: }
155:
156: // counter accessor methods
157:
158: public int getChannelAddsToLayout() {
159: return channelAddsToLayout;
160: }
161:
162: public int getChannelDefinitionModifies() {
163: return channelDefinitionModifies;
164: }
165:
166: public int getChannelDefinitionPublishes() {
167: return channelDefinitionPublishes;
168: }
169:
170: public int getChannelDefinitionRemoves() {
171: return channelDefinitionRemoves;
172: }
173:
174: public int getChannelInstantiates() {
175: return channelInstantiates;
176: }
177:
178: public int getChannelMovesInLayout() {
179: return channelMovesInLayout;
180: }
181:
182: public int getChannelRemovesFromLayout() {
183: return channelRemovesFromLayout;
184: }
185:
186: public int getChannelRenders() {
187: return channelRenders;
188: }
189:
190: public int getChannelTargets() {
191: return channelTargets;
192: }
193:
194: public int getChannelUpdatesInLayout() {
195: return channelUpdatesInLayout;
196: }
197:
198: public int getFolderAddsToLayout() {
199: return folderAddsToLayout;
200: }
201:
202: public int getFolderMovesInLayout() {
203: return folderMovesInLayout;
204: }
205:
206: public int getFolderRemovesFromLayout() {
207: return folderRemovesFromLayout;
208: }
209:
210: public int getFolderUpdatesInLayout() {
211: return folderUpdatesInLayout;
212: }
213:
214: public int getLogins() {
215: return logins;
216: }
217:
218: public int getLogouts() {
219: return logouts;
220: }
221:
222: public int getSessionCreates() {
223: return sessionCreates;
224: }
225:
226: public int getSessionDestroys() {
227: return sessionDestroys;
228: }
229:
230: }
|