@Test
  public void testFind3rdPartyPayRecordsByBill() throws Exception {

    BillingONCHeader1Dao daoBONCH =
        (BillingONCHeader1Dao) SpringUtils.getBean(BillingONCHeader1Dao.class);
    BillingONCHeader1 bONCHeader1 = new BillingONCHeader1();
    EntityDataGenerator.generateTestDataForModelClass(bONCHeader1);

    int billingNo = 1;

    BillingONPayment bONPayment1 = new BillingONPayment();
    EntityDataGenerator.generateTestDataForModelClass(bONPayment1);
    Date date1 = new Date(dfm.parse("20110101").getTime());
    bONPayment1.setBillingNo(billingNo);
    bONPayment1.setPaymentDate(date1);

    BillingONPayment bONPayment2 = new BillingONPayment();
    EntityDataGenerator.generateTestDataForModelClass(bONPayment2);
    Date date2 = new Date(dfm.parse("20110701").getTime());
    bONPayment2.setBillingNo(billingNo);
    bONPayment2.setPaymentDate(date2);

    BillingONPayment bONPayment3 = new BillingONPayment();
    EntityDataGenerator.generateTestDataForModelClass(bONPayment3);
    Date date3 = new Date(dfm.parse("20110301").getTime());
    bONPayment3.setBillingNo(billingNo);
    bONPayment3.setPaymentDate(date3);

    daoBONCH.persist(bONCHeader1);
    dao.persist(bONPayment1);
    dao.persist(bONPayment2);
    dao.persist(bONPayment3);

    List<BillingONPayment> result = dao.find3rdPartyPayRecordsByBill(bONCHeader1);
    List<BillingONPayment> expectedResult =
        new ArrayList<BillingONPayment>(
            Arrays.asList(
                bONPayment1,
                bONPayment3,
                bONPayment2)); /// add the three payment obj in the expected order and assert =
    // expected result

    Logger logger = MiscUtils.getLogger();

    if (result.size() != expectedResult.size()) {
      logger.warn("Array sizes do not match.");
      fail("Array sizes do not match.");
    }

    for (int i = 0; i < expectedResult.size(); i++) {
      if (!expectedResult.get(i).equals(result.get(i))) {
        logger.warn("Items not sorted by Billing Payment Date.");
        fail("Items not sorted by Billing Payment Date.");
      }
    }
    assertTrue(true);
  }
  @Test
  public void testFind3rdPartyPayRecordsByBillBillingONCHeader1DateDate() throws Exception {

    BillingONCHeader1Dao daoBONCH =
        (BillingONCHeader1Dao) SpringUtils.getBean(BillingONCHeader1Dao.class);

    BillingONCHeader1 bONCHeader1 = new BillingONCHeader1();
    EntityDataGenerator.generateTestDataForModelClass(bONCHeader1);
    Date startDate = new Date(dfm.parse("20101230").getTime());
    Date endDate = new Date(dfm.parse("20120101").getTime());

    BillingONPayment bONPayment1 = new BillingONPayment();
    EntityDataGenerator.generateTestDataForModelClass(bONPayment1);
    Date Date1 = new Date(dfm.parse("20110102").getTime());
    bONPayment1.setBillingNo(1);
    bONPayment1.setPaymentDate(Date1);

    BillingONPayment bONPayment2 = new BillingONPayment();
    EntityDataGenerator.generateTestDataForModelClass(bONPayment2);
    Date Date2 = new Date(dfm.parse("20110302").getTime());
    bONPayment2.setBillingNo(1);
    bONPayment2.setPaymentDate(Date2);

    BillingONPayment bONPayment3 = new BillingONPayment();
    EntityDataGenerator.generateTestDataForModelClass(bONPayment3);
    Date Date3 = new Date(dfm.parse("20110502").getTime());
    bONPayment3.setBillingNo(1);
    bONPayment3.setPaymentDate(Date3);

    /// out of bound dates
    BillingONPayment bONPayment4 = new BillingONPayment();
    EntityDataGenerator.generateTestDataForModelClass(bONPayment4);
    Date Date4 = new Date(dfm.parse("20090502").getTime());
    bONPayment4.setBillingNo(1);
    bONPayment4.setPaymentDate(Date4);

    BillingONPayment bONPayment5 = new BillingONPayment();
    EntityDataGenerator.generateTestDataForModelClass(bONPayment5);
    Date Date5 = new Date(dfm.parse("20130502").getTime());
    bONPayment5.setBillingNo(1);
    bONPayment5.setPaymentDate(Date5);

    daoBONCH.persist(bONCHeader1);
    dao.persist(bONPayment1);
    dao.persist(bONPayment2);
    dao.persist(bONPayment3);

    List<BillingONPayment> result =
        dao.find3rdPartyPayRecordsByBill(bONCHeader1, startDate, endDate);
    List<BillingONPayment> expectedResult =
        new ArrayList<BillingONPayment>(Arrays.asList(bONPayment1, bONPayment2, bONPayment3));

    Logger logger = MiscUtils.getLogger();

    if (result.size() != expectedResult.size()) {
      logger.warn("Array sizes do not match.");
      fail("Array sizes do not match.");
    }
    for (int i = 0; i < expectedResult.size(); i++) {
      if (!expectedResult.get(i).equals(result.get(i))) {
        logger.warn("Items not sorted by Billing Payment Date.");
        fail("Items not sorted by Billing Payment Date.");
      }
    }
    assertTrue(true);
  }