public void testDeleteOnCobarSqlMapClientTemplateNormally() {
Long[] memberIds = new Long[] { 1L, 129L, 257L, 2L, 130L, 258L, 386L };
// 1. empty data bases
String sqlAction = "com.alibaba.cobar.client.entities.Offer.deleteByMemberId";
for (Long mid : memberIds) {
Offer offer = new Offer();
offer.setMemberId(mid);
int affectedRows = getSqlMapClientTemplate().delete(sqlAction, offer);
assertEquals(0, affectedRows);
}
// 2. insert data fixtures
batchInsertOffersAsFixtureForLaterUse(memberIds);
for (int i = 0; i < memberIds.length; i++) {
String confirmSQL = "select subject from offers where memberId=" + memberIds[i];
if (i < 3) {
verifyEntityExistenceOnSpecificDataSource(confirmSQL, jt1m);
verifyEntityNonExistenceOnSpecificDataSource(confirmSQL, jt1s);
verifyEntityNonExistenceOnSpecificDataSource(confirmSQL, jt2m);
verifyEntityNonExistenceOnSpecificDataSource(confirmSQL, jt2s);
} else {
verifyEntityNonExistenceOnSpecificDataSource(confirmSQL, jt1m);
verifyEntityNonExistenceOnSpecificDataSource(confirmSQL, jt1s);
verifyEntityExistenceOnSpecificDataSource(confirmSQL, jt2m);
verifyEntityNonExistenceOnSpecificDataSource(confirmSQL, jt2s);
}
}
// 3. perform deletion and assertion
for (Long mid : memberIds) {
Offer offer = new Offer();
offer.setMemberId(mid);
int affectedRows = getSqlMapClientTemplate().delete(sqlAction, offer);
assertEquals(1, affectedRows);
}
}