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); } }
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); } }
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 @Before public void setUp() throws Exception { StaticHibernateUtil.startTransaction(); }