Search in sources :

Example 76 with Calendar

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());
}
Also used : GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) GregorianCalendar(java.util.GregorianCalendar) GroupCustActionForm(org.mifos.customers.group.struts.actionforms.GroupCustActionForm) Test(org.junit.Test)

Example 77 with Calendar

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());
}
Also used : Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) Date(java.sql.Date)

Example 78 with Calendar

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;
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar)

Example 79 with Calendar

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;
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar)

Example 80 with Calendar

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));
}
Also used : Calendar(java.util.Calendar) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Aggregations

Calendar (java.util.Calendar)9446 Date (java.util.Date)2436 GregorianCalendar (java.util.GregorianCalendar)2130 Test (org.junit.Test)1735 SimpleDateFormat (java.text.SimpleDateFormat)889 ArrayList (java.util.ArrayList)476 ParseException (java.text.ParseException)353 HashMap (java.util.HashMap)270 TimeZone (java.util.TimeZone)270 IOException (java.io.IOException)235 DateFormat (java.text.DateFormat)224 Timestamp (java.sql.Timestamp)194 List (java.util.List)187 File (java.io.File)167 Map (java.util.Map)149 BigDecimal (java.math.BigDecimal)134 Locale (java.util.Locale)134 Test (org.testng.annotations.Test)118 Identity (org.olat.core.id.Identity)112 Date (java.sql.Date)110