private void verifyInsertedValues(
     RewardConfirmation confirmation, Dining dining, Map<String, Object> values) {
   assertEquals(
       confirmation.getAccountContribution().getAmount(),
       new MonetaryAmount((Double) values.get("REWARD_AMOUNT")));
   assertEquals(SimpleDate.today().asDate(), values.get("REWARD_DATE"));
   assertEquals(
       confirmation.getAccountContribution().getAccountNumber(), values.get("ACCOUNT_NUMBER"));
   assertEquals(dining.getAmount(), new MonetaryAmount((Double) values.get("DINING_AMOUNT")));
   assertEquals(dining.getMerchantNumber(), values.get("DINING_MERCHANT_NUMBER"));
   assertEquals(SimpleDate.today().asDate(), values.get("DINING_DATE"));
 }
 public RewardConfirmation confirmReward(AccountContribution contribution, Dining dining) {
   String sql =
       "insert into T_REWARD (CONFIRMATION_NUMBER, REWARD_AMOUNT, REWARD_DATE, ACCOUNT_NUMBER, DINING_MERCHANT_NUMBER, DINING_DATE, DINING_AMOUNT) values (?, ?, ?, ?, ?, ?, ?)";
   Connection conn = null;
   PreparedStatement ps = null;
   try {
     conn = dataSource.getConnection();
     ps = conn.prepareStatement(sql);
     String confirmationNumber = nextConfirmationNumber();
     ps.setString(1, confirmationNumber);
     ps.setBigDecimal(2, contribution.getAmount().asBigDecimal());
     ps.setDate(3, new Date(SimpleDate.today().inMilliseconds()));
     ps.setString(4, contribution.getAccountNumber());
     ps.setString(5, dining.getMerchantNumber());
     ps.setDate(6, new Date(dining.getDate().inMilliseconds()));
     ps.setBigDecimal(7, dining.getAmount().asBigDecimal());
     ps.execute();
     return new RewardConfirmation(confirmationNumber, contribution);
   } catch (SQLException e) {
     throw new RuntimeException("SQL exception occured inserting reward record", e);
   } finally {
     if (ps != null) {
       try {
         // Close to prevent database cursor exhaustion
         ps.close();
       } catch (SQLException ex) {
       }
     }
     if (conn != null) {
       try {
         // Close to prevent database connection exhaustion
         conn.close();
       } catch (SQLException ex) {
       }
     }
   }
 }