Example #1
0
  public void testUpdate() throws Exception {
    fund = createFund("Fund-1");
    StaticHibernateUtil.closeSession();
    fund = (FundBO) TestObjectFactory.getObject(FundBO.class, fund.getFundId());
    setRequestPathInfo("/fundAction.do");
    addRequestParameter("method", Methods.manage.toString());
    addRequestParameter("fundCodeId", fund.getFundId().toString());
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();

    setRequestPathInfo("/fundAction.do");
    addRequestParameter("method", Methods.previewManage.toString());
    addRequestParameter("fundName", "Fund-2");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();

    setRequestPathInfo("/fundAction.do");
    addRequestParameter("method", Methods.update.toString());
    addRequestParameter("fundName", "Fund-2");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyForward(ActionForwards.update_success.toString());
    Assert.assertNull(
        ((FlowManager) request.getSession().getAttribute(Constants.FLOWMANAGER)).getFlow(flowKey));
    StaticHibernateUtil.closeSession();
    fund = (FundBO) TestObjectFactory.getObject(FundBO.class, fund.getFundId());
    Assert.assertNotNull(fund);
    Assert.assertEquals("Fund-2", fund.getFundName());
  }
Example #2
0
  public void testUpdateForDuplicateFundName() throws Exception {
    fund = createFund("Fund-1");
    fundBO = createFund("Fund-2");
    StaticHibernateUtil.closeSession();
    fund = (FundBO) TestObjectFactory.getObject(FundBO.class, fund.getFundId());
    setRequestPathInfo("/fundAction.do");
    addRequestParameter("method", Methods.manage.toString());
    addRequestParameter("fundCodeId", fund.getFundId().toString());
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();

    setRequestPathInfo("/fundAction.do");
    addRequestParameter("method", Methods.previewManage.toString());
    addRequestParameter("fundName", "Fund-1");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();

    setRequestPathInfo("/fundAction.do");
    addRequestParameter("method", Methods.update.toString());
    addRequestParameter("fundName", fundBO.getFundName());
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyActionErrors(new String[] {FundConstants.DUPLICATE_FUNDNAME_EXCEPTION});
    verifyForward(ActionForwards.update_failure.toString());
  }
Example #3
0
 public void save(AuditLog auditLog) {
   try {
     // explicit close session calls required to avoid infinite looping of audit logs
     // afterTransaction
     StaticHibernateUtil.closeSession();
     Session session = StaticHibernateUtil.getSessionTL();
     StaticHibernateUtil.startTransaction();
     session.save(auditLog);
     StaticHibernateUtil.commitTransaction();
     StaticHibernateUtil.closeSession();
   } catch (Exception e) {
     StaticHibernateUtil.rollbackTransaction();
     StaticHibernateUtil.closeSession();
     throw new RuntimeException(e);
   }
 }
Example #4
0
 @Override
 protected void tearDown() throws Exception {
   reloadMembers();
   TestObjectFactory.removeObject(fund);
   TestObjectFactory.removeObject(fundBO);
   StaticHibernateUtil.closeSession();
   super.tearDown();
 }
Example #5
0
 public void testManage() throws Exception {
   fund = createFund("Fund-1");
   StaticHibernateUtil.closeSession();
   fund = (FundBO) TestObjectFactory.getObject(FundBO.class, fund.getFundId());
   setRequestPathInfo("/fundAction.do");
   addRequestParameter("method", Methods.manage.toString());
   addRequestParameter("fundCodeId", fund.getFundId().toString());
   addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
   actionPerform();
   verifyNoActionErrors();
   verifyForward(ActionForwards.manage_success.toString());
   StaticHibernateUtil.closeSession();
   fund = (FundBO) TestObjectFactory.getObject(FundBO.class, fund.getFundId());
   Assert.assertNotNull(fund);
   Assert.assertEquals("Fund-1", fund.getFundName());
   Assert.assertEquals("Fund-1", SessionUtils.getAttribute(FundConstants.OLDFUNDNAME, request));
 }
 @Override
 protected void tearDown() throws Exception {
   TestObjectFactory.cleanUp(savings);
   TestObjectFactory.cleanUp(client1);
   TestObjectFactory.cleanUp(client2);
   TestObjectFactory.cleanUp(group);
   TestObjectFactory.cleanUp(center);
   StaticHibernateUtil.closeSession();
   super.tearDown();
 }
 public void testGetAllSavingsProductsFailure() throws Exception {
   SavingsOfferingBO savingsOffering = createSavingsOfferingBO();
   TestObjectFactory.simulateInvalidConnection();
   try {
     new SavingsPrdBusinessService().getAllSavingsProducts();
     Assert.assertTrue(false);
   } catch (ServiceException e) {
     Assert.assertTrue(true);
     StaticHibernateUtil.closeSession();
     TestObjectFactory.removeObject(savingsOffering);
   }
 }
Example #8
0
 public void testViewAllFunds() throws Exception {
   fund = createFund("Fund-1");
   StaticHibernateUtil.closeSession();
   fund = (FundBO) TestObjectFactory.getObject(FundBO.class, fund.getFundId());
   setRequestPathInfo("/fundAction.do");
   addRequestParameter("method", Methods.viewAllFunds.toString());
   actionPerform();
   verifyNoActionErrors();
   verifyForward(ActionForwards.viewAllFunds_success.toString());
   List<FundBO> fundList =
       (List<FundBO>) SessionUtils.getAttribute(FundConstants.FUNDLIST, request);
   Assert.assertEquals("The size of master data for funds should be 6", 6, fundList.size());
 }
 public void testGetApplicablePrdStatus() throws ServiceException {
   List<PrdStatusEntity> prdStatusList =
       new SavingsPrdBusinessService().getApplicablePrdStatus((short) 1);
   StaticHibernateUtil.closeSession();
   Assert.assertEquals(2, prdStatusList.size());
   for (PrdStatusEntity prdStatus : prdStatusList) {
     if (prdStatus.getPrdState().equals("1")) {
       Assert.assertEquals("Active", prdStatus.getPrdState().getName());
     }
     if (prdStatus.getPrdState().equals("2")) {
       Assert.assertEquals("InActive", prdStatus.getPrdState().getName());
     }
   }
 }
  @Override
  protected void tearDown() throws Exception {
    try {
      TestObjectFactory.cleanUp(accountBO);
      TestObjectFactory.cleanUp(group);
      TestObjectFactory.cleanUp(center);
    } catch (Exception e) {
      // TODO Whoops, cleanup didnt work, reset db
      TestDatabase.resetMySQLDatabase();
    }

    StaticHibernateUtil.closeSession();
    super.tearDown();
  }
Example #11
0
 @Override
 protected void tearDown() throws Exception {
   try {
     TestObjectFactory.cleanUp(fee);
     TestObjectFactory.cleanUp(fee1);
     TestObjectFactory.cleanUp(fee2);
     TestObjectFactory.cleanUp(fee3);
     StaticHibernateUtil.closeSession();
   } catch (Exception e) {
     // TODO Whoops, cleanup didnt work, reset db
     TestDatabase.resetMySQLDatabase();
   }
   super.tearDown();
 }
Example #12
0
  public void testSuccessfulViewAllFees() throws Exception {
    StaticHibernateUtil.startTransaction();
    fee =
        TestObjectFactory.createOneTimeRateFee(
            "Group_Fee", FeeCategory.GROUP, 10.0, FeeFormula.AMOUNT, FeePayment.UPFRONT);
    fee1 =
        TestObjectFactory.createOneTimeRateFee(
            "Customer_Fee", FeeCategory.ALLCUSTOMERS, 20.0, FeeFormula.AMOUNT, FeePayment.UPFRONT);
    fee2 =
        TestObjectFactory.createOneTimeRateFee(
            "Loan_Fee1", FeeCategory.LOAN, 30.0, FeeFormula.AMOUNT, FeePayment.UPFRONT);
    fee3 =
        TestObjectFactory.createOneTimeRateFee(
            "Center_Fee", FeeCategory.CENTER, 40.0, FeeFormula.AMOUNT, FeePayment.UPFRONT);
    StaticHibernateUtil.commitTransaction();
    StaticHibernateUtil.closeSession();
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "viewAll");

    actionPerform();
    verifyNoActionErrors();
    verifyForward(ActionForwards.viewAll_success.toString());
    flowKey = request.getAttribute(Constants.CURRENTFLOWKEY).toString();
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    List<FeeBO> customerFees =
        (List<FeeBO>) SessionUtils.getAttribute(FeeConstants.CUSTOMER_FEES, request);
    List<FeeBO> productFees =
        (List<FeeBO>) SessionUtils.getAttribute(FeeConstants.PRODUCT_FEES, request);
    Assert.assertEquals(3, customerFees.size());
    Assert.assertEquals(1, productFees.size());

    Assert.assertEquals("Center_Fee", customerFees.get(0).getFeeName());
    Assert.assertEquals("Customer_Fee", customerFees.get(1).getFeeName());
    Assert.assertEquals("Group_Fee", customerFees.get(2).getFeeName());

    Assert.assertEquals("Loan_Fee1", productFees.get(0).getFeeName());

    fee = (FeeBO) TestObjectFactory.getObject(FeeBO.class, fee.getFeeId());
    fee1 = (FeeBO) TestObjectFactory.getObject(FeeBO.class, fee1.getFeeId());
    fee2 = (FeeBO) TestObjectFactory.getObject(FeeBO.class, fee2.getFeeId());
    fee3 = (FeeBO) TestObjectFactory.getObject(FeeBO.class, fee3.getFeeId());
  }
  @Override
  protected void tearDown() throws Exception {
    try {
      TestObjectFactory.cleanUp(centerSavingsAccount);
      TestObjectFactory.cleanUp(groupSavingsAccount);
      TestObjectFactory.cleanUp(clientSavingsAccount);
      TestObjectFactory.cleanUp(groupAccount);
      TestObjectFactory.cleanUp(clientAccount);
      TestObjectFactory.cleanUp(account);
      TestObjectFactory.cleanUp(client);
      TestObjectFactory.cleanUp(group);
      TestObjectFactory.cleanUp(center);

    } catch (Exception e) {
      // Throwing here may mask earlier failures.
      e.printStackTrace();
    }
    StaticHibernateUtil.closeSession();
    super.tearDown();
  }
 @Override
 protected void tearDown() throws Exception {
   StaticHibernateUtil.closeSession();
   super.tearDown();
 }