1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.exoplatform.commons.search.service;
18
19 import java.util.Arrays;
20 import java.util.Comparator;
21 import java.util.HashMap;
22 import java.util.List;
23
24 import org.exoplatform.commons.utils.LazyPageList;
25 import org.exoplatform.commons.utils.ListAccess;
26 import org.exoplatform.portal.application.PortletPreferences;
27 import org.exoplatform.portal.config.DataStorage;
28 import org.exoplatform.portal.config.Query;
29 import org.exoplatform.portal.config.model.Application;
30 import org.exoplatform.portal.config.model.ApplicationState;
31 import org.exoplatform.portal.config.model.ApplicationType;
32 import org.exoplatform.portal.config.model.Container;
33 import org.exoplatform.portal.config.model.Dashboard;
34 import org.exoplatform.portal.config.model.ModelObject;
35 import org.exoplatform.portal.config.model.Page;
36 import org.exoplatform.portal.config.model.PortalConfig;
37 import org.exoplatform.portal.pom.data.ModelChange;
38 import org.exoplatform.services.log.ExoLogger;
39 import org.exoplatform.services.log.Log;
40 import org.mockito.Mockito;
41 import org.picocontainer.Startable;
42
43
44
45
46
47
48
49 public class MockDataStorage implements DataStorage,Startable {
50
51 private static final Log LOG = ExoLogger.getLogger(MockDataStorage.class);
52
53 static private HashMap<String, Page> pageCollections = new HashMap<String, Page>();
54
55 public static final String[] PORTAL_CLASSIC__WIKI = new String[] { "portal::classic::wiki", PortalConfig.PORTAL_TYPE, "classic" };
56
57 public static final String[] USER_MARY_WIKI = new String[] { "user::mary::wiki", PortalConfig.USER_TYPE, "mary" };
58
59 public static final String[] GROUP_USER_WIKI = new String[] { "group::/platform/users::wiki", PortalConfig.GROUP_TYPE,
60 "/platform/users" };
61
62 public static final String[] SPACE_EXO_WIKI = new String[] { "group::/space/exo::wiki", PortalConfig.GROUP_TYPE, "/space/exo" };
63
64 private List<String[]> pageDatas = Arrays.asList(new String[][] { PORTAL_CLASSIC__WIKI, USER_MARY_WIKI,
65 GROUP_USER_WIKI, SPACE_EXO_WIKI });
66
67
68
69
70 @Override
71 public void create(PortalConfig config) throws Exception {
72
73 }
74
75
76
77
78 @Override
79 public void save(PortalConfig config) throws Exception {
80
81 }
82
83
84
85
86 @Override
87 public PortalConfig getPortalConfig(String portalName) throws Exception {
88 return null;
89 }
90
91
92
93
94 @Override
95 public PortalConfig getPortalConfig(String ownerType, String portalName) throws Exception {
96 return null;
97 }
98
99
100
101
102 @Override
103 public void remove(PortalConfig config) throws Exception {
104
105 }
106
107
108
109
110 @Override
111 public Page getPage(String pageId) throws Exception {
112 return pageCollections.get(pageId);
113 }
114
115
116
117
118 @Override
119 public Page clonePage(String pageId, String clonedOwnerType, String clonedOwnerId, String clonedName) {
120 return null;
121 }
122
123
124
125
126 @Override
127 public void remove(Page page) {
128
129 }
130
131
132
133
134 @Override
135 public void create(Page page) {
136 pageCollections.put(page.getId(), page);
137 }
138
139
140
141
142 @Override
143 public List<ModelChange> save(Page page) throws Exception {
144 return null;
145 }
146
147
148
149
150 public void save(PortletPreferences portletPreferences) throws Exception {
151
152 }
153
154
155
156
157 @Override
158 public <S> String getId(ApplicationState<S> state) throws Exception {
159 return null;
160 }
161
162
163
164
165 @Override
166 public <S> S load(ApplicationState<S> state, ApplicationType<S> type) throws Exception {
167 return null;
168 }
169
170
171
172
173 @Override
174 public <S> ApplicationState<S> save(ApplicationState<S> state, S preferences) throws Exception {
175 return null;
176 }
177
178
179
180
181 public PortletPreferences getPortletPreferences(String windowID) throws Exception {
182 return null;
183 }
184
185
186
187
188 @Override
189 public <T> LazyPageList<T> find(Query<T> q) throws Exception {
190 return null;
191 }
192
193
194
195
196 @Override
197 public <T> LazyPageList<T> find(Query<T> q, Comparator<T> sortComparator) throws Exception {
198 return null;
199 }
200
201
202
203
204 @Override
205 public <T> ListAccess<T> find2(Query<T> q) throws Exception {
206 return null;
207 }
208
209
210
211
212 @Override
213 public <T> ListAccess<T> find2(Query<T> q, Comparator<T> sortComparator) throws Exception {
214 return null;
215 }
216
217
218
219
220 @Override
221 public Container getSharedLayout() throws Exception {
222 return null;
223 }
224
225
226
227
228 @Override
229 public Dashboard loadDashboard(String dashboardId) throws Exception {
230 return null;
231 }
232
233
234
235
236 @Override
237 public void saveDashboard(Dashboard dashboard) throws Exception {
238
239 }
240
241
242
243
244 @Override
245 public List<String> getAllPortalNames() throws Exception {
246 return Arrays.asList("intranet", "acme");
247 }
248
249
250
251
252 @Override
253 public List<String> getAllGroupNames() throws Exception {
254 return null;
255 }
256
257
258
259
260 @Override
261 public <A> A adapt(ModelObject modelObject, Class<A> type) {
262 return null;
263 }
264
265
266
267
268 @Override
269 public <A> A adapt(ModelObject modelObject, Class<A> type, boolean create) {
270 return null;
271 }
272
273
274
275
276 @Override
277 public void start() {
278 try {
279 for (String[] item : pageDatas) {
280 Page page = Mockito.mock(Page.class);
281 Mockito.when(page.getId()).thenReturn(item[0]);
282 Mockito.when(page.getOwnerType()).thenReturn(item[1]);
283 Mockito.when(page.getOwnerId()).thenReturn(item[2]);
284 create(page);
285 }
286 } catch (Exception e) {
287 LOG.warn("Could not create default page data for test", e);
288 }
289 }
290
291
292
293
294 @Override
295 public void stop() {
296 }
297
298
299
300
301 @Override
302 public void save() throws Exception {
303
304
305 }
306
307 @Override
308 public String[] getSiteInfo(String applicationStorageId) throws Exception {
309
310 return null;
311 }
312
313 @Override
314 public <S> Application<S> getApplicationModel(String applicationStorageId)
315 throws Exception {
316
317 return null;
318 }
319
320 }