Ejemplo n.º 1
0
  private void verifyAccountEmailAuditAndHistoryCount(
      final UUID accountId, final int expectedCount) {
    final Handle handle = dbi.open();

    // verify audit
    StringBuilder sb = new StringBuilder();
    sb.append("select * from audit_log a ");
    sb.append("inner join account_email_history aeh on a.record_id = aeh.history_record_id ");
    sb.append("where a.table_name = 'account_email_history' ");
    sb.append(String.format("and aeh.account_id='%s'", accountId.toString()));
    List<Map<String, Object>> result = handle.select(sb.toString());
    assertEquals(result.size(), expectedCount);

    // ***** NOT IDEAL
    // ... but this works after the email record has been deleted; will likely fail when multiple
    // emails exist for the same account
    // verify history table
    sb = new StringBuilder();
    sb.append("select * from account_email_history aeh ");
    sb.append(String.format("where aeh.account_id='%s'", accountId.toString()));
    result = handle.select(sb.toString());
    assertEquals(result.size(), expectedCount);

    handle.close();
  }
Ejemplo n.º 2
0
 @Override
 public Long withHandle(final Handle handle) throws Exception {
   return (Long)
           handle
               .select("select count(distinct record_id) count from bus_events")
               .get(0)
               .get("count")
       + (Long)
           handle
               .select(
                   "select count(distinct record_id) count from notifications where effective_date < ?",
                   clock.getUTCNow().toDate())
               .get(0)
               .get("count")
       + (Long)
           handle
               .select(
                   "select count(distinct record_id) count from notifications where processing_state = 'IN_PROCESSING'")
               .get(0)
               .get("count");
 }