Exemplo n.º 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());
  }
Exemplo n.º 2
0
 private void reloadMembers() {
   if (fund != null) {
     fund = (FundBO) StaticHibernateUtil.getSessionTL().get(FundBO.class, fund.getFundId());
   }
   if (fundBO != null) {
     fundBO = (FundBO) StaticHibernateUtil.getSessionTL().get(FundBO.class, fundBO.getFundId());
   }
 }
Exemplo n.º 3
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());
  }
 public List<ActivityEntity> getActivities() throws PersistenceException {
   try {
     return getActivities(StaticHibernateUtil.getSessionTL());
   } catch (Exception e) {
     throw new PersistenceException(e);
   }
 }
Exemplo n.º 5
0
  /** @see #addGeneralLedgerAccount(String, String, String, GLCategoryType) */
  private COABO addGeneralLedgerAccount(
      String name, String glcode, Short parent_id, GLCategoryType categoryType) {
    Short id = getAccountIdFromGlCode(glcode);
    if (id != null) {
      throw new RuntimeException(
          "An account already exists with glcode: " + glcode + ". id was " + id);
    }

    GLCodeEntity glCodeEntity = new GLCodeEntity(null, glcode);
    try {
      createOrUpdate(glCodeEntity);
      COABO newAccount = new COABO(name, glCodeEntity);
      newAccount.setCategoryType(categoryType);
      createOrUpdate(newAccount);

      COABO parentCOA;
      COAHierarchyEntity coaHierarchyEntity = null;
      if (null == parent_id) {
        coaHierarchyEntity = new COAHierarchyEntity(newAccount, null);
      } else {
        parentCOA = (COABO) StaticHibernateUtil.getSessionTL().load(COABO.class, parent_id);
        coaHierarchyEntity = new COAHierarchyEntity(newAccount, parentCOA.getCoaHierarchy());
      }

      createOrUpdate(coaHierarchyEntity);
      newAccount.setCoaHierarchy(coaHierarchyEntity);

      return newAccount;
    } catch (PersistenceException e) {
      throw new RuntimeException(e);
    }
  }
Exemplo n.º 6
0
  public void save(List<AccountBO> customerAccounts) {

    Session session = StaticHibernateUtil.getSessionTL();
    for (AccountBO account : customerAccounts) {
      session.save(account);
    }
  }
 private void createCustomers() {
   createParentCustomer();
   group =
       TestObjectFactory.createWeeklyFeeGroupUnderCenter(
           "group", CustomerStatus.GROUP_ACTIVE, center);
   client = TestObjectFactory.createClient("Client", CustomerStatus.CLIENT_ACTIVE, group);
   StaticHibernateUtil.flushSession();
 }
Exemplo n.º 8
0
 @Override
 protected void tearDown() throws Exception {
   reloadMembers();
   TestObjectFactory.removeObject(fund);
   TestObjectFactory.removeObject(fundBO);
   StaticHibernateUtil.closeSession();
   super.tearDown();
 }
Exemplo n.º 9
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));
 }
 @After
 public void tearDown() throws Exception {
   savings = null;
   group = null;
   center = null;
   TestObjectFactory.removeObject(savingsOffering2);
   StaticHibernateUtil.flushSession();
 }
 @After
 public void tearDown() throws Exception {
   branchOffice = null;
   savings = null;
   group = null;
   center = null;
   personnel = null;
   StaticHibernateUtil.flushSession();
 }
 @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 testUpdate() throws Exception {
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);

    for (int listIndex = 0; listIndex < configurationNameSet.length; ++listIndex) {
      String originalValue = "";
      StaticHibernateUtil.getSessionTL();

      for (int operationIndex = 0; operationIndex < operations.length; ++operationIndex) {
        createFlowAndAddToRequest(LookupOptionsAction.class);

        setRequestPathInfo("/lookupOptionsAction.do");
        addRequestParameter("method", "update");

        LookupOptionData data = new LookupOptionData();
        originalValue =
            prepareForUpdate(
                configurationNameSet[listIndex][MASTER_CONSTANT],
                configurationNameSet[listIndex][CONFIG_CONSTANT],
                configurationNameSet[listIndex][LIST_NAME],
                operations[operationIndex],
                data,
                names[operationIndex]);

        SessionUtils.setAttribute(ConfigurationConstants.LOOKUP_OPTION_DATA, data, request);
        addRequestParameter(
            ConfigurationConstants.ENTITY, configurationNameSet[listIndex][CONFIG_CONSTANT]);

        actionPerform();
        verifyNoActionErrors();
        verifyNoActionMessages();
        verifyForward(ActionForwards.update_success.toString());
      }
      StaticHibernateUtil.flushAndClearSession();

      StaticHibernateUtil.startTransaction();

      verifyOneListAndRestoreOriginalValues(
          configurationNameSet[listIndex][MASTER_CONSTANT],
          configurationNameSet[listIndex][CONFIG_CONSTANT],
          configurationNameSet[listIndex][LIST_NAME],
          originalValue);
    }
  }
Exemplo n.º 14
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());
  }
 @SuppressWarnings("unchecked")
 private <T extends MasterDataEntity> List<T> doFetchListOfMasterDataFor(Class<T> type) {
   Session session = StaticHibernateUtil.getSessionTL();
   List<T> masterEntities = session.createQuery("from " + type.getName()).list();
   for (MasterDataEntity masterData : masterEntities) {
     Hibernate.initialize(masterData.getNames());
     Hibernate.initialize(masterData.getLookUpValue());
     Hibernate.initialize(masterData.getLookUpValue().getLookUpValueLocales());
   }
   return masterEntities;
 }
 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);
   }
 }
Exemplo n.º 17
0
 /*
  * Execute a named query during initialization that does not include logging or other dependencies. This is a
  * workaround for issues related to interdependencies between initialization routines in {@link
  * ApplicationInitializer}
  */
 private List executeNamedQueryAtInit(String queryName, Map queryParameters)
     throws PersistenceException {
   Session session = null;
   try {
     session = StaticHibernateUtil.getSessionTL();
     Query query = session.getNamedQuery(queryName);
     query.setProperties(queryParameters);
     return query.list();
   } catch (Exception e) {
     throw new PersistenceException(e);
   }
 }
Exemplo n.º 18
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();
  }
Exemplo n.º 21
0
 public QueryResult getAllAccountNotes(Integer accountId) throws PersistenceException {
   QueryResult notesResult = null;
   try {
     Session session = null;
     notesResult = QueryFactory.getQueryResult("NotesSearch");
     session = StaticHibernateUtil.getSessionTL();
     Query query = session.getNamedQuery(NamedQueryConstants.GETALLACCOUNTNOTES);
     query.setInteger("accountId", accountId);
     notesResult.executeQuery(query);
   } catch (Exception e) {
     throw new PersistenceException(e);
   }
   return notesResult;
 }
Exemplo n.º 22
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();
 }
Exemplo n.º 23
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);
   }
 }
  @SuppressWarnings("unchecked")
  @Override
  public List<LookUpEntity> findLookupValueTypes() {

    Session session = StaticHibernateUtil.getSessionTL();

    List<LookUpEntity> entities = session.getNamedQuery(NamedQueryConstants.GET_ENTITIES).list();

    for (LookUpEntity entity : entities) {
      Set<LookUpLabelEntity> labels = entity.getLookUpLabels();
      entity.getEntityType();
      for (LookUpLabelEntity label : labels) {
        label.getLabelText();
        label.getLocaleId();
      }
    }

    return entities;
  }
Exemplo n.º 25
0
  @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();
  }
Exemplo n.º 26
0
 public void updatePayment(AccountPaymentEntity payment) {
   StaticHibernateUtil.getSessionTL().update(payment);
 }
Exemplo n.º 27
0
 public void save(AccountOverpaymentEntity overpaymentEntity) {
   StaticHibernateUtil.getSessionTL().save(overpaymentEntity);
 }
 @Override
 protected void tearDown() throws Exception {
   StaticHibernateUtil.closeSession();
   super.tearDown();
 }
Exemplo n.º 29
0
 private FundBO createFund(String fundName) throws Exception {
   FundCodeEntity fundCodeEntity =
       (FundCodeEntity) StaticHibernateUtil.getSessionTL().get(FundCodeEntity.class, (short) 1);
   return TestObjectFactory.createFund(fundCodeEntity, fundName);
 }
 @Override
 @Before
 public void setUp() throws Exception {
   StaticHibernateUtil.startTransaction();
 }