public void testSuccessfulPreview() throws Exception {
    CollectionSheetEntryGridDto bulkEntry = getSuccessfulBulkEntry();
    Calendar meetinDateCalendar = new GregorianCalendar();
    int year = meetinDateCalendar.get(Calendar.YEAR);
    int month = meetinDateCalendar.get(Calendar.MONTH);
    int day = meetinDateCalendar.get(Calendar.DAY_OF_MONTH);
    meetinDateCalendar = new GregorianCalendar(year, month, day);

    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    SessionUtils.setAttribute(CollectionSheetEntryConstants.BULKENTRY, bulkEntry, request);
    setRequestPathInfo("/collectionsheetaction.do");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    addRequestParameter("method", "preview");
    addRequestParameter("attendanceSelected[0]", "1");
    addRequestParameter("enteredAmount[0][0]", "212.0");
    addRequestParameter("enteredAmount[1][1]", "212.0");
    addRequestParameter("enteredAmount[0][1]", "212.0");
    addRequestParameter("enteredAmount[1][0]", "212.0");
    addRequestParameter("withDrawalAmountEntered[2][2]", "100.0");
    addRequestParameter("depositAmountEntered[2][2]", "100.0");
    addRequestParameter("withDrawalAmountEntered[0][0]", "100.0");
    addRequestParameter("depositAmountEntered[0][0]", "100.0");
    addRequestDateParameter("transactionDate", day + "/" + (month + 1) + "/" + year);
    performNoErrors();
    verifyForward("preview_success");

    groupAccount = TestObjectFactory.getObject(LoanBO.class, groupAccount.getAccountId());
    clientAccount = TestObjectFactory.getObject(LoanBO.class, clientAccount.getAccountId());
    centerSavingsAccount =
        TestObjectFactory.getObject(SavingsBO.class, centerSavingsAccount.getAccountId());
    clientSavingsAccount =
        TestObjectFactory.getObject(SavingsBO.class, clientSavingsAccount.getAccountId());
    groupSavingsAccount =
        TestObjectFactory.getObject(SavingsBO.class, groupSavingsAccount.getAccountId());
    center = TestObjectFactory.getCustomer(center.getCustomerId());
    group = TestObjectFactory.getCustomer(group.getCustomerId());
    client = TestObjectFactory.getClient(client.getCustomerId());
  }
  public void testSuccessfulCreate() throws Exception {
    CollectionSheetEntryGridDto bulkEntry = getSuccessfulBulkEntry();
    Calendar meetingDateCalendar = new GregorianCalendar();
    int year = meetingDateCalendar.get(Calendar.YEAR);
    int month = meetingDateCalendar.get(Calendar.MONTH);
    int day = meetingDateCalendar.get(Calendar.DAY_OF_MONTH);
    meetingDateCalendar = new GregorianCalendar(year, month, day);

    Date meetingDate = new Date(meetingDateCalendar.getTimeInMillis());
    HashMap<Integer, ClientAttendanceDto> clientAttendance =
        new HashMap<Integer, ClientAttendanceDto>();
    clientAttendance.put(1, getClientAttendanceDto(1, meetingDate));
    clientAttendance.put(2, getClientAttendanceDto(2, meetingDate));
    clientAttendance.put(3, getClientAttendanceDto(3, meetingDate));

    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    addRequestParameter("attendanceSelected[0]", "2");

    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    SessionUtils.setAttribute(CollectionSheetEntryConstants.BULKENTRY, bulkEntry, request);
    setRequestPathInfo("/collectionsheetaction.do");
    addRequestParameter("method", "preview");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    addRequestDateParameter("transactionDate", day + "/" + (month + 1) + "/" + year);

    if (SUPPLY_ENTERED_AMOUNT_PARAMETERS) {
      addParametersForEnteredAmount();
      addParametersForDisbursalEnteredAmount();
    }

    performNoErrors();

    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    setRequestPathInfo("/collectionsheetaction.do");
    addRequestParameter("method", "create");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    addRequestParameter("attendanceSelected[0]", "2");
    addRequestDateParameter("transactionDate", day + "/" + (month + 1) + "/" + year);
    addRequestParameter("customerId", "1");

    performNoErrors();
    verifyForward("create_success");
    Assert.assertNotNull(request.getAttribute(CollectionSheetEntryConstants.CENTER));
    Assert.assertEquals(
        request.getAttribute(CollectionSheetEntryConstants.CENTER), center.getDisplayName());

    groupAccount = TestObjectFactory.getObject(LoanBO.class, groupAccount.getAccountId());
    clientAccount = TestObjectFactory.getObject(LoanBO.class, clientAccount.getAccountId());
    centerSavingsAccount =
        TestObjectFactory.getObject(SavingsBO.class, centerSavingsAccount.getAccountId());
    clientSavingsAccount =
        TestObjectFactory.getObject(SavingsBO.class, clientSavingsAccount.getAccountId());
    groupSavingsAccount =
        TestObjectFactory.getObject(SavingsBO.class, groupSavingsAccount.getAccountId());
    center = TestObjectFactory.getCustomer(center.getCustomerId());
    group = TestObjectFactory.getCustomer(group.getCustomerId());
    client = TestObjectFactory.getClient(client.getCustomerId());

    Assert.assertEquals(1, client.getClientAttendances().size());
    Assert.assertEquals(
        AttendanceType.ABSENT,
        client
            .getClientAttendanceForMeeting(new java.sql.Date(meetingDateCalendar.getTimeInMillis()))
            .getAttendanceAsEnum());
  }