@@ -41,7 +41,7 @@ class HistoryRecordManagerTest {
4141 // For some reason the Flowable returned by getAll() never completes, so we can't assert
4242 // that the number of Lists it returns is exactly 1, we can only check if the first List is
4343 // correct. Why on earth has a Flowable been used instead of a Single for getAll()?!?
44- val entities = database.searchHistoryDAO().all .blockingFirst()
44+ val entities = database.searchHistoryDAO().getAll() .blockingFirst()
4545 assertThat(entities).hasSize(1 )
4646 assertThat(entities[0 ].id).isEqualTo(1 )
4747 assertThat(entities[0 ].serviceId).isEqualTo(0 )
@@ -51,50 +51,50 @@ class HistoryRecordManagerTest {
5151 @Test
5252 fun deleteSearchHistory () {
5353 val entries = listOf (
54- SearchHistoryEntry (time.minusSeconds(1 ), 0 , " A" ),
55- SearchHistoryEntry (time.minusSeconds(2 ), 2 , " A" ),
56- SearchHistoryEntry (time.minusSeconds(3 ), 1 , " B" ),
57- SearchHistoryEntry (time.minusSeconds(4 ), 0 , " B" ),
54+ SearchHistoryEntry (creationDate = time.minusSeconds(1 ), serviceId = 0 , search = " A" ),
55+ SearchHistoryEntry (creationDate = time.minusSeconds(2 ), serviceId = 2 , search = " A" ),
56+ SearchHistoryEntry (creationDate = time.minusSeconds(3 ), serviceId = 1 , search = " B" ),
57+ SearchHistoryEntry (creationDate = time.minusSeconds(4 ), serviceId = 0 , search = " B" ),
5858 )
5959
6060 // make sure all 4 were inserted
6161 database.searchHistoryDAO().insertAll(entries)
62- assertThat(database.searchHistoryDAO().all .blockingFirst()).hasSameSizeAs(entries)
62+ assertThat(database.searchHistoryDAO().getAll() .blockingFirst()).hasSameSizeAs(entries)
6363
6464 // try to delete only "A" entries, "B" entries should be untouched
6565 manager.deleteSearchHistory(" A" ).test().await().assertValue(2 )
66- val entities = database.searchHistoryDAO().all .blockingFirst()
66+ val entities = database.searchHistoryDAO().getAll() .blockingFirst()
6767 assertThat(entities).hasSize(2 )
6868 assertThat(entities).usingElementComparator { o1, o2 -> if (o1.hasEqualValues(o2)) 0 else 1 }
6969 .containsExactly(* entries.subList(2 , 4 ).toTypedArray())
7070
7171 // assert that nothing happens if we delete a search query that does exist in the db
7272 manager.deleteSearchHistory(" A" ).test().await().assertValue(0 )
73- val entities2 = database.searchHistoryDAO().all .blockingFirst()
73+ val entities2 = database.searchHistoryDAO().getAll() .blockingFirst()
7474 assertThat(entities2).hasSize(2 )
7575 assertThat(entities2).usingElementComparator { o1, o2 -> if (o1.hasEqualValues(o2)) 0 else 1 }
7676 .containsExactly(* entries.subList(2 , 4 ).toTypedArray())
7777
7878 // delete all remaining entries
7979 manager.deleteSearchHistory(" B" ).test().await().assertValue(2 )
80- assertThat(database.searchHistoryDAO().all .blockingFirst()).isEmpty()
80+ assertThat(database.searchHistoryDAO().getAll() .blockingFirst()).isEmpty()
8181 }
8282
8383 @Test
8484 fun deleteCompleteSearchHistory () {
8585 val entries = listOf (
86- SearchHistoryEntry (time.minusSeconds(1 ), 1 , " A" ),
87- SearchHistoryEntry (time.minusSeconds(2 ), 2 , " B" ),
88- SearchHistoryEntry (time.minusSeconds(3 ), 0 , " C" ),
86+ SearchHistoryEntry (creationDate = time.minusSeconds(1 ), serviceId = 1 , search = " A" ),
87+ SearchHistoryEntry (creationDate = time.minusSeconds(2 ), serviceId = 2 , search = " B" ),
88+ SearchHistoryEntry (creationDate = time.minusSeconds(3 ), serviceId = 0 , search = " C" ),
8989 )
9090
9191 // make sure all 3 were inserted
9292 database.searchHistoryDAO().insertAll(entries)
93- assertThat(database.searchHistoryDAO().all .blockingFirst()).hasSameSizeAs(entries)
93+ assertThat(database.searchHistoryDAO().getAll() .blockingFirst()).hasSameSizeAs(entries)
9494
9595 // should remove everything
9696 manager.deleteCompleteSearchHistory().test().await().assertValue(entries.size)
97- assertThat(database.searchHistoryDAO().all .blockingFirst()).isEmpty()
97+ assertThat(database.searchHistoryDAO().getAll() .blockingFirst()).isEmpty()
9898 }
9999
100100 private fun insertShuffledRelatedSearches (relatedSearches : Collection <SearchHistoryEntry >) {
@@ -107,7 +107,7 @@ class HistoryRecordManagerTest {
107107 // make sure all entries were inserted
108108 assertEquals(
109109 relatedSearches.size,
110- database.searchHistoryDAO().all .blockingFirst().size
110+ database.searchHistoryDAO().getAll() .blockingFirst().size
111111 )
112112 }
113113
@@ -127,19 +127,18 @@ class HistoryRecordManagerTest {
127127
128128 @Test
129129 fun getRelatedSearches_emptyQuery_manyDuplicates () {
130- insertShuffledRelatedSearches(
131- listOf (
132- SearchHistoryEntry (time.minusSeconds(9 ), 3 , " A" ),
133- SearchHistoryEntry (time.minusSeconds(8 ), 3 , " AB" ),
134- SearchHistoryEntry (time.minusSeconds(7 ), 3 , " A" ),
135- SearchHistoryEntry (time.minusSeconds(6 ), 3 , " A" ),
136- SearchHistoryEntry (time.minusSeconds(5 ), 3 , " BA" ),
137- SearchHistoryEntry (time.minusSeconds(4 ), 3 , " A" ),
138- SearchHistoryEntry (time.minusSeconds(3 ), 3 , " A" ),
139- SearchHistoryEntry (time.minusSeconds(2 ), 0 , " A" ),
140- SearchHistoryEntry (time.minusSeconds(1 ), 2 , " AA" ),
141- )
130+ val relatedSearches = listOf (
131+ SearchHistoryEntry (creationDate = time.minusSeconds(9 ), serviceId = 3 , search = " A" ),
132+ SearchHistoryEntry (creationDate = time.minusSeconds(8 ), serviceId = 3 , search = " AB" ),
133+ SearchHistoryEntry (creationDate = time.minusSeconds(7 ), serviceId = 3 , search = " A" ),
134+ SearchHistoryEntry (creationDate = time.minusSeconds(6 ), serviceId = 3 , search = " A" ),
135+ SearchHistoryEntry (creationDate = time.minusSeconds(5 ), serviceId = 3 , search = " BA" ),
136+ SearchHistoryEntry (creationDate = time.minusSeconds(4 ), serviceId = 3 , search = " A" ),
137+ SearchHistoryEntry (creationDate = time.minusSeconds(3 ), serviceId = 3 , search = " A" ),
138+ SearchHistoryEntry (creationDate = time.minusSeconds(2 ), serviceId = 0 , search = " A" ),
139+ SearchHistoryEntry (creationDate = time.minusSeconds(1 ), serviceId = 2 , search = " AA" ),
142140 )
141+ insertShuffledRelatedSearches(relatedSearches)
143142
144143 val searches = manager.getRelatedSearches(" " , 9 , 3 ).blockingFirst()
145144 assertThat(searches).containsExactly(" AA" , " A" , " BA" )
@@ -166,13 +165,13 @@ class HistoryRecordManagerTest {
166165 private val time = OffsetDateTime .of(LocalDateTime .of(2000 , 1 , 1 , 1 , 1 ), ZoneOffset .UTC )
167166
168167 private val RELATED_SEARCHES_ENTRIES = listOf (
169- SearchHistoryEntry (time.minusSeconds(7 ), 2 , " AC" ),
170- SearchHistoryEntry (time.minusSeconds(6 ), 0 , " ABC" ),
171- SearchHistoryEntry (time.minusSeconds(5 ), 1 , " BA" ),
172- SearchHistoryEntry (time.minusSeconds(4 ), 3 , " A" ),
173- SearchHistoryEntry (time.minusSeconds(2 ), 0 , " B" ),
174- SearchHistoryEntry (time.minusSeconds(3 ), 2 , " AA" ),
175- SearchHistoryEntry (time.minusSeconds(1 ), 1 , " A" ),
168+ SearchHistoryEntry (creationDate = time.minusSeconds(7 ), serviceId = 2 , search = " AC" ),
169+ SearchHistoryEntry (creationDate = time.minusSeconds(6 ), serviceId = 0 , search = " ABC" ),
170+ SearchHistoryEntry (creationDate = time.minusSeconds(5 ), serviceId = 1 , search = " BA" ),
171+ SearchHistoryEntry (creationDate = time.minusSeconds(4 ), serviceId = 3 , search = " A" ),
172+ SearchHistoryEntry (creationDate = time.minusSeconds(2 ), serviceId = 0 , search = " B" ),
173+ SearchHistoryEntry (creationDate = time.minusSeconds(3 ), serviceId = 2 , search = " AA" ),
174+ SearchHistoryEntry (creationDate = time.minusSeconds(1 ), serviceId = 1 , search = " A" ),
176175 )
177176 }
178177}
0 commit comments