From bff5e19d641d31b500924ba1975608299998ddfd Mon Sep 17 00:00:00 2001 From: Lentumunai-Mark Date: Mon, 9 Sep 2024 09:41:40 +0300 Subject: [PATCH] "Start writing test fro closing custom resources" Signed-off-by: Lentumunai-Mark --- .../engine/task/FhirResourceUtilTest.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/android/engine/src/test/java/org/smartregister/fhircore/engine/task/FhirResourceUtilTest.kt b/android/engine/src/test/java/org/smartregister/fhircore/engine/task/FhirResourceUtilTest.kt index ee0010e637..17ce9c2b93 100644 --- a/android/engine/src/test/java/org/smartregister/fhircore/engine/task/FhirResourceUtilTest.kt +++ b/android/engine/src/test/java/org/smartregister/fhircore/engine/task/FhirResourceUtilTest.kt @@ -38,6 +38,7 @@ import javax.inject.Inject import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.runTest import org.hl7.fhir.r4.model.CarePlan +import org.hl7.fhir.r4.model.Encounter import org.hl7.fhir.r4.model.Period import org.hl7.fhir.r4.model.Reference import org.hl7.fhir.r4.model.Task @@ -281,4 +282,22 @@ class FhirResourceUtilTest : RobolectricTest() { assertEquals(TaskStatus.REQUESTED, task.status) } + + @Test + fun testCloseCustomResources() { + val encounter = + Encounter().apply { + id = "test-Encounter" + period = Period().apply { start = Date().plusDays(-2) } + status = Encounter.EncounterStatus.INPROGRESS + } + + runBlocking { fhirEngine.create(encounter) } + + coEvery { defaultRepository.update(any()) } just runs + + assertEquals(Encounter.EncounterStatus.INPROGRESS, encounter.status) + + runBlocking { fhirResourceUtil.closeCustomResources() } + } }