use of org.mifos.builders.MifosUserBuilder in project head by mifos.
the class MifosMockStrutsTestCase method beforeStrutsTest.
@Before
public void beforeStrutsTest() throws Exception {
mockStruts.setUp();
if (!strutsConfigSet) {
setStrutsConfig();
strutsConfigSet = true;
}
getActionServlet().getServletContext().setAttribute(ShutdownManager.class.getName(), new ShutdownManager());
SecurityContext securityContext = new SecurityContextImpl();
MifosUser principal = new MifosUserBuilder().build();
Authentication authentication = new TestingAuthenticationToken(principal, principal);
securityContext.setAuthentication(authentication);
SecurityContextHolder.setContext(securityContext);
}
use of org.mifos.builders.MifosUserBuilder in project head by mifos.
the class PersonnelNoteActionStrutsTest method testSuccessCreatePersonnelNote.
@Test
public void testSuccessCreatePersonnelNote() throws Exception {
SecurityContext securityContext = new SecurityContextImpl();
MifosUser principal = new MifosUserBuilder().nonLoanOfficer().withAdminRole().build();
Authentication authentication = new TestingAuthenticationToken(principal, principal);
securityContext.setAuthentication(authentication);
SecurityContextHolder.setContext(securityContext);
createPersonnelAndSetInSession(getBranchOffice(), PersonnelLevel.LOAN_OFFICER);
setRequestPathInfo("/personnelNoteAction.do");
addRequestParameter("method", Methods.create.toString());
addRequestParameter("personnelId", personnel.getPersonnelId().toString());
addRequestParameter("comment", "Test");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
actionPerform();
verifyForward(ActionForwards.create_success.toString());
verifyNoActionErrors();
verifyNoActionMessages();
}
use of org.mifos.builders.MifosUserBuilder in project head by mifos.
the class CustHistoricalDataActionStrutsTest method testUpdateHistoricalDataWhenCustHistoricalDataIsNotNull.
@Test
public void testUpdateHistoricalDataWhenCustHistoricalDataIsNotNull() throws Exception {
SecurityContext securityContext = new SecurityContextImpl();
MifosUser principal = new MifosUserBuilder().nonLoanOfficer().withAdminRole().build();
Authentication authentication = new TestingAuthenticationToken(principal, principal);
securityContext.setAuthentication(authentication);
SecurityContextHolder.setContext(securityContext);
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
createInitialObjects();
CustomerHistoricalDataEntity customerHistoricalDataEntity = new CustomerHistoricalDataEntity(group);
group.updateHistoricalData(customerHistoricalDataEntity);
group.update();
StaticHibernateUtil.flushSession();
SessionUtils.setAttribute(Constants.BUSINESS_KEY, group, request);
setRequestPathInfo("/custHistoricalDataAction.do");
addRequestParameter("method", "updateHistoricalData");
addRequestParameter("productName", "Test");
addRequestParameter("loanAmount", "200");
addRequestParameter("totalAmountPaid", "150");
addRequestParameter("interestPaid", "50");
addRequestParameter("missedPaymentsCount", "2");
addRequestParameter("totalPaymentsCount", "3");
addRequestParameter("commentNotes", "Test notes");
addRequestParameter("loanCycleNumber", "2");
addRequestParameter("type", "Group");
addRequestParameter("mfiJoiningDate", DateUtils.getCurrentDate(((UserContext) request.getSession().getAttribute("UserContext")).getPreferredLocale()));
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
actionPerform();
verifyForward(ActionForwards.updateHistoricalData_success.toString());
verifyNoActionErrors();
verifyNoActionMessages();
group = TestObjectFactory.getGroup(group.getCustomerId());
Assert.assertEquals("Test", group.getHistoricalData().getProductName());
Assert.assertEquals("Test notes", group.getHistoricalData().getNotes());
Assert.assertEquals(new Money(getCurrency(), "200"), group.getHistoricalData().getLoanAmount());
Assert.assertEquals(new Money(getCurrency(), "150"), group.getHistoricalData().getTotalAmountPaid());
Assert.assertEquals(new Money(getCurrency(), "50"), group.getHistoricalData().getInterestPaid());
Assert.assertEquals(2, group.getHistoricalData().getMissedPaymentsCount().intValue());
Assert.assertEquals(3, group.getHistoricalData().getTotalPaymentsCount().intValue());
Assert.assertEquals(2, group.getHistoricalData().getLoanCycleNumber().intValue());
}
use of org.mifos.builders.MifosUserBuilder in project head by mifos.
the class LoanArrearsAgingHelperIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
StaticHibernateUtil.getSessionTL().clear();
oldRoundingMode = (String) MifosConfigurationManager.getInstance().getProperty(AccountingRulesConstants.CURRENCY_ROUNDING_MODE);
//FIXME this test was using CELLING ROUNDING MODE due to MIFOS-2659
MifosConfigurationManager.getInstance().setProperty(AccountingRulesConstants.CURRENCY_ROUNDING_MODE, RoundingMode.CEILING.toString());
/*
* Takes lateness days out of the equation so that the LoanArrearsTask will set all overdue account into bad
* standing.
*
* Resetting the database in tear down puts the original value back for other tests
*/
setLatenessDaysToZero();
LoanArrearsTask arrearsTask = new LoanArrearsTask();
loanArrearHelper = (LoanArrearsHelper) arrearsTask.getTaskHelper();
LoanArrearsAgingTask loanArrearsAgingTask = new LoanArrearsAgingTask();
loanArrearsAgingHelper = (LoanArrearsAgingHelper) loanArrearsAgingTask.getTaskHelper();
dateTime = initializeToFixedDateTime();
SecurityContext securityContext = new SecurityContextImpl();
MifosUser principal = new MifosUserBuilder().nonLoanOfficer().withAdminRole().build();
Authentication authentication = new TestingAuthenticationToken(principal, principal);
securityContext.setAuthentication(authentication);
SecurityContextHolder.setContext(securityContext);
}
use of org.mifos.builders.MifosUserBuilder in project head by mifos.
the class SavingsApplyAdjustmentActionStrutsTest method setUp.
@Before
public void setUp() throws Exception {
userContext = TestObjectFactory.getContext();
userContext.setPreferredLocale(new Locale("en", "GB"));
addRequestParameter("recordLoanOfficerId", "1");
addRequestParameter("recordOfficeId", "1");
request.getSession().setAttribute(Constants.USER_CONTEXT_KEY, userContext);
request.getSession(false).setAttribute("ActivityContext", TestObjectFactory.getActivityContext());
flowKey = createFlow(request, SavingsApplyAdjustmentAction.class);
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
SecurityContext securityContext = new SecurityContextImpl();
MifosUser principal = new MifosUserBuilder().build();
Authentication authentication = new TestingAuthenticationToken(principal, principal);
securityContext.setAuthentication(authentication);
SecurityContextHolder.setContext(securityContext);
}
Aggregations