### Question:
Whassup { public Cursor queryMessages() throws IOException { return queryMessages(0, -1); } Whassup(Context context);   Whassup(DecryptorFactory decryptorFactory, DBProvider dbProvider, DBOpener dbOpener); Cursor queryMessages(); Cursor queryMessages(long timestamp, int max); long getMostRecentTimestamp(boolean ignoreGroups); List<WhatsAppMessage> getMessages(long timestamp, int max); List<WhatsAppMessage> getMessages(); boolean hasBackupDB();  }### Answer:
@Test(expected = IOException.class) public void shouldCatchSQLiteExceptionWhenOpeningDatabase() throws Exception { DBOpener dbOpener = mock(DBOpener.class); when(dbOpener.openDatabase(any(File.class))).thenThrow(new SQLiteException("failz")); new Whassup(decryptorFactory, dbProvider, dbOpener).queryMessages(); }
@Test public void shouldQueryMessages() throws Exception { Cursor cursor = whassup.queryMessages(); assertThat(cursor).isNotNull(); assertThat(cursor.getCount()).isEqualTo(82); cursor.close(); }
@Test public void shouldQueryMessagesSinceASpecificTimestamp() throws Exception { Cursor cursor = whassup.queryMessages(1367349391104L, -1); assertThat(cursor).isNotNull(); assertThat(cursor.getCount()).isEqualTo(15); }
@Test public void shouldQueryMessagesSinceASpecificTimestampAndLimit() throws Exception { Cursor cursor = whassup.queryMessages(1367349391104L, 3); assertThat(cursor).isNotNull(); assertThat(cursor.getCount()).isEqualTo(3); }