EMMA Coverage Report (generated Fri Sep 15 10:32:43 EDT 2006)
[all classes][edu.iu.uis.sit.portal.portlet.admin.web]

COVERAGE SUMMARY FOR SOURCE FILE [AllWindowStateControllersTest.java]

nameclass, %method, %block, %line, %
AllWindowStateControllersTest.java100% (1/1)92%  (22/24)45%  (455/1016)45%  (119.8/267)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AllWindowStateControllersTest100% (1/1)92%  (22/24)45%  (455/1016)45%  (119.8/267)
getOneStartUser (): OneStartUser 0%   (0/1)0%   (0/3)0%   (0/1)
getUser (): User 0%   (0/1)0%   (0/41)0%   (0/11)
onSetUpInTransaction (): void 100% (1/1)11%  (54/472)12%  (16/135)
testWindowStateDeleteOnSubmitAction (): void 100% (1/1)56%  (15/27)67%  (4/6)
testWindowStateValidatorValidate (): void 100% (1/1)64%  (21/33)75%  (6/8)
testWindowStateOnSubmitAction (): void 100% (1/1)71%  (30/42)78%  (7/9)
testWindowStateDeleteOnSubmitRender (): void 100% (1/1)79%  (48/61)84%  (10.9/13)
testWindowStateFormBackingObject (): void 100% (1/1)80%  (47/59)86%  (12/14)
testWindowStateDeleteFormBackingObject (): void 100% (1/1)80%  (48/60)86%  (12/14)
testWindowStateOnSubmitRender (): void 100% (1/1)85%  (72/85)88%  (15.9/18)
testWindowStateViewHandleRenderRequestInternal (): void 100% (1/1)85%  (75/88)89%  (16.9/19)
AllWindowStateControllersTest (): void 100% (1/1)100% (3/3)100% (1/1)
getAdminService (): AdminService 100% (1/1)100% (3/3)100% (1/1)
getUserService (): UserService 100% (1/1)100% (3/3)100% (1/1)
getWindowStateController (): WindowStateController 100% (1/1)100% (3/3)100% (1/1)
getWindowStateDeleteController (): WindowStateDeleteController 100% (1/1)100% (3/3)100% (1/1)
getWindowStateValidator (): WindowStateValidator 100% (1/1)100% (3/3)100% (1/1)
getWindowStateViewController (): WindowStateViewController 100% (1/1)100% (3/3)100% (1/1)
setAdminService (AdminService): void 100% (1/1)100% (4/4)100% (2/2)
setUserService (UserService): void 100% (1/1)100% (4/4)100% (2/2)
setWindowStateController (WindowStateController): void 100% (1/1)100% (4/4)100% (2/2)
setWindowStateDeleteController (WindowStateDeleteController): void 100% (1/1)100% (4/4)100% (2/2)
setWindowStateValidator (WindowStateValidator): void 100% (1/1)100% (4/4)100% (2/2)
setWindowStateViewController (WindowStateViewController): void 100% (1/1)100% (4/4)100% (2/2)

1package edu.iu.uis.sit.portal.portlet.admin.web;
2 
3import java.sql.Timestamp;
4import java.util.ArrayList;
5import java.util.Iterator;
6import java.util.List;
7import java.util.Map;
8 
9import org.springframework.mock.web.portlet.MockPortletRequest;
10import org.springframework.mock.web.portlet.MockRenderRequest;
11import org.springframework.mock.web.portlet.MockRenderResponse;
12import org.springframework.validation.BindException;
13import org.springframework.validation.Errors;
14import org.springframework.web.portlet.ModelAndView;
15 
16import edu.iu.uis.sit.portal.PersistenceBrokerAbstractTransactionalDataSourceSpringContextTests;
17import edu.iu.uis.sit.portal.portlet.admin.domain.PortalConfig;
18import edu.iu.uis.sit.portal.portlet.admin.domain.PortalSupport;
19import edu.iu.uis.sit.portal.portlet.admin.domain.PortletApplication;
20import edu.iu.uis.sit.portal.portlet.admin.domain.PortletConfig;
21import edu.iu.uis.sit.portal.portlet.admin.services.AdminService;
22import edu.iu.uis.sit.portal.portlet.utility.Constants;
23import edu.iu.uis.sit.portal.user.User;
24import edu.iu.uis.sit.portal.user.domain.OneStartUser;
25import edu.iu.uis.sit.portal.user.service.UserService;
26 
27public class AllWindowStateControllersTest extends PersistenceBrokerAbstractTransactionalDataSourceSpringContextTests {
28 
29        private AdminService adminService;
30 
31        private UserService userService;
32 
33        private WindowStateValidator windowStateValidator;
34 
35        private WindowStateViewController windowStateViewController;
36 
37        private WindowStateDeleteController windowStateDeleteController;
38 
39        private WindowStateController windowStateController;
40 
41        private OneStartUser oneStartUser;
42 
43        private PortalConfig portalConfig;
44 
45        private PortalSupport portalSupport;
46 
47        protected void onSetUpInTransaction() throws Exception {
48                OneStartUser oneStartUser = new OneStartUser();
49                oneStartUser.setEmplId("01234567890");
50                oneStartUser.setUserName("jdoe");
51                oneStartUser.setLastLoginDate(new Timestamp(System.currentTimeMillis()));
52                getUserService().saveOneStartUser(oneStartUser);
53                this.oneStartUser = oneStartUser;
54 
55                PortalConfig portalConfig = getAdminService().getPortalConfig();
56                if (portalConfig == null) {
57                        portalConfig = new PortalConfig();
58                        portalConfig.setPortalVersion("1.1.0-BETA1");
59                        portalConfig.setContainerName("Pluto Portal Driver");
60                        portalConfig.setPortalName("pluto-portal-driver");
61 
62                        List supports = new ArrayList();
63                        PortalSupport support = new PortalSupport();
64                        support.setPortalConfig(portalConfig);
65                        support.setSupportName("view");
66                        support.setSupportType(Constants.PORTLET_MODE_SUPPORT);
67                        supports.add(support);
68 
69                        support = new PortalSupport();
70                        support.setPortalConfig(portalConfig);
71                        support.setSupportName("edit");
72                        support.setSupportType(Constants.PORTLET_MODE_SUPPORT);
73                        supports.add(support);
74 
75                        support = new PortalSupport();
76                        support.setPortalConfig(portalConfig);
77                        support.setSupportName("help");
78                        support.setSupportType(Constants.PORTLET_MODE_SUPPORT);
79                        supports.add(support);
80 
81                        support = new PortalSupport();
82                        support.setPortalConfig(portalConfig);
83                        support.setSupportName("config");
84                        support.setSupportType(Constants.PORTLET_MODE_SUPPORT);
85                        supports.add(support);
86 
87                        support = new PortalSupport();
88                        support.setPortalConfig(portalConfig);
89                        support.setSupportName("normal");
90                        support.setSupportType(Constants.WINDOW_STATE_SUPPORT);
91                        supports.add(support);
92 
93                        support = new PortalSupport();
94                        support.setPortalConfig(portalConfig);
95                        support.setSupportName("maximized");
96                        support.setSupportType(Constants.WINDOW_STATE_SUPPORT);
97                        supports.add(support);
98 
99                        support = new PortalSupport();
100                        support.setPortalConfig(portalConfig);
101                        support.setSupportName("minimized");
102                        support.setSupportType(Constants.WINDOW_STATE_SUPPORT);
103                        supports.add(support);
104 
105                        List portletApplications = new ArrayList();
106                        PortletApplication application = new PortletApplication();
107                        application.setContextPath("/my-dev");
108 
109                        List portletConfigs = new ArrayList();
110                        PortletConfig config = new PortletConfig();
111                        config.setPortletApplication(application);
112                        config.setPortletName("AdminPortlet");
113                        portletConfigs.add(config);
114 
115                        config = new PortletConfig();
116                        config.setPortletApplication(application);
117                        config.setPortletName("PublishingPortlet");
118                        portletConfigs.add(config);
119 
120                        config = new PortletConfig();
121                        config.setPortletApplication(application);
122                        config.setPortletName("GroupsPortlet");
123                        portletConfigs.add(config);
124 
125                        config = new PortletConfig();
126                        config.setPortletApplication(application);
127                        config.setPortletName("ExamplePortlet");
128                        portletConfigs.add(config);
129 
130                        application.setPortletConfigs(portletConfigs);
131                        portletApplications.add(application);
132 
133                        application = new PortletApplication();
134                        application.setContextPath("/onestartportlets");
135 
136                        portletConfigs = new ArrayList();
137                        config = new PortletConfig();
138                        config.setPortletApplication(application);
139                        config.setPortletName("IframePortlet");
140                        portletConfigs.add(config);
141 
142                        config = new PortletConfig();
143                        config.setPortletApplication(application);
144                        config.setPortletName("RSSPortlet");
145                        portletConfigs.add(config);
146 
147                        application.setPortletConfigs(portletConfigs);
148                        portletApplications.add(application);
149 
150                        application = new PortletApplication();
151                        application.setContextPath("/ccf-dev");
152 
153                        portletConfigs = new ArrayList();
154                        config = new PortletConfig();
155                        config.setPortletApplication(application);
156                        config.setPortletName("ClassifiedsPortlet");
157                        portletConfigs.add(config);
158 
159                        application.setPortletConfigs(portletConfigs);
160                        portletApplications.add(application);
161 
162                        application = new PortletApplication();
163                        application.setContextPath("/SpringPortlets");
164 
165                        portletConfigs = new ArrayList();
166                        config = new PortletConfig();
167                        config.setPortletApplication(application);
168                        config.setPortletName("books");
169                        portletConfigs.add(config);
170 
171                        portletConfigs = new ArrayList();
172                        config = new PortletConfig();
173                        config.setPortletApplication(application);
174                        config.setPortletName("exceptions");
175                        portletConfigs.add(config);
176 
177                        portletConfigs = new ArrayList();
178                        config = new PortletConfig();
179                        config.setPortletApplication(application);
180                        config.setPortletName("mode");
181                        portletConfigs.add(config);
182 
183                        portletConfigs = new ArrayList();
184                        config = new PortletConfig();
185                        config.setPortletApplication(application);
186                        config.setPortletName("redirect");
187                        portletConfigs.add(config);
188 
189                        portletConfigs = new ArrayList();
190                        config = new PortletConfig();
191                        config.setPortletApplication(application);
192                        config.setPortletName("upload");
193                        portletConfigs.add(config);
194 
195                        portletConfigs = new ArrayList();
196                        config = new PortletConfig();
197                        config.setPortletApplication(application);
198                        config.setPortletName("helloworld");
199                        portletConfigs.add(config);
200 
201                        application.setPortletConfigs(portletConfigs);
202                        portletApplications.add(application);
203 
204                        getAdminService().savePortalConfig(portalConfig);
205                }
206                PortalSupport portalSupport = new PortalSupport();
207                portalSupport.setSupportType(Constants.WINDOW_STATE_SUPPORT);
208                portalSupport.setSupportName("test");
209                portalSupport.setPortalConfig(portalConfig);
210 
211                getAdminService().savePortalSupport(portalConfig, portalSupport);
212                this.portalSupport = portalSupport;
213                this.portalConfig = portalConfig;
214        }
215 
216        private User getUser() {
217                String userName = "jdoe";
218                String firstName = "John";
219                String lastName = "Doe";
220                String emailAddress = "jdoe@university.edu";
221                String campusCode = "BL";
222                List groups = new ArrayList();
223                groups.add("group1");
224                groups.add("group2");
225                groups.add("group3");
226 
227                OneStartUser oneStartUser = getUserService().findOneStartUserByUserName(userName);
228                return new User(oneStartUser, lastName, firstName, emailAddress, campusCode, groups);
229        }
230 
231        public void testWindowStateValidatorValidate() {
232                try {
233                        WebPortalConfig webPortalConfig = new WebPortalConfig();
234                        Errors errors = new BindException(webPortalConfig, "webPortalConfig");
235                        getWindowStateValidator().validate(webPortalConfig, errors);
236                        assertTrue("There should be errors from the validation. Required field support name (window state name).", errors.hasErrors());
237                } catch (Exception e) {
238                        assertTrue("An error occured.  " + e.toString(), false);
239                }
240        }
241 
242        public void testWindowStateOnSubmitAction() {
243                try {
244                        WebPortalConfig webPortalConfig = new WebPortalConfig(portalConfig);
245                        portalSupport.setSupportName("change");
246                        webPortalConfig.setPortalSupport(portalSupport);
247                        getWindowStateController().onSubmitAction(webPortalConfig);
248                        assertEquals("Portal Support should have been updated.", "change", getAdminService().findPortalSupportById(portalSupport.getPortalSupportId()).getSupportName());
249                } catch (Exception e) {
250                        assertTrue("An error occured.  " + e.toString(), false);
251                }
252        }
253 
254        public void testWindowStateOnSubmitRender() {
255                try {
256                        WebPortalConfig webPortalConfig = new WebPortalConfig(portalConfig);
257                        ModelAndView modelAndView = getWindowStateController().onSubmitRender(webPortalConfig);
258 
259                        assertNotNull("ModelAndView does not contain content.", modelAndView.getModel());
260                        if (modelAndView.getModel() != null) {
261                                assertTrue("ModelAndView does not contain a window states.", modelAndView.getModel().containsKey("windowStates"));
262                                for (Iterator iter = modelAndView.getModel().entrySet().iterator(); iter.hasNext();) {
263                                        Map.Entry entry = (Map.Entry) iter.next();
264                                        if (entry.getKey().equals("windowStates")) {
265                                                assertTrue("There should be at least 1 window state.", ((List) entry.getValue()).size() > 0);
266                                                for (Iterator iterator = ((List) entry.getValue()).iterator(); iterator.hasNext();) {
267                                                        PortalSupport support = (PortalSupport) iterator.next();
268                                                        assertTrue("All portal supports should be window states.",Constants.WINDOW_STATE_SUPPORT.equals(support.getSupportType()));
269                                                }
270                                        }
271                                }
272                        }
273                } catch (Exception e) {
274                        assertTrue("An error occured.  " + e.toString(), false);
275                }
276        }
277 
278        public void testWindowStateFormBackingObject() {
279                MockPortletRequest portletRequest = new MockPortletRequest();
280 
281                try {
282                        Object object = getWindowStateController().formBackingObject(portletRequest);
283                        assertTrue("Command object should be of type WebPortalConfig.", object instanceof WebPortalConfig);
284 
285                        WebPortalConfig webPortalConfig = (WebPortalConfig) object;
286                        assertNotNull("WebPortalConfig should be present.", webPortalConfig);
287                        assertNull("Portal Support should be empty because we are creating a new one.", webPortalConfig.getPortalSupport().getSupportName());
288 
289                        portletRequest.addParameter("portalSupportId", portalSupport.getPortalSupportId().toString());
290                        object = getWindowStateController().formBackingObject(portletRequest);
291 
292                        webPortalConfig = (WebPortalConfig) object;
293                        assertEquals("Portal Support context should be test.", "test", webPortalConfig.getPortalSupport().getSupportName());
294                } catch (Exception e) {
295                        assertTrue("An error occured.  " + e.toString(), false);
296                }
297        }
298 
299        public void testWindowStateDeleteOnSubmitRender() {
300                try {
301                        ModelAndView modelAndView = getWindowStateDeleteController().onSubmitRender(portalSupport);
302 
303                        assertNotNull("ModelAndView does not contain content.", modelAndView.getModel());
304                        if (modelAndView.getModel() != null) {
305                                assertTrue("ModelAndView does not contain a window states.", modelAndView.getModel().containsKey("windowStates"));
306                                for (Iterator iter = modelAndView.getModel().entrySet().iterator(); iter.hasNext();) {
307                                        Map.Entry entry = (Map.Entry) iter.next();
308                                        if (entry.getKey().equals("windowStates")) {
309                                                assertTrue("There may be 0 or more window states.", ((List) entry.getValue()).size() >= 0);
310                                        }
311                                }
312                        }
313                } catch (Exception e) {
314                        assertTrue("An error occured.  " + e.toString(), false);
315                }
316        }
317 
318        public void testWindowStateDeleteOnSubmitAction() {
319                try {
320                        getWindowStateDeleteController().onSubmitAction(portalSupport);
321                        assertNull("Portal Support should have been deleted.", getAdminService().findPortalSupportById(portalSupport.getPortalSupportId()));
322                } catch (Exception e) {
323                        assertTrue("An error occured.  " + e.toString(), false);
324                }
325        }
326 
327        public void testWindowStateDeleteFormBackingObject() {
328                MockPortletRequest portletRequest = new MockPortletRequest();
329 
330                try {
331                        Object object = getWindowStateDeleteController().formBackingObject(portletRequest);
332                        assertTrue("Command object should be of type PortalSupport.", object instanceof PortalSupport);
333 
334                        PortalSupport portalSupport = (PortalSupport) object;
335                        assertNull("Portal support should be a new empty object.", portalSupport.getPortalSupportId());
336 
337                        portletRequest.addParameter("portalSupportId", this.portalSupport.getPortalSupportId().toString());
338 
339                        object = getWindowStateDeleteController().formBackingObject(portletRequest);
340                        assertTrue("Command object should be of type PortalSupport.", object instanceof PortalSupport);
341 
342                        PortalSupport found = (PortalSupport) object;
343                        assertEquals("Portal support id is incorrect.", this.portalSupport.getPortalSupportId(), found.getPortalSupportId());
344 
345                } catch (Exception e) {
346                        assertTrue("An error occured.  " + e.toString(), false);
347                }
348        }
349 
350        public void testWindowStateViewHandleRenderRequestInternal() {
351                MockRenderRequest renderRequest = new MockRenderRequest();
352                MockRenderResponse renderResponse = new MockRenderResponse();
353                try {
354                        ModelAndView modelAndView = getWindowStateViewController().handleRenderRequestInternal(renderRequest, renderResponse);
355 
356                        assertNotNull("ModelAndView does not contain content.", modelAndView.getModel());
357                        if (modelAndView.getModel() != null) {
358                                assertTrue("ModelAndView does not contain a window states.", modelAndView.getModel().containsKey("windowStates"));
359                                for (Iterator iter = modelAndView.getModel().entrySet().iterator(); iter.hasNext();) {
360                                        Map.Entry entry = (Map.Entry) iter.next();
361                                        if (entry.getKey().equals("windowStates")) {
362                                                assertTrue("There should be at least 1 window state.", ((List) entry.getValue()).size() > 0);
363                                                for (Iterator iterator = ((List) entry.getValue()).iterator(); iterator.hasNext();) {
364                                                        PortalSupport support = (PortalSupport) iterator.next();
365                                                        assertTrue("All portal supports should be window states",Constants.WINDOW_STATE_SUPPORT.equals(support.getSupportType()));
366                                                }
367                                        }
368                                }
369                        }
370                } catch (Exception e) {
371                        assertTrue("An error occured.  " + e.toString(), false);
372                }
373        }
374 
375        public OneStartUser getOneStartUser() {
376                return oneStartUser;
377        }
378 
379        public UserService getUserService() {
380                return userService;
381        }
382 
383        public void setUserService(UserService userService) {
384                this.userService = userService;
385        }
386 
387        public AdminService getAdminService() {
388                return adminService;
389        }
390 
391        public void setAdminService(AdminService adminService) {
392                this.adminService = adminService;
393        }
394 
395        public WindowStateController getWindowStateController() {
396                return windowStateController;
397        }
398 
399        public void setWindowStateController(WindowStateController windowStateController) {
400                this.windowStateController = windowStateController;
401        }
402 
403        public WindowStateDeleteController getWindowStateDeleteController() {
404                return windowStateDeleteController;
405        }
406 
407        public void setWindowStateDeleteController(WindowStateDeleteController windowStateDeleteController) {
408                this.windowStateDeleteController = windowStateDeleteController;
409        }
410 
411        public WindowStateValidator getWindowStateValidator() {
412                return windowStateValidator;
413        }
414 
415        public void setWindowStateValidator(WindowStateValidator windowStateValidator) {
416                this.windowStateValidator = windowStateValidator;
417        }
418 
419        public WindowStateViewController getWindowStateViewController() {
420                return windowStateViewController;
421        }
422 
423        public void setWindowStateViewController(WindowStateViewController windowStateViewController) {
424                this.windowStateViewController = windowStateViewController;
425        }
426 
427}

[all classes][edu.iu.uis.sit.portal.portlet.admin.web]
EMMA 2.0.5312 (C) Vladimir Roubtsov