Search in sources :

Example 6 with MeetingActionForm

use of org.mifos.application.meeting.struts.actionforms.MeetingActionForm in project head by mifos.

the class MeetingActionStrutsTest method testEditForCenter.

@Test
public void testEditForCenter() throws Exception {
    setMifosUserFromContext();
    MeetingBO meeting = createWeeklyMeeting(WeekDay.WEDNESDAY, Short.valueOf("5"), new Date());
    center = createCenter(meeting);
    setRequestPathInfo("/centerCustAction.do");
    addRequestParameter("method", "get");
    addRequestParameter("globalCustNum", center.getGlobalCustNum());
    actionPerform();
    setRequestPathInfo("/meetingAction.do");
    addRequestParameter("method", "edit");
    addRequestParameter("customerLevel", CustomerLevel.CENTER.getValue().toString());
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    actionPerform();
    verifyForward(ActionForwards.edit_success.toString());
    Assert.assertNotNull(SessionUtils.getAttribute(MeetingConstants.WEEKDAYSLIST, request));
    Assert.assertNotNull(SessionUtils.getAttribute(MeetingConstants.WEEKRANKLIST, request));
    verifyNoActionErrors();
    verifyNoActionMessages();
    MeetingActionForm actionForm = (MeetingActionForm) request.getSession().getAttribute("meetingActionForm");
    Assert.assertEquals(CustomerLevel.CENTER, actionForm.getCustomerLevelValue());
    center = TestObjectFactory.getCenter(center.getCustomerId());
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) MeetingActionForm(org.mifos.application.meeting.struts.actionforms.MeetingActionForm) Date(java.util.Date) Test(org.junit.Test)

Example 7 with MeetingActionForm

use of org.mifos.application.meeting.struts.actionforms.MeetingActionForm in project head by mifos.

the class MeetingActionStrutsTest method testLoadForCenter.

@Test
public void testLoadForCenter() throws Exception {
    setRequestPathInfo("/meetingAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("customerLevel", CustomerLevel.CENTER.getValue().toString());
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    addRequestParameter("input", "create");
    actionPerform();
    verifyForward(ActionForwards.load_success.toString());
    Assert.assertNotNull(SessionUtils.getAttribute(MeetingConstants.WEEKDAYSLIST, request));
    Assert.assertNotNull(SessionUtils.getAttribute(MeetingConstants.WEEKRANKLIST, request));
    verifyNoActionErrors();
    verifyNoActionMessages();
    MeetingActionForm actionForm = (MeetingActionForm) request.getSession().getAttribute("meetingActionForm");
    Assert.assertEquals(CustomerLevel.CENTER, actionForm.getCustomerLevelValue());
}
Also used : MeetingActionForm(org.mifos.application.meeting.struts.actionforms.MeetingActionForm) Test(org.junit.Test)

Example 8 with MeetingActionForm

use of org.mifos.application.meeting.struts.actionforms.MeetingActionForm in project head by mifos.

the class MeetingActionStrutsTest method testLoad_MonthlyOnDateMeetingExists.

@Test
public void testLoad_MonthlyOnDateMeetingExists() throws Exception {
    setRequestPathInfo("/centerCustAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("officeId", "3");
    actionPerform();
    Short recurAfter = Short.valueOf("2");
    Short dayNumber = Short.valueOf("5");
    MeetingBO meeting = createMonthlyMeetingOnDate(dayNumber, recurAfter, new Date());
    SessionUtils.setAttribute(CustomerConstants.CUSTOMER_MEETING, meeting, request);
    setRequestPathInfo("/meetingAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("customerLevel", CustomerLevel.CENTER.getValue().toString());
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    addRequestParameter("input", "create");
    actionPerform();
    verifyForward(ActionForwards.load_success.toString());
    Assert.assertNotNull(SessionUtils.getAttribute(MeetingConstants.WEEKDAYSLIST, request));
    Assert.assertNotNull(SessionUtils.getAttribute(MeetingConstants.WEEKRANKLIST, request));
    verifyNoActionErrors();
    verifyNoActionMessages();
    MeetingActionForm actionForm = (MeetingActionForm) request.getSession().getAttribute("meetingActionForm");
    Assert.assertEquals(CustomerLevel.CENTER, actionForm.getCustomerLevelValue());
    Assert.assertEquals("1", actionForm.getMonthType());
    Assert.assertEquals(dayNumber, actionForm.getMonthDayValue());
    Assert.assertEquals(recurAfter, actionForm.getDayRecurMonthValue());
    Assert.assertEquals(RecurrenceType.MONTHLY, actionForm.getRecurrenceType());
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) MeetingActionForm(org.mifos.application.meeting.struts.actionforms.MeetingActionForm) Date(java.util.Date) Test(org.junit.Test)

Example 9 with MeetingActionForm

use of org.mifos.application.meeting.struts.actionforms.MeetingActionForm in project head by mifos.

the class MeetingActionStrutsTest method testLoadForClient.

@Test
public void testLoadForClient() throws Exception {
    setRequestPathInfo("/meetingAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("customerLevel", CustomerLevel.CLIENT.getValue().toString());
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    addRequestParameter("input", "create");
    actionPerform();
    verifyForward(ActionForwards.load_success.toString());
    Assert.assertNotNull(SessionUtils.getAttribute(MeetingConstants.WEEKDAYSLIST, request));
    Assert.assertNotNull(SessionUtils.getAttribute(MeetingConstants.WEEKRANKLIST, request));
    verifyNoActionErrors();
    verifyNoActionMessages();
    MeetingActionForm actionForm = (MeetingActionForm) request.getSession().getAttribute("meetingActionForm");
    Assert.assertEquals(CustomerLevel.CLIENT, actionForm.getCustomerLevelValue());
}
Also used : MeetingActionForm(org.mifos.application.meeting.struts.actionforms.MeetingActionForm) Test(org.junit.Test)

Example 10 with MeetingActionForm

use of org.mifos.application.meeting.struts.actionforms.MeetingActionForm in project head by mifos.

the class MeetingAction method edit.

@TransactionDemarcate(conditionToken = true)
public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    MeetingActionForm actionForm = (MeetingActionForm) form;
    clearActionForm(actionForm);
    CustomerBO customerInSession = (CustomerBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    CustomerBO customer = this.customerDao.findCustomerById(customerInSession.getCustomerId());
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, customer, request);
    List<WeekDay> workingDays = getLocalizedWorkingDays();
    SessionUtils.setCollectionAttribute(MeetingConstants.WEEKDAYSLIST, workingDays, request);
    SessionUtils.setCollectionAttribute(MeetingConstants.WEEKRANKLIST, RankOfDay.getRankOfDayList(), request);
    ActionForward forward = null;
    if (customer.getCustomerMeeting() != null) {
        MeetingBO meeting = customer.getCustomerMeeting().getMeeting();
        setValuesInActionForm(actionForm, meeting);
        forward = mapping.findForward(ActionForwards.edit_success.toString());
        actionForm.setInput(MeetingConstants.INPUT_EDIT);
    } else {
        actionForm.setInput(MeetingConstants.INPUT_CREATE);
        forward = mapping.findForward(ActionForwards.createMeeting_success.toString());
    }
    return forward;
}
Also used : WeekDay(org.mifos.application.meeting.util.helpers.WeekDay) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomerBO(org.mifos.customers.business.CustomerBO) MeetingActionForm(org.mifos.application.meeting.struts.actionforms.MeetingActionForm) ActionForward(org.apache.struts.action.ActionForward) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

MeetingActionForm (org.mifos.application.meeting.struts.actionforms.MeetingActionForm)12 MeetingBO (org.mifos.application.meeting.business.MeetingBO)8 Test (org.junit.Test)7 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)5 Date (java.util.Date)4 WeekDay (org.mifos.application.meeting.util.helpers.WeekDay)2 CustomerBO (org.mifos.customers.business.CustomerBO)2 ActionForward (org.apache.struts.action.ActionForward)1 ActionForwards (org.mifos.application.util.helpers.ActionForwards)1 MeetingDto (org.mifos.dto.domain.MeetingDto)1 CloseSession (org.mifos.framework.util.helpers.CloseSession)1