SmsContentDAO extends BaseIbatisDAO { public void delete(final Map<String, Object> parameters) { if (LOG.isDebugEnabled()) { LOG.debug("Want to delete,condition: " + parameters); } super.delete("SMS_CONTENT.delete", parameters); }  SmsContent save(final SmsContent sms); @SuppressWarnings("unchecked") List<SmsContent> query(final Map<String, Object> parameters); void deleteByPrimaryKey(final Serializable id); void delete(final Map<String, Object> parameters); void updateFailureCount(final Serializable id); SmsContent getByPrimaryKey(final Serializable id); void retrySend(final Serializable serialId); static int getRule(); static void setRule(int rule); @SuppressWarnings("unchecked") List<SmsContent> queryByParam(Map<String, Object> param); void reSendSmsByMap(Map<Object, Object> extendParam); int update(SmsContent smsContent); void insert(SmsContent smsContent);  }
@Test public void testDelete() throws Exception { smsContentDAO.save(new SmsContent("Test Sms 1", "13917677725")); smsContentDAO.save(new SmsContent("Test Sms 2", "13917677725")); smsContentDAO.save(new SmsContent("Test Sms 3", "13917677725")); smsContentDAO.save(new SmsContent("Test Sms 4", "13917677725")); smsContentDAO.save(new SmsContent("Test Sms 5", "13917677725")); int rownum = 0; Statement stat = conn.createStatement(); ResultSet rs = stat.executeQuery("SELECT COUNT(id) FROM sms_content"); if (rs.next()) { rownum = rs.getInt(1); } Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("condition", "content = 'Test Sms 1'"); smsContentDAO.delete(parameters); stat = conn.createStatement(); rs = stat.executeQuery("SELECT COUNT(id) FROM sms_content"); if (rs.next()) { Assert.assertEquals(rownum - 1, rs.getInt(1)); rownum = rs.getInt(1); } parameters.clear(); parameters.put("condition", "content = 'Test Sms 1'"); parameters.put("failure", 2); smsContentDAO.delete(parameters); stat = conn.createStatement(); rs = stat.executeQuery("SELECT COUNT(id) FROM sms_content"); if (rs.next()) { Assert.assertEquals(rownum, rs.getInt(1)); } parameters.clear(); parameters.put("condition", "content like '%Test Sms%'"); smsContentDAO.delete(parameters); stat = conn.createStatement(); rs = stat.executeQuery("SELECT COUNT(id) FROM sms_content"); if (rs.next()) { Assert.assertEquals(rownum - 4, rs.getInt(1)); } }