Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo <[email protected]>
  • Loading branch information
Balcan committed Feb 8, 2024
1 parent fe6dac1 commit 1cba0fd
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class EventInitialTest {
enrollmentStatus = enrollmentStatus,
)

private fun provideEventResourcesProvider() = EventDetailResourcesProvider(resourceManager)
private fun provideEventResourcesProvider() = EventDetailResourcesProvider(PROGRAM_UID, resourceManager)

private fun createOrUpdateEventDetails() = CreateOrUpdateEventDetails(
repository = eventDetailsRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ class FilterRepositoryTest {
private fun mockFilterLabels() {
whenever(filterResources.filterOrgUnitLabel()) doReturn ORG_UNIT
whenever(filterResources.filterSyncLabel()) doReturn SYNC_STATUS
whenever(filterResources.filterEnrollmentStatusLabel()) doReturn
whenever(filterResources.filterEnrollmentStatusLabel(any())) doReturn
ENROLLMENT_STATUS
whenever(filterResources.filterDateLabel()) doReturn EVENT_DATE
whenever(filterResources.filterEventStatusLabel()) doReturn EVENT_STATUS
whenever(filterResources.filterEnrollmentDateLabel()) doReturn
whenever(filterResources.filterEnrollmentDateLabel(any())) doReturn
ENROLLMENT_DATE
whenever(filterResources.filterAssignedToMeLabel()) doReturn ASSIGN_TO_ME
whenever(filterResources.filterEventDateLabel()) doReturn EVENT_DATE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class EventDetailsIntegrationTest {
enrollmentStatus = enrollmentStatus,
)

private fun provideEventResourcesProvider() = EventDetailResourcesProvider(resourceManager)
private fun provideEventResourcesProvider() = EventDetailResourcesProvider(PROGRAM_UID, resourceManager)

private fun createOrUpdateEventDetails() = CreateOrUpdateEventDetails(
repository = eventDetailsRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.hisp.dhis.android.core.trackedentity.TrackedEntityInstance
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import org.mockito.kotlin.any
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.mock
import org.mockito.kotlin.whenever
Expand All @@ -36,7 +37,7 @@ class TEICardMapperTest {
whenever(resourceManager.getString(R.string.show_less)) doReturn "Show less"
whenever(resourceManager.getString(R.string.completed)) doReturn "Completed"
whenever(
resourceManager.getString(R.string.enrollment_completed),
resourceManager.formatWithEnrollmentLabel(any(), any(), any(), any()),
) doReturn "Enrollment Completed"
whenever(
resourceManager.getString(R.string.overdue_today),
Expand Down Expand Up @@ -67,7 +68,7 @@ class TEICardMapperTest {
)
assertEquals(
result.additionalInfo[3].value,
resourceManager.getString(R.string.enrollment_completed),
"Enrollment Completed",
)

assertEquals(
Expand Down Expand Up @@ -99,6 +100,7 @@ class TEICardMapperTest {
setCurrentEnrollment(
Enrollment.builder()
.uid("EnrollmentUid")
.program("programUid")
.status(EnrollmentStatus.COMPLETED)
.build(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,19 @@ class InfoBarMapperTest {
whenever(resourceManager.getString(R.string.sync_warning)) doReturn "Sync warning"
whenever(resourceManager.getString(R.string.sync_error)) doReturn "Sync Error"
whenever(resourceManager.getString(R.string.marked_follow_up)) doReturn "Marked for follow up"
whenever(resourceManager.getString(R.string.enrollment_completed)) doReturn "Enrollment completed"
whenever(resourceManager.getString(R.string.enrollment_cancelled)) doReturn "Enrollment cancelled"
setPrograms().forEach {
whenever(
resourceManager.formatWithEnrollmentLabel(
it.uid(), R.string.enrollment_completed_V2, 1,
),
) doReturn "Enrollment completed"
whenever(
resourceManager.formatWithEnrollmentLabel(
it.uid(), R.string.enrollment_cancelled_V2, 1,
),
) doReturn "Enrollment cancelled"
}

whenever(resourceManager.getString(R.string.sync)) doReturn "Sync"
whenever(resourceManager.getString(R.string.sync_retry)) doReturn "Retry sync"
whenever(resourceManager.getString(R.string.remove)) doReturn "remove"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ResourceManager(
programUid: String,
@StringRes stringResource: Int,
quantity: Int,
formatWithQuantity: Boolean = false
formatWithQuantity: Boolean = false,
): String {
val enrollmentLabel = try {
D2Manager.getD2().programModule().programs().uid(programUid).blockingGet()
Expand Down

0 comments on commit 1cba0fd

Please sign in to comment.