-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] FhirEngine search integration tests
- Loading branch information
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
...idTest/java/org/smartregister/fhircore/engine/util/extension/FhirEngineExtensionKtTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package org.smartregister.fhircore.engine.util.extension | ||
|
||
import android.content.Context | ||
import androidx.test.core.app.ApplicationProvider | ||
import androidx.test.filters.LargeTest | ||
import androidx.test.filters.MediumTest | ||
import com.google.android.fhir.FhirEngine | ||
import com.google.android.fhir.FhirEngineConfiguration | ||
import com.google.android.fhir.FhirEngineProvider | ||
import com.google.android.fhir.datacapture.extensions.logicalId | ||
import com.google.android.fhir.search.getQuery | ||
import com.google.android.fhir.search.search | ||
import kotlinx.coroutines.runBlocking | ||
import org.hl7.fhir.r4.model.Patient | ||
import org.junit.After | ||
import org.junit.Assert | ||
import org.junit.Before | ||
import org.junit.Test | ||
import kotlin.system.measureTimeMillis | ||
|
||
@MediumTest | ||
class FhirEngineExtensionKtTest { | ||
|
||
private val context = ApplicationProvider.getApplicationContext<Context>() | ||
private lateinit var fhirEngine: FhirEngine | ||
|
||
@Before | ||
fun setUp() { | ||
FhirEngineProvider.init(FhirEngineConfiguration(testMode = true)) | ||
fhirEngine = FhirEngineProvider.getInstance(context) | ||
|
||
val patients = (0..1000).map { Patient().apply { id = "test-patient-${it}" } } | ||
runBlocking { | ||
fhirEngine.create(*patients.toTypedArray()) | ||
} | ||
} | ||
|
||
@After | ||
fun tearDown() { | ||
runBlocking { | ||
fhirEngine.clearDatabase() | ||
} | ||
FhirEngineProvider.cleanup() | ||
} | ||
|
||
@Test | ||
fun test_search_time() { | ||
runBlocking { | ||
val searchTime = measureTimeMillis { | ||
fhirEngine.search<Patient> {} | ||
} | ||
println(searchTime) | ||
} | ||
} | ||
|
||
@Test | ||
fun test_batchedSearch_time() { | ||
runBlocking { | ||
val searchTime = measureTimeMillis { | ||
fhirEngine.batchedSearch<Patient> {} | ||
} | ||
println(searchTime) | ||
} | ||
} | ||
|
||
} |