@Test
public final void testProcessFormSubmission() {
try
{
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
BindException aError = new BindException(new RoleCommand(), RoleCommand.ACTION_EDIT);
this.testSetAgencyUserManager();
this.testSetAuthorityManager();
this.testSetMessageSource();
RoleCommand aCommand = new RoleCommand();
aCommand.setAction(RoleCommand.ACTION_NEW);
aCommand.setOid(new Long(3000));
ModelAndView mav = testInstance.processFormSubmission(request, response, aCommand, aError);
assertTrue(mav != null);
assertTrue(mav.getViewName().equals("AddRole"));
List<Agency> agencies = (List<Agency>)mav.getModel().get("agencies");
assertTrue(agencies != null);
assertTrue(agencies.size() > 0);
aCommand = new RoleCommand();
aCommand.setAction(RoleCommand.ACTION_VIEW);
aCommand.setOid(new Long(3000));
mav = testInstance.processFormSubmission(request, response, aCommand, aError);
assertTrue(mav != null);
assertTrue(mav.getViewName().equals("AddRole"));
agencies = (List<Agency>)mav.getModel().get("agencies");
assertTrue(agencies != null);
assertTrue(agencies.size() > 0);
RoleCommand newCommand = (RoleCommand)mav.getModel().get("command");
assertTrue(newCommand != null);
assertTrue(newCommand.getViewOnlyMode());
aCommand = new RoleCommand();
aCommand.setAction(RoleCommand.ACTION_EDIT);
aCommand.setOid(new Long(3000));
mav = testInstance.processFormSubmission(request, response, aCommand, aError);
assertTrue(mav != null);
assertTrue(mav.getViewName().equals("AddRole"));
agencies = (List<Agency>)mav.getModel().get("agencies");
assertTrue(agencies != null);
assertTrue(agencies.size() > 0);
newCommand = (RoleCommand)mav.getModel().get("command");
assertTrue(newCommand != null);
assertFalse(newCommand.getViewOnlyMode());
aCommand = new RoleCommand();
aCommand.setAction(RoleCommand.ACTION_SAVE);
aCommand.setRoleName("New Test Role");
aCommand.setAgency(AuthUtil.getRemoteUserObject().getAgency().getOid());
String[] scopedPrivileges = {};
aCommand.setScopedPrivileges(scopedPrivileges);
mav = testInstance.processFormSubmission(request, response, aCommand, aError);
assertTrue(mav != null);
assertTrue(mav.getViewName().equals("Roles"));
List<Role> roles = (List<Role>)mav.getModel().get("roles");
assertTrue(roles != null);
assertTrue(roles.size() > 0);
aCommand = new RoleCommand();
aCommand.setAction(RoleCommand.ACTION_FILTER);
String agencyFilter = "Dummy";
aCommand.setAgencyFilter(agencyFilter);
mav = testInstance.processFormSubmission(request, response, aCommand, aError);
assertTrue(mav != null);
assertTrue(mav.getViewName().equals("Roles"));
RoleCommand command = (RoleCommand)mav.getModel().get("command");
assertTrue(command != null);
assertTrue(agencyFilter.equals(command.getAgencyFilter()));
assertTrue(agencyFilter.equals((String)request.getSession().getAttribute(RoleCommand.PARAM_AGENCY_FILTER)));
}
catch (Exception e)
{
String message = e.getClass().toString() + " - " + e.getMessage();
log.debug(message);
fail(message);
}
}
RoleControllerTest.java 文件源码
java
阅读 15
收藏 0
点赞 0
评论 0
项目:webcurator
作者:
评论列表
文章目录