DalQueryHandler { public void handleDelete(DalQuery<Integer> query, boolean failAsSuccess) { try { Integer result = query.doQuery(); if(!failAsSuccess) { if (result == null || result == 0) { throw new DalException("No row deleted"); } } } catch (Exception e) { throw new DalUpdateException("Update failed." + e.getMessage(), e); } }  T handleQuery(DalQuery<T> query); void handleUpdate(DalQuery<Integer> query); void handleBatchUpdate(DalQuery<int[]> query); void handleDelete(DalQuery<Integer> query, boolean failAsSuccess); void handleBatchDelete(DalQuery<int[]> query, boolean failAsSuccess); void handleInsert(DalQuery<Integer> query); int[] handleBatchInsert(DalQuery<int[]> query);  }
@Test(expected = DalUpdateException.class) public void testHandleDeleteWithException() throws Exception { handler.handleDelete(new DalQuery<Integer>() { @Override public Integer doQuery() throws DalException { throw new DalException("Dal connect exception"); } }, true); }