Skip to content

Commit 41ebbfe

Browse files
author
sagarwal
committed
Fix test cases
1 parent ee0686d commit 41ebbfe

File tree

5 files changed

+110
-89
lines changed

5 files changed

+110
-89
lines changed

app/src/androidTest/java/org/simple/clinic/patient/PatientRepositoryAndroidTest.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,8 @@ class PatientRepositoryAndroidTest {
922922
patientRecordedAt = this.recordedAt,
923923
updatedAt = recordedAt,
924924
eligibleForReassignment = eligibleForReassignment,
925+
diagnosedWithDiabetes = Yes,
926+
diagnosedWithHypertension = Yes
925927
)
926928

927929
private fun verifyRecentPatientOrder(
@@ -977,6 +979,8 @@ class PatientRepositoryAndroidTest {
977979
patientRecordedAt = this.recordedAt,
978980
updatedAt = updatedAt,
979981
eligibleForReassignment = eligibleForReassignment,
982+
diagnosedWithDiabetes = Yes,
983+
diagnosedWithHypertension = Yes
980984
)
981985
}
982986
}
@@ -1119,6 +1123,8 @@ class PatientRepositoryAndroidTest {
11191123
patientRecordedAt = this.recordedAt,
11201124
updatedAt = createdAt,
11211125
eligibleForReassignment = eligibleForReassignment,
1126+
diagnosedWithDiabetes = Yes,
1127+
diagnosedWithHypertension = Yes
11221128
)
11231129
}
11241130
}

app/src/main/java/org/simple/clinic/recentpatient/RecentPatientItem.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ data class RecentPatientItem(
3333
userClock: UserClock,
3434
dateFormatter: DateTimeFormatter
3535
): RecentPatientItem {
36-
val model = RecentPatientUiModel.fromDomain(
36+
val model = RecentPatientUiModel.from(
3737
recentPatient = recentPatient,
3838
today = today,
3939
userClock = userClock,

app/src/main/java/org/simple/clinic/recentpatient/RecentPatientUiModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ data class RecentPatientUiModel(
3232
val isSuspectedForDiabetes: Boolean = false
3333
) {
3434
companion object {
35-
fun fromDomain(
35+
fun from(
3636
recentPatient: RecentPatient,
3737
today: LocalDate,
3838
userClock: UserClock,

app/src/main/java/org/simple/clinic/recentpatientsview/RecentPatientItem.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ sealed class RecentPatientItemType : ItemAdapter.Item<UiEvent> {
4747
dateFormatter: DateTimeFormatter,
4848
isPatientReassignmentFeatureEnabled: Boolean,
4949
): RecentPatientItem {
50-
val model = RecentPatientUiModel.fromDomain(
50+
val model = RecentPatientUiModel.from(
5151
recentPatient = recentPatient,
5252
today = today,
5353
userClock = userClock,

app/src/test/java/org/simple/clinic/recentpatientsview/LatestRecentPatientsLogicTest.kt

Lines changed: 101 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
11
package org.simple.clinic.recentpatientsview
22

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
93
import io.reactivex.Observable
104
import io.reactivex.rxkotlin.ofType
115
import io.reactivex.subjects.PublishSubject
126
import io.reactivex.subjects.Subject
137
import org.junit.After
148
import org.junit.Rule
159
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
1617
import org.simple.clinic.patient.Gender.Female
1718
import org.simple.clinic.patient.Gender.Male
1819
import org.simple.clinic.patient.Gender.Transgender
1920
import org.simple.clinic.patient.PatientAgeDetails
2021
import org.simple.clinic.patient.PatientConfig
2122
import org.simple.clinic.patient.PatientRepository
2223
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
2327
import org.simple.clinic.util.scheduler.TestSchedulersProvider
2428
import org.simple.clinic.widgets.UiEvent
2529
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
2930
import java.time.Instant
3031
import java.time.LocalDate
3132
import java.time.Period
@@ -105,43 +106,49 @@ class LatestRecentPatientsLogicTest {
105106

106107
verify(ui).updateRecentPatients(listOf(
107108
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+
)
119122
),
120123
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+
)
132137
),
133138
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+
)
145152
)
146153
))
147154
verify(ui).showOrHideRecentPatients(isVisible = true)
@@ -207,43 +214,49 @@ class LatestRecentPatientsLogicTest {
207214

208215
verify(ui).updateRecentPatients(listOf(
209216
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+
)
221230
),
222231
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+
)
234245
),
235246
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+
)
247260
),
248261
SeeAllItem
249262
))
@@ -278,17 +291,19 @@ class LatestRecentPatientsLogicTest {
278291
)))
279292
verify(ui).updateRecentPatients(listOf(
280293
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+
)
292307
)
293308
))
294309
verify(ui).showOrHideRecentPatients(true)

0 commit comments

Comments
 (0)