@@ -5,10 +5,15 @@ import androidx.room.Room
55import androidx.test.core.app.ApplicationProvider
66import androidx.test.ext.junit.runners.AndroidJUnit4
77import androidx.test.platform.app.InstrumentationRegistry
8- import kotlinx.coroutines.*
9- import kotlinx.coroutines.flow.count
10- import kotlinx.coroutines.flow.first
11- import org.hamcrest.CoreMatchers.*
8+ import kotlinx.coroutines.CoroutineExceptionHandler
9+ import kotlinx.coroutines.CoroutineScope
10+ import kotlinx.coroutines.Dispatchers
11+ import kotlinx.coroutines.launch
12+ import kotlinx.coroutines.runBlocking
13+ import kotlinx.coroutines.withContext
14+ import org.hamcrest.CoreMatchers.equalTo
15+ import org.hamcrest.CoreMatchers.notNullValue
16+ import org.hamcrest.CoreMatchers.nullValue
1217import org.hamcrest.MatcherAssert.assertThat
1318import org.junit.After
1419import org.junit.Before
@@ -22,7 +27,7 @@ import org.wikipedia.search.db.RecentSearchDao
2227import org.wikipedia.talk.db.TalkPageSeen
2328import org.wikipedia.talk.db.TalkPageSeenDao
2429import org.wikipedia.util.log.L
25- import java.util.*
30+ import java.util.Date
2631
2732@RunWith(AndroidJUnit4 ::class )
2833class AppDatabaseTests {
@@ -100,8 +105,8 @@ class AppDatabaseTests {
100105
101106 notificationDao.insertNotifications(notifications)
102107
103- var enWikiList = notificationDao.getNotificationsByWiki(listOf (" enwiki" )).first()
104- val zhWikiList = notificationDao.getNotificationsByWiki(listOf (" zhwiki" )).first()
108+ var enWikiList = notificationDao.getNotificationsByWiki(listOf (" enwiki" ))
109+ val zhWikiList = notificationDao.getNotificationsByWiki(listOf (" zhwiki" ))
105110 assertThat(enWikiList, notNullValue())
106111 assertThat(enWikiList.first().id, equalTo(123759827 ))
107112 assertThat(zhWikiList.first().id, equalTo(2470933 ))
@@ -114,18 +119,18 @@ class AppDatabaseTests {
114119 notificationDao.updateNotification(firstEnNotification)
115120
116121 // get updated item
117- enWikiList = notificationDao.getNotificationsByWiki(listOf (" enwiki" )).first()
122+ enWikiList = notificationDao.getNotificationsByWiki(listOf (" enwiki" ))
118123 assertThat(enWikiList.first().id, equalTo(123759827 ))
119124 assertThat(enWikiList.first().isUnread, equalTo(true ))
120125
121126 notificationDao.deleteNotification(firstEnNotification)
122127 assertThat(notificationDao.getAllNotifications().size, equalTo(2 ))
123- assertThat(notificationDao.getNotificationsByWiki(listOf (" enwiki" )).first(). size, equalTo(1 ))
128+ assertThat(notificationDao.getNotificationsByWiki(listOf (" enwiki" )).size, equalTo(1 ))
124129
125- notificationDao.deleteNotification(notificationDao.getNotificationsByWiki(listOf (" enwiki" )).first().first() )
126- assertThat(notificationDao.getNotificationsByWiki(listOf (" enwiki" )).first(). isEmpty(), equalTo(true ))
130+ notificationDao.deleteNotification(notificationDao.getNotificationsByWiki(listOf (" enwiki" )).first())
131+ assertThat(notificationDao.getNotificationsByWiki(listOf (" enwiki" )).isEmpty(), equalTo(true ))
127132
128- notificationDao.deleteNotification(notificationDao.getNotificationsByWiki(listOf (" zhwiki" )).first().first() )
133+ notificationDao.deleteNotification(notificationDao.getNotificationsByWiki(listOf (" zhwiki" )).first())
129134 assertThat(notificationDao.getAllNotifications().isEmpty(), equalTo(true ))
130135 }
131136}
0 commit comments