Search in sources :

Example 16 with PageExpiredException

use of org.mifos.framework.exceptions.PageExpiredException in project head by mifos.

the class AccountApplyPaymentActionTest method loadShouldSetLastPaymentDateOnForm.

@Test
public void loadShouldSetLastPaymentDateOnForm() throws Exception {
    when(accountServiceFacade.getAccountPaymentInformation(Matchers.<Integer>any(), Matchers.<String>any(), Matchers.<Short>any(), Matchers.<UserReferenceDto>any(), Matchers.<Date>any())).thenReturn(new AccountPaymentDto(null, 0, null, null, null, new Date(1234), null, null));
    when(form.getAccountId()).thenReturn("1");
    accountApplyPaymentAction = new AccountApplyPaymentAction(accountServiceFacade, legacyAcceptedPaymentTypeDao) {

        @Override
        protected UserContext getUserContext(HttpServletRequest request) {
            return userContext;
        }

        @Override
        void setValuesInSession(HttpServletRequest request, AccountApplyPaymentActionForm actionForm, AccountPaymentDto accountPaymentDto) throws PageExpiredException {
        }
    };
    accountApplyPaymentAction.load(actionMapping, form, request, response);
    verify(form).setLastPaymentDate(new Date(1234));
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) UserContext(org.mifos.security.util.UserContext) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) AccountPaymentDto(org.mifos.accounts.servicefacade.AccountPaymentDto) Date(java.util.Date) AccountApplyPaymentActionForm(org.mifos.accounts.struts.actionforms.AccountApplyPaymentActionForm) Test(org.junit.Test)

Example 17 with PageExpiredException

use of org.mifos.framework.exceptions.PageExpiredException in project head by mifos.

the class LoanPrdActionFormTest method shouldNotAllowPeriodicFeeForVariableInstallmentLoanProduct.

@Test
public void shouldNotAllowPeriodicFeeForVariableInstallmentLoanProduct() {
    String PERIODIC_FEE_2 = "2";
    String NON_PERIODIC_FEE = "3";
    when(periodicFeeRate.isPeriodic()).thenReturn(true);
    when(periodicFeeRate.getFeeType()).thenReturn(RateAmountFlag.RATE);
    when(periodicFeeRate.getFeeId()).thenReturn(Short.valueOf(PERIODIC_FEE_2));
    when(periodicFeeRate.getFeeName()).thenReturn("periodic fee2");
    when(nonPeriodicFeeRate.isPeriodic()).thenReturn(false);
    when(nonPeriodicFeeRate.getFeeType()).thenReturn(RateAmountFlag.RATE);
    when(nonPeriodicFeeRate.getFeeId()).thenReturn(Short.valueOf(NON_PERIODIC_FEE));
    when(nonPeriodicFeeRate.getFeeName()).thenReturn("non Periodic fee");
    when(((RateFeeBO) nonPeriodicFeeRate).getFeeFormula()).thenReturn(feeFormulaEntity);
    when(feeFormulaEntity.getFeeFormula()).thenReturn(FeeFormula.INTEREST);
    List<FeeBO> allPrdFees = new ArrayList<FeeBO>();
    allPrdFees.add(periodicFeeRate);
    allPrdFees.add(nonPeriodicFeeRate);
    when(request.getAttribute(Constants.CURRENTFLOWKEY)).thenReturn(FLOW_KEY);
    when(request.getSession()).thenReturn(session);
    when(session.getAttribute(Constants.FLOWMANAGER)).thenReturn(flowManager);
    when(session.getAttribute(ProductDefinitionConstants.LOANPRDFEE)).thenReturn(allPrdFees);
    Flow flow = new Flow();
    try {
        when(flowManager.getFromFlow(Mockito.anyString(), Mockito.anyString())).thenReturn(allPrdFees);
        when(flowManager.getFlowWithValidation(FLOW_KEY)).thenReturn(flow);
    } catch (PageExpiredException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    ActionMessageMatcher actionMessageMatcher = new ActionMessageMatcher(ProductDefinitionConstants.PERIODIC_FEE_NOT_APPLICABLE);
    loanPrdActionForm.setCanConfigureVariableInstallments(true);
    loanPrdActionForm.setPrdOfferinFees(new String[] { PERIODIC_FEE_2, NON_PERIODIC_FEE });
    loanPrdActionForm.validateSelectedFeeForVariableInstallment(request, errors);
    Mockito.verify(errors, Mockito.times(1)).add(Mockito.anyString(), Mockito.argThat(actionMessageMatcher));
}
Also used : RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) ArrayList(java.util.ArrayList) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) FeeBO(org.mifos.accounts.fees.business.FeeBO) RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) Flow(org.mifos.framework.util.helpers.Flow) Test(org.junit.Test)

Example 18 with PageExpiredException

use of org.mifos.framework.exceptions.PageExpiredException in project head by mifos.

the class LoanPrdActionFormTest method shouldAllowPeriodicFeeForNonVariableInstallmentLoanProduct.

@Test
public void shouldAllowPeriodicFeeForNonVariableInstallmentLoanProduct() {
    String PERIODIC_FEE_2 = "2";
    String NON_PERIODIC_FEE = "3";
    final FeeDto feeDto = Mockito.mock(FeeDto.class);
    loanPrdActionForm = new LoanPrdActionForm() {

        @Override
        FeeDto getFeeDto(@SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") FeeBO fee) {
            return feeDto;
        }
    };
    FeeFrequencyEntity feeFrequencyEntity = Mockito.mock(FeeFrequencyEntity.class);
    MeetingBO meetingBo = Mockito.mock(MeetingBO.class);
    MeetingDetailsEntity meetingDetailsEntity = Mockito.mock(MeetingDetailsEntity.class);
    when(periodicFeeRate.isPeriodic()).thenReturn(true);
    when(periodicFeeRate.getFeeType()).thenReturn(RateAmountFlag.RATE);
    when(periodicFeeRate.getFeeId()).thenReturn(Short.valueOf(PERIODIC_FEE_2));
    when(periodicFeeRate.getFeeName()).thenReturn("periodic fee2");
    when((periodicFeeRate).getFeeFormula()).thenReturn(feeFormulaEntity);
    when(feeFormulaEntity.getFeeFormula()).thenReturn(FeeFormula.INTEREST);
    when(periodicFeeRate.getFeeFrequency()).thenReturn(feeFrequencyEntity);
    when(nonPeriodicFeeRate.isPeriodic()).thenReturn(false);
    when(nonPeriodicFeeRate.getFeeType()).thenReturn(RateAmountFlag.RATE);
    when(nonPeriodicFeeRate.getFeeId()).thenReturn(Short.valueOf(NON_PERIODIC_FEE));
    when(nonPeriodicFeeRate.getFeeName()).thenReturn("non Periodic fee");
    when(((RateFeeBO) nonPeriodicFeeRate).getFeeFormula()).thenReturn(feeFormulaEntity);
    when(feeFormulaEntity.getFeeFormula()).thenReturn(FeeFormula.INTEREST);
    List<FeeBO> allPrdFees = new ArrayList<FeeBO>();
    allPrdFees.add(periodicFeeRate);
    allPrdFees.add(nonPeriodicFeeRate);
    when(request.getAttribute(Constants.CURRENTFLOWKEY)).thenReturn(FLOW_KEY);
    when(request.getSession()).thenReturn(session);
    when(session.getAttribute(Constants.FLOWMANAGER)).thenReturn(flowManager);
    when(session.getAttribute(ProductDefinitionConstants.LOANPRDFEE)).thenReturn(allPrdFees);
    Flow flow = new Flow();
    try {
        when(flowManager.getFromFlow(Mockito.anyString(), Mockito.anyString())).thenReturn(allPrdFees);
        when(flowManager.getFlowWithValidation(FLOW_KEY)).thenReturn(flow);
    } catch (PageExpiredException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    loanPrdActionForm.setCanConfigureVariableInstallments(false);
    loanPrdActionForm.setPrdOfferinFees(new String[] { PERIODIC_FEE_2, NON_PERIODIC_FEE });
    loanPrdActionForm.validateSelectedFeeForVariableInstallment(request, errors);
    Mockito.verifyZeroInteractions(errors);
}
Also used : RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) MeetingBO(org.mifos.application.meeting.business.MeetingBO) FeeDto(org.mifos.accounts.fees.business.FeeDto) ArrayList(java.util.ArrayList) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) Flow(org.mifos.framework.util.helpers.Flow) HttpServletRequest(javax.servlet.http.HttpServletRequest) MeetingDetailsEntity(org.mifos.application.meeting.business.MeetingDetailsEntity) FeeBO(org.mifos.accounts.fees.business.FeeBO) RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) FeeFrequencyEntity(org.mifos.accounts.fees.business.FeeFrequencyEntity) Test(org.junit.Test)

Example 19 with PageExpiredException

use of org.mifos.framework.exceptions.PageExpiredException in project head by mifos.

the class ActivityTag method doEndTag.

@SuppressWarnings("unchecked")
@Override
public int doEndTag() throws JspException {
    RoleTempleteBuilder builder = new RoleTempleteBuilder();
    List<ActivityEntity> activities;
    try {
        activities = (List<ActivityEntity>) SessionUtils.getAttribute(RolesAndPermissionConstants.ACTIVITYLIST, (HttpServletRequest) pageContext.getRequest());
        activities = filterActivities(activities);
        RoleBO role = (RoleBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, (HttpServletRequest) pageContext.getRequest());
        RolesPermissionsActionForm rolesPermissionsActionForm = (RolesPermissionsActionForm) pageContext.getSession().getAttribute("rolesPermissionsActionForm");
        if (rolesPermissionsActionForm != null && rolesPermissionsActionForm.getActivities().size() > 0) {
            List<ActivityEntity> flitered = filterActivities(getActivities(activities, rolesPermissionsActionForm.getActivities()));
            Set<Short> activitySet = convertToIdSet(flitered);
            builder.setCurrentActivites(activitySet);
        } else if (role != null) {
            List<ActivityEntity> flitered = filterActivities(new ArrayList<ActivityEntity>(role.getActivities()));
            Set<Short> activitySet = convertToIdSet(flitered);
            builder.setCurrentActivites(activitySet);
        }
        Map<Short, ActivityRestrictionDto> activityRestrictionDtoMap = rolesPermissionsActionForm.getActivityRestrictionDtoMap();
        if (activityRestrictionDtoMap == null) {
            activityRestrictionDtoMap = new HashMap<Short, ActivityRestrictionDto>();
        }
        builder.setActivityRestrictionDtoMap(activityRestrictionDtoMap);
        SessionUtils.getAttribute(Constants.BUSINESS_KEY, (HttpServletRequest) pageContext.getRequest());
        StringBuilder sb = builder.getRolesTemplete(activities);
        pageContext.getOut().print(sb.toString());
    } catch (IOException e) {
        throw new JspException(e);
    } catch (PageExpiredException e1) {
        throw new JspException(e1);
    }
    return EVAL_PAGE;
}
Also used : ActivityEntity(org.mifos.security.rolesandpermission.business.ActivityEntity) Set(java.util.Set) HashSet(java.util.HashSet) RolesPermissionsActionForm(org.mifos.security.rolesandpermission.struts.actionforms.RolesPermissionsActionForm) ArrayList(java.util.ArrayList) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) IOException(java.io.IOException) HttpServletRequest(javax.servlet.http.HttpServletRequest) RoleTempleteBuilder(org.mifos.security.rolesandpermission.util.helpers.RoleTempleteBuilder) JspException(javax.servlet.jsp.JspException) ArrayList(java.util.ArrayList) List(java.util.List) ActivityRestrictionDto(org.mifos.dto.domain.ActivityRestrictionDto) RoleBO(org.mifos.security.rolesandpermission.business.RoleBO)

Example 20 with PageExpiredException

use of org.mifos.framework.exceptions.PageExpiredException in project head by mifos.

the class HeaderTag method doStartTag.

@Override
public int doStartTag() throws JspException {
    AbstractBusinessObject obj = null;
    Object randomNum = pageContext.getSession().getAttribute(Constants.RANDOMNUM);
    try {
        obj = (AbstractBusinessObject) SessionUtils.getAttribute(Constants.BUSINESS_KEY, (HttpServletRequest) pageContext.getRequest());
    } catch (PageExpiredException pex) {
        obj = (AbstractBusinessObject) pageContext.getSession().getAttribute(Constants.BUSINESS_KEY);
    }
    try {
        String linkStr;
        if (selfLink != null && selfLink != "") {
            linkStr = TagGenerator.createHeaderLinks(obj, Boolean.getBoolean(selfLink), randomNum);
        } else {
            linkStr = TagGenerator.createHeaderLinks(obj, true, randomNum);
        }
        pageContext.getOut().write(linkStr);
    } catch (PageExpiredException e) {
        new JspException(e);
    } catch (IOException e) {
        new JspException(e);
    }
    return SKIP_BODY;
}
Also used : JspException(javax.servlet.jsp.JspException) AbstractBusinessObject(org.mifos.framework.business.AbstractBusinessObject) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) AbstractBusinessObject(org.mifos.framework.business.AbstractBusinessObject) IOException(java.io.IOException)

Aggregations

PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)23 ArrayList (java.util.ArrayList)9 List (java.util.List)9 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 ActionMessage (org.apache.struts.action.ActionMessage)6 IOException (java.io.IOException)5 JspException (javax.servlet.jsp.JspException)5 ActionErrors (org.apache.struts.action.ActionErrors)4 Test (org.junit.Test)4 FeeBO (org.mifos.accounts.fees.business.FeeBO)4 RateFeeBO (org.mifos.accounts.fees.business.RateFeeBO)4 FeeDto (org.mifos.accounts.fees.business.FeeDto)3 Date (java.sql.Date)2 Date (java.util.Date)2 JspWriter (javax.servlet.jsp.JspWriter)2 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)2 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)2 HibernateSearchException (org.mifos.framework.exceptions.HibernateSearchException)2 TableTagParseException (org.mifos.framework.exceptions.TableTagParseException)2 Flow (org.mifos.framework.util.helpers.Flow)2