}
}
public void testUpdate() throws Exception {
final DataContext context = createDataContext();
final DbEntity entity = context.getEntityResolver().lookupObjEntity(
SoftTest.class).getDbEntity();
try {
context.getParentDataDomain().setQueryBuilderFactory(new SoftDeleteQueryBuilderFactory());
final SoftTest test = context.newObject(SoftTest.class);
test.setName("SoftDeleteBatchQueryBuilderTest");
context.commitChanges();
final SelectQuery query = new SelectQuery(SoftTest.class);
new ThreadedTestHelper() {
@Override
protected void assertResult() throws Exception {
query.setQualifier(ExpressionFactory.matchExp("name", test.getName()));
assertEquals(1, context.performQuery(query).size());
query.andQualifier(ExpressionFactory.matchDbExp("DELETED", true));
assertEquals(0, context.performQuery(query).size());
}
}.assertWithTimeout(200);
context.deleteObject(test);
assertEquals(test.getPersistenceState(), PersistenceState.DELETED);
context.commitChanges();
new ThreadedTestHelper() {
@Override
protected void assertResult() throws Exception {
query.setQualifier(ExpressionFactory.matchExp("name", test.getName()));
assertEquals(0, context.performQuery(query).size());
SQLTemplate template = new SQLTemplate(entity, "SELECT * FROM SOFT_TEST");
template.setFetchingDataRows(true);
assertEquals(1, context.performQuery(template).size());
}
}.assertWithTimeout(200);
}
finally {
context.performQuery(new SQLTemplate(entity, "DELETE FROM SOFT_TEST"));
context.getParentDataDomain().setQueryBuilderFactory(null);
}
}