use of java.util.Calendar in project head by mifos.
the class GroupActionStrutsTest method testPreviewManageSuccessForNameChange_AfterTrainedSet.
/**
* This test asserts that when a group name for a trained group is edited, there are no errors and the trained date
* is present in the action form.
*/
@Test
public void testPreviewManageSuccessForNameChange_AfterTrainedSet() throws Exception {
Calendar cal = new GregorianCalendar();
cal.set(Calendar.DAY_OF_MONTH, 2);
cal.set(Calendar.MONTH, 5);
cal.set(Calendar.YEAR, 2008);
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
createTrainedGroupAndSetInSession(cal.getTime());
setRequestPathInfo("/groupCustAction.do");
addRequestParameter("method", "manage");
addRequestParameter("officeId", "3");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
actionPerform();
List<CustomFieldDto> customFieldDefs = getCustomFieldsFromSession();
setRequestPathInfo("/groupCustAction.do");
addRequestParameter("method", "previewManage");
addRequestParameter("officeId", "3");
// editing group name
addRequestParameter("displayName", "group123");
int i = 0;
for (CustomFieldDto customFieldDef : customFieldDefs) {
addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
addRequestParameter("customField[" + i + "].fieldValue", "Req");
i++;
}
addRequestParameter("trained", "1");
addRequestParameter("trainedDate", "2/6/2008");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
actionPerform();
GroupCustActionForm actionForm = (GroupCustActionForm) getActionForm();
Assert.assertEquals("2/6/2008", actionForm.getTrainedDate());
Assert.assertEquals(0, getErrorSize());
}
use of java.util.Calendar in project head by mifos.
the class LoanArrearsTaskIntegrationTest method offSetGivenDate.
private java.sql.Date offSetGivenDate(Date date, int numberOfDays) {
Calendar dateCalendar = new GregorianCalendar();
dateCalendar.setTimeInMillis(date.getTime());
int year = dateCalendar.get(Calendar.YEAR);
int month = dateCalendar.get(Calendar.MONTH);
int day = dateCalendar.get(Calendar.DAY_OF_MONTH);
dateCalendar = new GregorianCalendar(year, month, day - numberOfDays);
return new java.sql.Date(dateCalendar.getTimeInMillis());
}
use of java.util.Calendar in project head by mifos.
the class PortfolioAtRiskCalculationIntegrationTest method changeFirstInstallmentDate.
private void changeFirstInstallmentDate(AccountBO accountBO, int numberOfDays) {
Calendar currentDateCalendar = new GregorianCalendar();
int year = currentDateCalendar.get(Calendar.YEAR);
int month = currentDateCalendar.get(Calendar.MONTH);
int day = currentDateCalendar.get(Calendar.DAY_OF_MONTH);
currentDateCalendar = new GregorianCalendar(year, month, day - numberOfDays);
for (AccountActionDateEntity accountActionDateEntity : accountBO.getAccountActionDates()) {
LoanBOTestUtils.setActionDate(accountActionDateEntity, new java.sql.Date(currentDateCalendar.getTimeInMillis()));
break;
}
}
use of java.util.Calendar in project head by mifos.
the class PortfolioAtRiskHelperIntegrationTest method changeFirstInstallmentDate.
private void changeFirstInstallmentDate(AccountBO accountBO, int numberOfDays) {
Calendar currentDateCalendar = new GregorianCalendar();
int year = currentDateCalendar.get(Calendar.YEAR);
int month = currentDateCalendar.get(Calendar.MONTH);
int day = currentDateCalendar.get(Calendar.DAY_OF_MONTH);
currentDateCalendar = new GregorianCalendar(year, month, day - numberOfDays);
for (AccountActionDateEntity accountActionDateEntity : accountBO.getAccountActionDates()) {
LoanBOTestUtils.setActionDate(accountActionDateEntity, new java.sql.Date(currentDateCalendar.getTimeInMillis()));
break;
}
}
use of java.util.Calendar in project head by mifos.
the class DateUtilsTest method testGetCalendar.
public void testGetCalendar() throws Exception {
Date today = new SimpleDateFormat("yyyy-MM-dd").parse("2008-03-26");
Calendar todaysCalendar = DateUtils.getCalendar(today);
Assert.assertEquals(2008, todaysCalendar.get(Calendar.YEAR));
Assert.assertEquals(Calendar.MARCH, todaysCalendar.get(Calendar.MONTH));
Assert.assertEquals(26, todaysCalendar.get(Calendar.DAY_OF_MONTH));
today = new SimpleDateFormat("yyyy-MM-dd").parse("2004-12-06");
todaysCalendar = DateUtils.getCalendar(today);
Assert.assertEquals(2004, todaysCalendar.get(Calendar.YEAR));
Assert.assertEquals(Calendar.DECEMBER, todaysCalendar.get(Calendar.MONTH));
Assert.assertEquals(6, todaysCalendar.get(Calendar.DAY_OF_MONTH));
}
Aggregations