DalQueryHandler { public void handleInsert(DalQuery<Integer> query) { try { Integer result = query.doQuery(); if(result == null || result == 0) { throw new DalInsertException("No rows insert"); } } catch (Exception e) { throw new DalInsertException("Insert 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 = DalInsertException.class) public void handleInsert() throws Exception { handler.handleBatchInsert(new DalQuery<int[]>() { @Override public int[] doQuery() throws DalException { return new int[0]; } }); }
@Test public void handleInsertPositive() throws Exception { handler.handleInsert(new DalQuery<Integer>() { @Override public Integer doQuery() throws DalException { return 1; } }); }