@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);
  }
示例#2
0
  public void testSuccessfulCreateOneTimeFee() throws Exception {
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "load");
    actionPerform();
    flowKey = request.getAttribute(Constants.CURRENTFLOWKEY).toString();
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "preview");
    addRequestParameter("categoryType", FeeCategory.ALLCUSTOMERS.getValue().toString());
    addRequestParameter("currencyId", TestUtils.RUPEE.getCurrencyId().toString());
    addRequestParameter("amount", "100");
    addRequestParameter("feeName", "Customer_One_time");
    addRequestParameter("feeFrequencyType", FeeFrequencyType.ONETIME.getValue().toString());
    addRequestParameter("customerCharge", FeePayment.UPFRONT.getValue().toString());
    addRequestParameter("glCode", GLOCDE_ID);
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "create");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyForward(ActionForwards.create_success.toString());

    FeeActionForm actionForm = (FeeActionForm) request.getSession().getAttribute("feeactionform");
    fee = (FeeBO) TestObjectFactory.getObject(FeeBO.class, actionForm.getFeeIdValue());
    Assert.assertEquals("Customer_One_time", fee.getFeeName());
    Assert.assertEquals(FeeCategory.ALLCUSTOMERS.getValue(), fee.getCategoryType().getId());
    Assert.assertEquals(RateAmountFlag.AMOUNT, fee.getFeeType());
    Assert.assertEquals(new Money(getCurrency(), "100.0"), ((AmountFeeBO) fee).getFeeAmount());
    Assert.assertTrue(fee.isOneTime());
    Assert.assertFalse(fee.isCustomerDefaultFee());
    Assert.assertTrue(fee.isActive());
  }
  @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));
  }
示例#4
0
  public void testSuccessfulCreatePeriodicFeeWithFormula() throws Exception {
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "load");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    flowKey = request.getAttribute(Constants.CURRENTFLOWKEY).toString();
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "preview");
    addRequestParameter("categoryType", FeeCategory.LOAN.getValue().toString());
    addRequestParameter("currencyId", TestUtils.RUPEE.getCurrencyId().toString());
    addRequestParameter("rate", "23");
    addRequestParameter("amount", "");
    addRequestParameter("feeFormula", FeeFormula.AMOUNT.getValue().toString());
    addRequestParameter("feeName", "Loan_Periodic_Fee");
    addRequestParameter("customerDefaultFee", "0");
    addRequestParameter("feeFrequencyType", FeeFrequencyType.PERIODIC.getValue().toString());
    addRequestParameter("feeRecurrenceType", RecurrenceType.WEEKLY.getValue().toString());
    addRequestParameter("weekRecurAfter", "2");
    addRequestParameter("glCode", GLOCDE_ID);
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();

    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "create");
    addRequestParameter(
        "org.apache.struts.taglib.html.TOKEN",
        (String) request.getSession().getAttribute("org.apache.struts.action.TOKEN"));
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyForward(ActionForwards.create_success.toString());

    FeeActionForm actionForm = (FeeActionForm) request.getSession().getAttribute("feeactionform");
    fee = (FeeBO) TestObjectFactory.getObject(FeeBO.class, actionForm.getFeeIdValue());

    Assert.assertEquals("Loan_Periodic_Fee", fee.getFeeName());
    Assert.assertEquals(FeeCategory.LOAN.getValue(), fee.getCategoryType().getId());
    Assert.assertEquals(RateAmountFlag.RATE, fee.getFeeType());
    Assert.assertEquals(23.0, ((RateFeeBO) fee).getRate(), DELTA);
    Assert.assertEquals(
        ((RateFeeBO) fee).getFeeFormula().getId(), FeeFormula.AMOUNT.getValue(), DELTA);
    Assert.assertTrue(fee.isPeriodic());
    Assert.assertTrue(fee.isActive());
  }