use of android.database.sqlite.SQLiteStatement in project sqlbrite by square.
the class BriteDatabaseTest method executeUpdateDeleteAndTriggerWithMultipleTables.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test
public void executeUpdateDeleteAndTriggerWithMultipleTables() {
SQLiteStatement statement = real.compileStatement("UPDATE " + TABLE_EMPLOYEE + " SET " + TestDb.EmployeeTable.NAME + " = 'Zach'");
final RecordingObserver managerObserver = new RecordingObserver();
db.createQuery(TABLE_MANAGER, SELECT_MANAGER_LIST).subscribe(managerObserver);
managerObserver.assertCursor().hasRow("Eve Evenson", "Alice Allison").isExhausted();
db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES).subscribe(o);
o.assertCursor().hasRow("alice", "Alice Allison").hasRow("bob", "Bob Bobberson").hasRow("eve", "Eve Evenson").isExhausted();
final Set<String> employeeAndManagerTables = Collections.unmodifiableSet(new HashSet<>(BOTH_TABLES));
db.executeUpdateDelete(employeeAndManagerTables, statement);
o.assertCursor().hasRow("alice", "Zach").hasRow("bob", "Zach").hasRow("eve", "Zach").isExhausted();
managerObserver.assertCursor().hasRow("Zach", "Zach").isExhausted();
}
use of android.database.sqlite.SQLiteStatement in project sqlbrite by square.
the class BriteDatabaseTest method executeInsertAndDontTrigger.
@Test
public void executeInsertAndDontTrigger() {
SQLiteStatement statement = real.compileStatement("INSERT OR IGNORE INTO " + TABLE_EMPLOYEE + " (" + TestDb.EmployeeTable.NAME + ", " + TestDb.EmployeeTable.USERNAME + ") " + "VALUES ('Alice Allison', 'alice')");
db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES).subscribe(o);
o.assertCursor().hasRow("alice", "Alice Allison").hasRow("bob", "Bob Bobberson").hasRow("eve", "Eve Evenson").isExhausted();
db.executeInsert(TABLE_EMPLOYEE, statement);
o.assertNoMoreEvents();
}
use of android.database.sqlite.SQLiteStatement in project sqlbrite by square.
the class BriteDatabaseTest method executeInsertThrowsAndDoesNotTrigger.
@Test
public void executeInsertThrowsAndDoesNotTrigger() {
SQLiteStatement statement = real.compileStatement("INSERT INTO " + TABLE_EMPLOYEE + " (" + TestDb.EmployeeTable.NAME + ", " + TestDb.EmployeeTable.USERNAME + ") " + "VALUES ('Alice Allison', 'alice')");
db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES).skip(// Skip initial
1).subscribe(o);
try {
db.executeInsert(TABLE_EMPLOYEE, statement);
fail();
} catch (SQLException ignored) {
}
o.assertNoMoreEvents();
}
use of android.database.sqlite.SQLiteStatement in project sqlbrite by square.
the class BriteDatabaseTest method executeUpdateDeleteThrowsAndDoesNotTrigger.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test
public void executeUpdateDeleteThrowsAndDoesNotTrigger() {
SQLiteStatement statement = real.compileStatement("UPDATE " + TABLE_EMPLOYEE + " SET " + TestDb.EmployeeTable.USERNAME + " = 'alice'");
db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES).skip(// Skip initial
1).subscribe(o);
try {
db.executeUpdateDelete(TABLE_EMPLOYEE, statement);
fail();
} catch (SQLException ignored) {
}
o.assertNoMoreEvents();
}
use of android.database.sqlite.SQLiteStatement in project sqlbrite by square.
the class BriteDatabaseTest method executeUpdateDeleteAndTriggerWithNoTables.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test
public void executeUpdateDeleteAndTriggerWithNoTables() {
SQLiteStatement statement = real.compileStatement("UPDATE " + TABLE_EMPLOYEE + " SET " + TestDb.EmployeeTable.NAME + " = 'Zach'");
db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES).subscribe(o);
o.assertCursor().hasRow("alice", "Alice Allison").hasRow("bob", "Bob Bobberson").hasRow("eve", "Eve Evenson").isExhausted();
db.executeUpdateDelete(Collections.<String>emptySet(), statement);
o.assertNoMoreEvents();
}
Aggregations