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 [AllPortalConfigControllersTest.java]

nameclass, %method, %block, %line, %
AllPortalConfigControllersTest.java100% (1/1)89%  (17/19)25%  (178/700)29%  (57/198)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AllPortalConfigControllersTest100% (1/1)89%  (17/19)25%  (178/700)29%  (57/198)
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)7%   (33/451)8%   (10/129)
testPortalConfigOnSubmitAction (): void 100% (1/1)60%  (18/30)71%  (5/7)
testPortalConfigOnSubmitRender (): void 100% (1/1)60%  (18/30)71%  (5/7)
testPortalConfigFormBackingObject (): void 100% (1/1)64%  (21/33)78%  (7/9)
testPortalConfigValidatorValidate (): void 100% (1/1)64%  (21/33)75%  (6/8)
testPortalConfigViewHandleRenderRequestInternal (): void 100% (1/1)71%  (29/41)80%  (8/10)
AllPortalConfigControllersTest (): void 100% (1/1)100% (3/3)100% (1/1)
getAdminService (): AdminService 100% (1/1)100% (3/3)100% (1/1)
getPortalConfigController (): PortalConfigController 100% (1/1)100% (3/3)100% (1/1)
getPortalConfigValidator (): PortalConfigValidator 100% (1/1)100% (3/3)100% (1/1)
getPortalConfigViewController (): PortalConfigViewController 100% (1/1)100% (3/3)100% (1/1)
getUserService (): UserService 100% (1/1)100% (3/3)100% (1/1)
setAdminService (AdminService): void 100% (1/1)100% (4/4)100% (2/2)
setPortalConfigController (PortalConfigController): void 100% (1/1)100% (4/4)100% (2/2)
setPortalConfigValidator (PortalConfigValidator): void 100% (1/1)100% (4/4)100% (2/2)
setPortalConfigViewController (PortalConfigViewController): void 100% (1/1)100% (4/4)100% (2/2)
setUserService (UserService): 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.List;
6 
7import org.springframework.mock.web.portlet.MockPortletRequest;
8import org.springframework.mock.web.portlet.MockRenderRequest;
9import org.springframework.mock.web.portlet.MockRenderResponse;
10import org.springframework.validation.BindException;
11import org.springframework.validation.Errors;
12import org.springframework.web.portlet.ModelAndView;
13 
14import edu.iu.uis.sit.portal.PersistenceBrokerAbstractTransactionalDataSourceSpringContextTests;
15import edu.iu.uis.sit.portal.portlet.admin.domain.PortalConfig;
16import edu.iu.uis.sit.portal.portlet.admin.domain.PortalSupport;
17import edu.iu.uis.sit.portal.portlet.admin.domain.PortletApplication;
18import edu.iu.uis.sit.portal.portlet.admin.domain.PortletConfig;
19import edu.iu.uis.sit.portal.portlet.admin.services.AdminService;
20import edu.iu.uis.sit.portal.portlet.utility.Constants;
21import edu.iu.uis.sit.portal.user.User;
22import edu.iu.uis.sit.portal.user.domain.OneStartUser;
23import edu.iu.uis.sit.portal.user.service.UserService;
24 
25public class AllPortalConfigControllersTest extends PersistenceBrokerAbstractTransactionalDataSourceSpringContextTests {
26 
27        private AdminService adminService;
28 
29        private UserService userService;
30 
31        private PortalConfigValidator portalConfigValidator;
32 
33        private PortalConfigViewController portalConfigViewController;
34 
35        private PortalConfigController portalConfigController;
36 
37        private OneStartUser oneStartUser;
38 
39        private PortalConfig portalConfig;
40 
41        protected void onSetUpInTransaction() throws Exception {
42                OneStartUser oneStartUser = new OneStartUser();
43                oneStartUser.setEmplId("01234567890");
44                oneStartUser.setUserName("jdoe");
45                oneStartUser.setLastLoginDate(new Timestamp(System.currentTimeMillis()));
46                getUserService().saveOneStartUser(oneStartUser);
47                this.oneStartUser = oneStartUser;
48 
49                PortalConfig portalConfig = getAdminService().getPortalConfig();
50                if (portalConfig == null) {
51                        portalConfig = new PortalConfig();
52                        portalConfig.setPortalVersion("1.1.0-BETA1");
53                        portalConfig.setContainerName("Pluto Portal Driver");
54                        portalConfig.setPortalName("pluto-portal-driver");
55 
56                        List supports = new ArrayList();
57                        PortalSupport support = new PortalSupport();
58                        support.setPortalConfig(portalConfig);
59                        support.setSupportName("view");
60                        support.setSupportType(Constants.PORTLET_MODE_SUPPORT);
61                        supports.add(support);
62 
63                        support = new PortalSupport();
64                        support.setPortalConfig(portalConfig);
65                        support.setSupportName("edit");
66                        support.setSupportType(Constants.PORTLET_MODE_SUPPORT);
67                        supports.add(support);
68 
69                        support = new PortalSupport();
70                        support.setPortalConfig(portalConfig);
71                        support.setSupportName("help");
72                        support.setSupportType(Constants.PORTLET_MODE_SUPPORT);
73                        supports.add(support);
74 
75                        support = new PortalSupport();
76                        support.setPortalConfig(portalConfig);
77                        support.setSupportName("config");
78                        support.setSupportType(Constants.PORTLET_MODE_SUPPORT);
79                        supports.add(support);
80 
81                        support = new PortalSupport();
82                        support.setPortalConfig(portalConfig);
83                        support.setSupportName("normal");
84                        support.setSupportType(Constants.WINDOW_STATE_SUPPORT);
85                        supports.add(support);
86 
87                        support = new PortalSupport();
88                        support.setPortalConfig(portalConfig);
89                        support.setSupportName("maximized");
90                        support.setSupportType(Constants.WINDOW_STATE_SUPPORT);
91                        supports.add(support);
92 
93                        support = new PortalSupport();
94                        support.setPortalConfig(portalConfig);
95                        support.setSupportName("minimized");
96                        support.setSupportType(Constants.WINDOW_STATE_SUPPORT);
97                        supports.add(support);
98 
99                        List portletApplications = new ArrayList();
100                        PortletApplication application = new PortletApplication();
101                        application.setContextPath("/my-dev");
102 
103                        List portletConfigs = new ArrayList();
104                        PortletConfig config = new PortletConfig();
105                        config.setPortletApplication(application);
106                        config.setPortletName("AdminPortlet");
107                        portletConfigs.add(config);
108 
109                        config = new PortletConfig();
110                        config.setPortletApplication(application);
111                        config.setPortletName("PublishingPortlet");
112                        portletConfigs.add(config);
113 
114                        config = new PortletConfig();
115                        config.setPortletApplication(application);
116                        config.setPortletName("GroupsPortlet");
117                        portletConfigs.add(config);
118 
119                        config = new PortletConfig();
120                        config.setPortletApplication(application);
121                        config.setPortletName("ExamplePortlet");
122                        portletConfigs.add(config);
123 
124                        application.setPortletConfigs(portletConfigs);
125                        portletApplications.add(application);
126 
127                        application = new PortletApplication();
128                        application.setContextPath("/onestartportlets");
129 
130                        portletConfigs = new ArrayList();
131                        config = new PortletConfig();
132                        config.setPortletApplication(application);
133                        config.setPortletName("IframePortlet");
134                        portletConfigs.add(config);
135 
136                        config = new PortletConfig();
137                        config.setPortletApplication(application);
138                        config.setPortletName("RSSPortlet");
139                        portletConfigs.add(config);
140 
141                        application.setPortletConfigs(portletConfigs);
142                        portletApplications.add(application);
143 
144                        application = new PortletApplication();
145                        application.setContextPath("/ccf-dev");
146 
147                        portletConfigs = new ArrayList();
148                        config = new PortletConfig();
149                        config.setPortletApplication(application);
150                        config.setPortletName("ClassifiedsPortlet");
151                        portletConfigs.add(config);
152 
153                        application.setPortletConfigs(portletConfigs);
154                        portletApplications.add(application);
155 
156                        application = new PortletApplication();
157                        application.setContextPath("/SpringPortlets");
158 
159                        portletConfigs = new ArrayList();
160                        config = new PortletConfig();
161                        config.setPortletApplication(application);
162                        config.setPortletName("books");
163                        portletConfigs.add(config);
164 
165                        portletConfigs = new ArrayList();
166                        config = new PortletConfig();
167                        config.setPortletApplication(application);
168                        config.setPortletName("exceptions");
169                        portletConfigs.add(config);
170 
171                        portletConfigs = new ArrayList();
172                        config = new PortletConfig();
173                        config.setPortletApplication(application);
174                        config.setPortletName("mode");
175                        portletConfigs.add(config);
176 
177                        portletConfigs = new ArrayList();
178                        config = new PortletConfig();
179                        config.setPortletApplication(application);
180                        config.setPortletName("redirect");
181                        portletConfigs.add(config);
182 
183                        portletConfigs = new ArrayList();
184                        config = new PortletConfig();
185                        config.setPortletApplication(application);
186                        config.setPortletName("upload");
187                        portletConfigs.add(config);
188 
189                        portletConfigs = new ArrayList();
190                        config = new PortletConfig();
191                        config.setPortletApplication(application);
192                        config.setPortletName("helloworld");
193                        portletConfigs.add(config);
194 
195                        application.setPortletConfigs(portletConfigs);
196                        portletApplications.add(application);
197 
198                        getAdminService().savePortalConfig(portalConfig);
199                }
200                this.portalConfig = portalConfig;
201        }
202 
203        private User getUser() {
204                String userName = "jdoe";
205                String firstName = "John";
206                String lastName = "Doe";
207                String emailAddress = "jdoe@university.edu";
208                String campusCode = "BL";
209                List groups = new ArrayList();
210                groups.add("group1");
211                groups.add("group2");
212                groups.add("group3");
213 
214                OneStartUser oneStartUser = getUserService().findOneStartUserByUserName(userName);
215                return new User(oneStartUser, lastName, firstName, emailAddress, campusCode, groups);
216        }
217 
218        public void testPortalConfigValidatorValidate() {
219                try {
220                        PortalConfig portalConfig = new PortalConfig();
221                        Errors errors = new BindException(portalConfig, "portalConfig");
222                        getPortalConfigValidator().validate(portalConfig, errors);
223                        assertTrue("There should be errors from the validation. Required fields portal name, portal version, and container name.", errors.hasErrors());
224 
225                } catch (Exception e) {
226                        assertTrue("An error occured.  " + e.toString(), false);
227                }
228        }
229 
230        public void testPortalConfigOnSubmitAction() {
231                try {
232                        portalConfig.setPortalName("change");
233                        getPortalConfigController().onSubmitAction(portalConfig);
234                        assertEquals("Portal config should have been updated.", "change", getAdminService().getPortalConfig().getPortalName());
235                } catch (Exception e) {
236                        assertTrue("An error occured.  " + e.toString(), false);
237                }
238        }
239 
240        public void testPortalConfigOnSubmitRender() {
241                try {
242                        ModelAndView modelAndView = getPortalConfigController().onSubmitRender(portalConfig);
243 
244                        assertNotNull("ModelAndView does not contain content.", modelAndView.getModel());
245                        assertTrue("ModelAndView does not contain a confirmation message.", modelAndView.getModel().containsKey("message"));
246                } catch (Exception e) {
247                        assertTrue("An error occured.  " + e.toString(), false);
248                }
249        }
250 
251        public void testPortalConfigFormBackingObject() {
252                MockPortletRequest portletRequest = new MockPortletRequest();
253 
254                try {
255                        Object object = getPortalConfigController().formBackingObject(portletRequest);
256                        assertTrue("Command object should be of type PortalConfig.", object instanceof PortalConfig);
257 
258                        PortalConfig portalConfig = (PortalConfig) object;
259                        assertNotNull("PortalConfig should be present.", portalConfig);
260                } catch (Exception e) {
261                        assertTrue("An error occured.  " + e.toString(), false);
262                }
263        }
264 
265        public void testPortalConfigViewHandleRenderRequestInternal() {
266                MockRenderRequest renderRequest = new MockRenderRequest();
267                MockRenderResponse renderResponse = new MockRenderResponse();
268                try {
269                        ModelAndView modelAndView = getPortalConfigViewController().handleRenderRequestInternal(renderRequest, renderResponse);
270 
271                        assertNotNull("ModelAndView does not contain content.", modelAndView.getModel());
272                        if (modelAndView.getModel() != null) {
273                                assertTrue("ModelAndView does not contain a portal config.", modelAndView.getModel().containsKey("portalConfig"));
274                        }
275                } catch (Exception e) {
276                        assertTrue("An error occured.  " + e.toString(), false);
277                }
278        }
279 
280        public OneStartUser getOneStartUser() {
281                return oneStartUser;
282        }
283 
284        public UserService getUserService() {
285                return userService;
286        }
287 
288        public void setUserService(UserService userService) {
289                this.userService = userService;
290        }
291 
292        public AdminService getAdminService() {
293                return adminService;
294        }
295 
296        public void setAdminService(AdminService adminService) {
297                this.adminService = adminService;
298        }
299 
300        public PortalConfigController getPortalConfigController() {
301                return portalConfigController;
302        }
303 
304        public void setPortalConfigController(PortalConfigController portalConfigController) {
305                this.portalConfigController = portalConfigController;
306        }
307 
308        public PortalConfigValidator getPortalConfigValidator() {
309                return portalConfigValidator;
310        }
311 
312        public void setPortalConfigValidator(PortalConfigValidator portalConfigValidator) {
313                this.portalConfigValidator = portalConfigValidator;
314        }
315 
316        public PortalConfigViewController getPortalConfigViewController() {
317                return portalConfigViewController;
318        }
319 
320        public void setPortalConfigViewController(PortalConfigViewController portalConfigViewController) {
321                this.portalConfigViewController = portalConfigViewController;
322        }
323 
324}

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