|
1 | 1 | package org.simple.clinic.recentpatientsview |
2 | 2 |
|
3 | | -import org.mockito.kotlin.clearInvocations |
4 | | -import org.mockito.kotlin.doReturn |
5 | | -import org.mockito.kotlin.mock |
6 | | -import org.mockito.kotlin.verify |
7 | | -import org.mockito.kotlin.verifyNoMoreInteractions |
8 | | -import org.mockito.kotlin.whenever |
9 | 3 | import io.reactivex.Observable |
10 | 4 | import io.reactivex.rxkotlin.ofType |
11 | 5 | import io.reactivex.subjects.PublishSubject |
12 | 6 | import io.reactivex.subjects.Subject |
13 | 7 | import org.junit.After |
14 | 8 | import org.junit.Rule |
15 | 9 | import org.junit.Test |
| 10 | +import org.mockito.kotlin.clearInvocations |
| 11 | +import org.mockito.kotlin.doReturn |
| 12 | +import org.mockito.kotlin.mock |
| 13 | +import org.mockito.kotlin.verify |
| 14 | +import org.mockito.kotlin.verifyNoMoreInteractions |
| 15 | +import org.mockito.kotlin.whenever |
| 16 | +import org.simple.clinic.TestData |
16 | 17 | import org.simple.clinic.patient.Gender.Female |
17 | 18 | import org.simple.clinic.patient.Gender.Male |
18 | 19 | import org.simple.clinic.patient.Gender.Transgender |
19 | 20 | import org.simple.clinic.patient.PatientAgeDetails |
20 | 21 | import org.simple.clinic.patient.PatientConfig |
21 | 22 | import org.simple.clinic.patient.PatientRepository |
22 | 23 | import org.simple.clinic.patient.RecentPatient |
| 24 | +import org.simple.clinic.recentpatient.RecentPatientUiModel |
| 25 | +import org.simple.clinic.util.RxErrorsRule |
| 26 | +import org.simple.clinic.util.TestUserClock |
23 | 27 | import org.simple.clinic.util.scheduler.TestSchedulersProvider |
24 | 28 | import org.simple.clinic.widgets.UiEvent |
25 | 29 | import org.simple.mobius.migration.MobiusTestFixture |
26 | | -import org.simple.clinic.TestData |
27 | | -import org.simple.clinic.util.RxErrorsRule |
28 | | -import org.simple.clinic.util.TestUserClock |
29 | 30 | import java.time.Instant |
30 | 31 | import java.time.LocalDate |
31 | 32 | import java.time.Period |
@@ -105,43 +106,49 @@ class LatestRecentPatientsLogicTest { |
105 | 106 |
|
106 | 107 | verify(ui).updateRecentPatients(listOf( |
107 | 108 | RecentPatientItem( |
108 | | - uuid = patientUuid1, |
109 | | - name = "Ajay Kumar", |
110 | | - age = 42, |
111 | | - gender = Transgender, |
112 | | - updatedAt = Instant.parse("2020-01-01T00:00:00Z"), |
113 | | - dateFormatter = dateFormatter, |
114 | | - clock = userClock, |
115 | | - isNewRegistration = true, |
116 | | - isEligibleForReassignment = false, |
117 | | - isSuspectedForHypertension = false, |
118 | | - isSuspectedForDiabetes = false, |
| 109 | + model = RecentPatientUiModel( |
| 110 | + uuid = patientUuid1, |
| 111 | + name = "Ajay Kumar", |
| 112 | + age = 42, |
| 113 | + gender = Transgender, |
| 114 | + updatedAt = Instant.parse("2020-01-01T00:00:00Z"), |
| 115 | + dateFormatter = dateFormatter, |
| 116 | + clock = userClock, |
| 117 | + isNewRegistration = true, |
| 118 | + isEligibleForReassignment = false, |
| 119 | + isSuspectedForHypertension = false, |
| 120 | + isSuspectedForDiabetes = false, |
| 121 | + ) |
119 | 122 | ), |
120 | 123 | RecentPatientItem( |
121 | | - uuid = patientUuid2, |
122 | | - name = "Vijay Kumar", |
123 | | - age = 24, |
124 | | - gender = Male, |
125 | | - updatedAt = Instant.parse("2019-12-31T00:00:00Z"), |
126 | | - dateFormatter = dateFormatter, |
127 | | - clock = userClock, |
128 | | - isNewRegistration = false, |
129 | | - isEligibleForReassignment = false, |
130 | | - isSuspectedForHypertension = false, |
131 | | - isSuspectedForDiabetes = false, |
| 124 | + model = RecentPatientUiModel( |
| 125 | + uuid = patientUuid2, |
| 126 | + name = "Vijay Kumar", |
| 127 | + age = 24, |
| 128 | + gender = Male, |
| 129 | + updatedAt = Instant.parse("2019-12-31T00:00:00Z"), |
| 130 | + dateFormatter = dateFormatter, |
| 131 | + clock = userClock, |
| 132 | + isNewRegistration = false, |
| 133 | + isEligibleForReassignment = false, |
| 134 | + isSuspectedForHypertension = false, |
| 135 | + isSuspectedForDiabetes = false, |
| 136 | + ) |
132 | 137 | ), |
133 | 138 | RecentPatientItem( |
134 | | - uuid = patientUuid3, |
135 | | - name = "Vinaya Kumari", |
136 | | - age = 27, |
137 | | - gender = Female, |
138 | | - updatedAt = Instant.parse("2019-12-29T00:00:00Z"), |
139 | | - dateFormatter = dateFormatter, |
140 | | - clock = userClock, |
141 | | - isNewRegistration = false, |
142 | | - isEligibleForReassignment = false, |
143 | | - isSuspectedForHypertension = false, |
144 | | - isSuspectedForDiabetes = false, |
| 139 | + model = RecentPatientUiModel( |
| 140 | + uuid = patientUuid3, |
| 141 | + name = "Vinaya Kumari", |
| 142 | + age = 27, |
| 143 | + gender = Female, |
| 144 | + updatedAt = Instant.parse("2019-12-29T00:00:00Z"), |
| 145 | + dateFormatter = dateFormatter, |
| 146 | + clock = userClock, |
| 147 | + isNewRegistration = false, |
| 148 | + isEligibleForReassignment = false, |
| 149 | + isSuspectedForHypertension = false, |
| 150 | + isSuspectedForDiabetes = false, |
| 151 | + ) |
145 | 152 | ) |
146 | 153 | )) |
147 | 154 | verify(ui).showOrHideRecentPatients(isVisible = true) |
@@ -207,43 +214,49 @@ class LatestRecentPatientsLogicTest { |
207 | 214 |
|
208 | 215 | verify(ui).updateRecentPatients(listOf( |
209 | 216 | RecentPatientItem( |
210 | | - uuid = patientUuid1, |
211 | | - name = "Ajay Kumar", |
212 | | - age = 42, |
213 | | - gender = Transgender, |
214 | | - updatedAt = Instant.parse("2020-01-01T00:00:00Z"), |
215 | | - dateFormatter = dateFormatter, |
216 | | - clock = userClock, |
217 | | - isNewRegistration = true, |
218 | | - isEligibleForReassignment = false, |
219 | | - isSuspectedForHypertension = false, |
220 | | - isSuspectedForDiabetes = false, |
| 217 | + model = RecentPatientUiModel( |
| 218 | + uuid = patientUuid1, |
| 219 | + name = "Ajay Kumar", |
| 220 | + age = 42, |
| 221 | + gender = Transgender, |
| 222 | + updatedAt = Instant.parse("2020-01-01T00:00:00Z"), |
| 223 | + dateFormatter = dateFormatter, |
| 224 | + clock = userClock, |
| 225 | + isNewRegistration = true, |
| 226 | + isEligibleForReassignment = false, |
| 227 | + isSuspectedForHypertension = false, |
| 228 | + isSuspectedForDiabetes = false, |
| 229 | + ) |
221 | 230 | ), |
222 | 231 | RecentPatientItem( |
223 | | - uuid = patientUuid2, |
224 | | - name = "Vijay Kumar", |
225 | | - age = 24, |
226 | | - gender = Male, |
227 | | - updatedAt = Instant.parse("2019-12-31T00:00:00Z"), |
228 | | - dateFormatter = dateFormatter, |
229 | | - clock = userClock, |
230 | | - isNewRegistration = false, |
231 | | - isEligibleForReassignment = false, |
232 | | - isSuspectedForHypertension = false, |
233 | | - isSuspectedForDiabetes = false, |
| 232 | + model = RecentPatientUiModel( |
| 233 | + uuid = patientUuid2, |
| 234 | + name = "Vijay Kumar", |
| 235 | + age = 24, |
| 236 | + gender = Male, |
| 237 | + updatedAt = Instant.parse("2019-12-31T00:00:00Z"), |
| 238 | + dateFormatter = dateFormatter, |
| 239 | + clock = userClock, |
| 240 | + isNewRegistration = false, |
| 241 | + isEligibleForReassignment = false, |
| 242 | + isSuspectedForHypertension = false, |
| 243 | + isSuspectedForDiabetes = false, |
| 244 | + ) |
234 | 245 | ), |
235 | 246 | RecentPatientItem( |
236 | | - uuid = patientUuid3, |
237 | | - name = "Vinaya Kumari", |
238 | | - age = 27, |
239 | | - gender = Female, |
240 | | - updatedAt = Instant.parse("2019-12-28T00:00:00Z"), |
241 | | - dateFormatter = dateFormatter, |
242 | | - clock = userClock, |
243 | | - isNewRegistration = false, |
244 | | - isEligibleForReassignment = false, |
245 | | - isSuspectedForHypertension = false, |
246 | | - isSuspectedForDiabetes = false, |
| 247 | + model = RecentPatientUiModel( |
| 248 | + uuid = patientUuid3, |
| 249 | + name = "Vinaya Kumari", |
| 250 | + age = 27, |
| 251 | + gender = Female, |
| 252 | + updatedAt = Instant.parse("2019-12-28T00:00:00Z"), |
| 253 | + dateFormatter = dateFormatter, |
| 254 | + clock = userClock, |
| 255 | + isNewRegistration = false, |
| 256 | + isEligibleForReassignment = false, |
| 257 | + isSuspectedForHypertension = false, |
| 258 | + isSuspectedForDiabetes = false, |
| 259 | + ) |
247 | 260 | ), |
248 | 261 | SeeAllItem |
249 | 262 | )) |
@@ -278,17 +291,19 @@ class LatestRecentPatientsLogicTest { |
278 | 291 | ))) |
279 | 292 | verify(ui).updateRecentPatients(listOf( |
280 | 293 | RecentPatientItem( |
281 | | - uuid = patientUuid, |
282 | | - name = "Anish Acharya", |
283 | | - age = 2, |
284 | | - gender = Male, |
285 | | - updatedAt = Instant.parse("2018-01-01T00:00:00Z"), |
286 | | - dateFormatter = dateFormatter, |
287 | | - clock = userClock, |
288 | | - isNewRegistration = false, |
289 | | - isEligibleForReassignment = false, |
290 | | - isSuspectedForHypertension = false, |
291 | | - isSuspectedForDiabetes = false, |
| 294 | + model = RecentPatientUiModel( |
| 295 | + uuid = patientUuid, |
| 296 | + name = "Anish Acharya", |
| 297 | + age = 2, |
| 298 | + gender = Male, |
| 299 | + updatedAt = Instant.parse("2018-01-01T00:00:00Z"), |
| 300 | + dateFormatter = dateFormatter, |
| 301 | + clock = userClock, |
| 302 | + isNewRegistration = false, |
| 303 | + isEligibleForReassignment = false, |
| 304 | + isSuspectedForHypertension = false, |
| 305 | + isSuspectedForDiabetes = false, |
| 306 | + ) |
292 | 307 | ) |
293 | 308 | )) |
294 | 309 | verify(ui).showOrHideRecentPatients(true) |
|
0 commit comments