use of com.squareup.sqlbrite3.TestDb.Employee in project sqlbrite by square.
the class BriteDatabaseTest method transactionCreatedFromTransactionNotificationWorks.
@Test
public void transactionCreatedFromTransactionNotificationWorks() {
// Tests the case where a transaction is created in the subscriber to a query which gets
// notified as the result of another transaction being committed. With improper ordering, this
// can result in creating a new transaction before the old is committed on the underlying DB.
db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES).subscribe(new Consumer<Query>() {
@Override
public void accept(Query query) {
db.newTransaction().end();
}
});
Transaction transaction = db.newTransaction();
try {
db.insert(TABLE_EMPLOYEE, CONFLICT_NONE, employee("john", "John Johnson"));
transaction.markSuccessful();
} finally {
transaction.end();
}
}
use of com.squareup.sqlbrite3.TestDb.Employee in project sqlbrite by square.
the class BriteDatabaseTest method synchronousQueryDuringTransactionSeesChanges.
@Test
public void synchronousQueryDuringTransactionSeesChanges() {
Transaction transaction = db.newTransaction();
try {
assertCursor(db.query(SELECT_EMPLOYEES)).hasRow("alice", "Alice Allison").hasRow("bob", "Bob Bobberson").hasRow("eve", "Eve Evenson").isExhausted();
db.insert(TABLE_EMPLOYEE, CONFLICT_NONE, employee("john", "John Johnson"));
db.insert(TABLE_EMPLOYEE, CONFLICT_NONE, employee("nick", "Nick Nickers"));
assertCursor(db.query(SELECT_EMPLOYEES)).hasRow("alice", "Alice Allison").hasRow("bob", "Bob Bobberson").hasRow("eve", "Eve Evenson").hasRow("john", "John Johnson").hasRow("nick", "Nick Nickers").isExhausted();
transaction.markSuccessful();
} finally {
transaction.end();
}
}
Aggregations