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

nameclass, %method, %block, %line, %
AllApplicationConstantControllersTest.java100% (1/1)92%  (22/24)73%  (388/529)79%  (106.9/135)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AllApplicationConstantControllersTest100% (1/1)92%  (22/24)73%  (388/529)79%  (106.9/135)
getOneStartUser (): OneStartUser 0%   (0/1)0%   (0/3)0%   (0/1)
getUser (): User 0%   (0/1)0%   (0/41)0%   (0/11)
testApplicationConstantDeleteOnSubmitAction (): void 100% (1/1)56%  (15/27)67%  (4/6)
testApplicationConstantDeleteOnSubmitRender (): void 100% (1/1)60%  (18/30)71%  (5/7)
testApplicationConstantOnSubmitRender (): void 100% (1/1)60%  (18/30)71%  (5/7)
testApplicationConstantOnSubmitAction (): void 100% (1/1)64%  (21/33)71%  (5/7)
testApplicationConstantDeleteFormBackingObject (): void 100% (1/1)80%  (48/60)86%  (12/14)
testApplicationConstantFormBackingObject (): void 100% (1/1)80%  (48/60)86%  (12/14)
testApplicationConstantViewHandleRenderRequestInternal (): void 100% (1/1)81%  (57/70)86%  (12.9/15)
testApplicationConstantValidatorValidate (): void 100% (1/1)84%  (63/75)89%  (16/18)
AllApplicationConstantControllersTest (): void 100% (1/1)100% (3/3)100% (1/1)
getAdminService (): AdminService 100% (1/1)100% (3/3)100% (1/1)
getApplicationConstantController (): ApplicationConstantController 100% (1/1)100% (3/3)100% (1/1)
getApplicationConstantDeleteController (): ApplicationConstantDeleteController 100% (1/1)100% (3/3)100% (1/1)
getApplicationConstantValidator (): ApplicationConstantValidator 100% (1/1)100% (3/3)100% (1/1)
getApplicationConstantViewController (): ApplicationConstantViewController 100% (1/1)100% (3/3)100% (1/1)
getUserService (): UserService 100% (1/1)100% (3/3)100% (1/1)
onSetUpInTransaction (): void 100% (1/1)100% (55/55)100% (16/16)
setAdminService (AdminService): void 100% (1/1)100% (4/4)100% (2/2)
setApplicationConstantController (ApplicationConstantController): void 100% (1/1)100% (4/4)100% (2/2)
setApplicationConstantDeleteController (ApplicationConstantDeleteController):... 100% (1/1)100% (4/4)100% (2/2)
setApplicationConstantValidator (ApplicationConstantValidator): void 100% (1/1)100% (4/4)100% (2/2)
setApplicationConstantViewController (ApplicationConstantViewController): 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.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.ApplicationConstant;
18import edu.iu.uis.sit.portal.portlet.admin.services.AdminService;
19import edu.iu.uis.sit.portal.user.User;
20import edu.iu.uis.sit.portal.user.domain.OneStartUser;
21import edu.iu.uis.sit.portal.user.service.UserService;
22 
23public class AllApplicationConstantControllersTest extends PersistenceBrokerAbstractTransactionalDataSourceSpringContextTests {
24 
25        private AdminService adminService;
26 
27        private UserService userService;
28 
29        private ApplicationConstantDeleteController applicationConstantDeleteController;
30        
31        private ApplicationConstantValidator applicationConstantValidator;
32 
33        private ApplicationConstantViewController applicationConstantViewController;
34 
35        private ApplicationConstantController applicationConstantController;
36 
37        private OneStartUser oneStartUser;
38 
39        private ApplicationConstant applicationConstant;
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                ApplicationConstant applicationConstant = new ApplicationConstant();
50                applicationConstant.setConstantName("Config.Application.My.Constant");
51                applicationConstant.setConstantValue("My Constant");
52 
53                getAdminService().saveApplicationConstant(applicationConstant);
54                this.applicationConstant = applicationConstant;
55 
56                ApplicationConstant applicationConstant2 = new ApplicationConstant();
57                applicationConstant2.setConstantName("Config.Application.My.Constant2");
58                applicationConstant2.setConstantValue("My Constant 2");
59                getAdminService().saveApplicationConstant(applicationConstant2);
60        }
61 
62        private User getUser() {
63                String userName = "jdoe";
64                String firstName = "John";
65                String lastName = "Doe";
66                String emailAddress = "jdoe@university.edu";
67                String campusCode = "BL";
68                List groups = new ArrayList();
69                groups.add("group1");
70                groups.add("group2");
71                groups.add("group3");
72 
73                OneStartUser oneStartUser = getUserService().findOneStartUserByUserName(userName);
74                return new User(oneStartUser, lastName, firstName, emailAddress, campusCode, groups);
75        }
76 
77        public void testApplicationConstantValidatorValidate() {
78                try {
79                        ApplicationConstant applicationConstant = new ApplicationConstant();
80                        Errors errors = new BindException(applicationConstant, "applicationConstant");
81                        getApplicationConstantValidator().validate(applicationConstant, errors);
82                        assertTrue("There should be errors from the validation. Required field application name.", errors.hasErrors());
83 
84                        applicationConstant.setConstantName("Config.Application.My.Constant");
85                        applicationConstant.setConstantValue("My Constant");
86                        errors = new BindException(applicationConstant, "applicationContstant");
87                        getApplicationConstantValidator().validate(applicationConstant, errors);
88                        assertTrue("There should be errors from the validation.  Duplicate application constant.", errors.hasErrors());
89 
90                        applicationConstant.setConstantName("Config.Application. test");
91                        applicationConstant.setConstantValue("My Constant");
92                        errors = new BindException(applicationConstant, "applicationContstant");
93                        getApplicationConstantValidator().validate(applicationConstant, errors);
94                        assertTrue("There should be errors from the validation.  Spaces in application name.", errors.hasErrors());
95                } catch (Exception e) {
96                        assertTrue("An error occured.  " + e.toString(), false);
97                }
98        }
99 
100        public void testApplicationConstantOnSubmitAction() {
101                try {
102                        applicationConstant.setConstantValue("change");
103                        getApplicationConstantController().onSubmitAction(applicationConstant);
104                        assertEquals("Application constant should have been updated.", "change", getAdminService().findApplicationConstantById(applicationConstant.getConstantId()).getConstantValue());
105                } catch (Exception e) {
106                        assertTrue("An error occured.  " + e.toString(), false);
107                }
108        }
109 
110        public void testApplicationConstantOnSubmitRender() {
111                try {
112                        ModelAndView modelAndView = getApplicationConstantController().onSubmitRender(applicationConstant);
113 
114                        assertNotNull("ModelAndView does not contain content.", modelAndView.getModel());
115                        assertTrue("ModelAndView does not contain a confirmation message.", modelAndView.getModel().containsKey("message"));
116                } catch (Exception e) {
117                        assertTrue("An error occured.  " + e.toString(), false);
118                }
119        }
120 
121        public void testApplicationConstantFormBackingObject() {
122                MockPortletRequest portletRequest = new MockPortletRequest();
123 
124                try {
125                        Object object = getApplicationConstantController().formBackingObject(portletRequest);
126                        assertTrue("Command object should be of type ApplicationConstant.", object instanceof ApplicationConstant);
127 
128                        ApplicationConstant applicationConstant = (ApplicationConstant) object;
129                        assertNull("Application constant should be a new empty object.", applicationConstant.getConstantId());
130 
131                        portletRequest.addParameter("constantId", this.applicationConstant.getConstantId().toString());
132 
133                        object = getApplicationConstantController().formBackingObject(portletRequest);
134                        assertTrue("Command object should be of type ApplicationConstant.", object instanceof ApplicationConstant);
135 
136                        ApplicationConstant found = (ApplicationConstant) object;
137                        assertEquals("Application constant id is incorrect.", this.applicationConstant.getConstantId(), found.getConstantId());
138 
139                } catch (Exception e) {
140                        assertTrue("An error occured.  " + e.toString(), false);
141                }
142        }
143 
144        public void testApplicationConstantDeleteOnSubmitRender() {
145                try {
146                        ModelAndView modelAndView = getApplicationConstantDeleteController().onSubmitRender(applicationConstant);
147 
148                        assertNotNull("ModelAndView does not contain content.", modelAndView.getModel());
149                        assertTrue("ModelAndView does not contain a confirmation message.", modelAndView.getModel().containsKey("message"));
150                } catch (Exception e) {
151                        assertTrue("An error occured.  " + e.toString(), false);
152                }
153        }
154 
155        public void testApplicationConstantDeleteOnSubmitAction() {
156                try {
157                        getApplicationConstantDeleteController().onSubmitAction(applicationConstant);
158                        assertNull("Application constant should have been deleted.", getAdminService().findApplicationConstantById(applicationConstant.getConstantId()));
159                } catch (Exception e) {
160                        assertTrue("An error occured.  " + e.toString(), false);
161                }
162        }
163 
164        public void testApplicationConstantDeleteFormBackingObject() {
165                MockPortletRequest portletRequest = new MockPortletRequest();
166 
167                try {
168                        Object object = getApplicationConstantDeleteController().formBackingObject(portletRequest);
169                        assertTrue("Command object should be of type ApplicationConstant.", object instanceof ApplicationConstant);
170 
171                        ApplicationConstant applicationConstant = (ApplicationConstant) object;
172                        assertNull("Application constant should be a new empty object.", applicationConstant.getConstantId());
173 
174                        portletRequest.addParameter("constantId", this.applicationConstant.getConstantId().toString());
175 
176                        object = getApplicationConstantDeleteController().formBackingObject(portletRequest);
177                        assertTrue("Command object should be of type ApplicationConstant.", object instanceof ApplicationConstant);
178 
179                        ApplicationConstant found = (ApplicationConstant) object;
180                        assertEquals("Application constant id is incorrect.", this.applicationConstant.getConstantId(), found.getConstantId());
181 
182                } catch (Exception e) {
183                        assertTrue("An error occured.  " + e.toString(), false);
184                }
185        }
186 
187        public void testApplicationConstantViewHandleRenderRequestInternal() {
188                MockRenderRequest renderRequest = new MockRenderRequest();
189                MockRenderResponse renderResponse = new MockRenderResponse();
190                try {
191                        ModelAndView modelAndView = getApplicationConstantViewController().handleRenderRequestInternal(renderRequest, renderResponse);
192 
193                        assertNotNull("ModelAndView does not contain content.", modelAndView.getModel());
194                        if (modelAndView.getModel() != null) {
195                                assertTrue("ModelAndView does not contain constants.", modelAndView.getModel().containsKey("constants"));
196 
197                                for (Iterator iter = modelAndView.getModel().entrySet().iterator(); iter.hasNext();) {
198                                        Map.Entry entry = (Map.Entry) iter.next();
199                                        if (entry.getKey().equals("constants")) {
200                                                assertTrue("There should be at least 2 application constants.", ((List) entry.getValue()).size() > 1);
201                                        }
202                                }
203                        }
204                } catch (Exception e) {
205                        assertTrue("An error occured.  " + e.toString(), false);
206                }
207        }
208 
209        public OneStartUser getOneStartUser() {
210                return oneStartUser;
211        }
212 
213        public UserService getUserService() {
214                return userService;
215        }
216 
217        public void setUserService(UserService userService) {
218                this.userService = userService;
219        }
220 
221        public ApplicationConstantDeleteController getApplicationConstantDeleteController() {
222                return applicationConstantDeleteController;
223        }
224 
225        public void setApplicationConstantDeleteController(ApplicationConstantDeleteController applicationConstantDeleteController) {
226                this.applicationConstantDeleteController = applicationConstantDeleteController;
227        }
228 
229        public ApplicationConstantViewController getApplicationConstantViewController() {
230                return applicationConstantViewController;
231        }
232 
233        public void setApplicationConstantViewController(ApplicationConstantViewController applicationConstantViewController) {
234                this.applicationConstantViewController = applicationConstantViewController;
235        }
236 
237        public AdminService getAdminService() {
238                return adminService;
239        }
240 
241        public void setAdminService(AdminService adminService) {
242                this.adminService = adminService;
243        }
244 
245        public ApplicationConstantController getApplicationConstantController() {
246                return applicationConstantController;
247        }
248 
249        public void setApplicationConstantController(ApplicationConstantController applicationConstantController) {
250                this.applicationConstantController = applicationConstantController;
251        }
252 
253        public ApplicationConstantValidator getApplicationConstantValidator() {
254                return applicationConstantValidator;
255        }
256 
257        public void setApplicationConstantValidator(ApplicationConstantValidator applicationConstantValidator) {
258                this.applicationConstantValidator = applicationConstantValidator;
259        }
260 
261}

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