From 9efc23675c6351d7a564b0895f240ceb3b5dd162 Mon Sep 17 00:00:00 2001 From: okanmercan Date: Fri, 29 Sep 2023 13:21:23 +0300 Subject: [PATCH] :recyclec: refactor(FhirMappingJobManagerTest): Add a real erroneous csv to tests. --- .../test/resources/test-data/patients-erroneous.csv | 11 +++++++++++ .../io/tofhir/test/FhirMappingJobManagerTest.scala | 7 +++++-- 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 tofhir-engine/src/test/resources/test-data/patients-erroneous.csv diff --git a/tofhir-engine/src/test/resources/test-data/patients-erroneous.csv b/tofhir-engine/src/test/resources/test-data/patients-erroneous.csv new file mode 100644 index 000000000..d376cc91f --- /dev/null +++ b/tofhir-engine/src/test/resources/test-data/patients-erroneous.csv @@ -0,0 +1,11 @@ +pid,gender,birthDate,deceasedDateTime,homePostalCode +p1,male,2000-05-10,, +p2,male,1985-05-08,2017-03-10,G02547 +p3,male,1997-02,, +p4,male,1999-06-05,,H10564 +p5,male,1965-10-01,2019-04-21,G02547 +p6,,1991-03 +p7,female,1972-10-25,,V13135 +p8,female,2010-01-10,,Z54564 +p9,female,1999-05-12,, +p10,female,2003-11,, diff --git a/tofhir-engine/src/test/scala/io/tofhir/test/FhirMappingJobManagerTest.scala b/tofhir-engine/src/test/scala/io/tofhir/test/FhirMappingJobManagerTest.scala index 7663a68b8..7ec335518 100644 --- a/tofhir-engine/src/test/scala/io/tofhir/test/FhirMappingJobManagerTest.scala +++ b/tofhir-engine/src/test/scala/io/tofhir/test/FhirMappingJobManagerTest.scala @@ -39,6 +39,11 @@ class FhirMappingJobManagerTest extends AsyncFlatSpec with BeforeAndAfterAll wit sourceContext = Map("source" -> FileSystemSource(path = "patients.csv")) ) + val patientMappingTaskWithError: FhirMappingTask = FhirMappingTask( + mappingRef = "https://aiccelerate.eu/fhir/mappings/patient-mapping", + sourceContext = Map("source" -> FileSystemSource(path = "patients-erroneous.csv")) + ) + val patientMappingTaskWithPreprocess: FhirMappingTask = FhirMappingTask( mappingRef = "https://aiccelerate.eu/fhir/mappings/patient-mapping", sourceContext = Map("source" -> @@ -250,7 +255,6 @@ class FhirMappingJobManagerTest extends AsyncFlatSpec with BeforeAndAfterAll wit it should "halt execute the mapping job when encounter with an error" in { assume(fhirServerIsAvailable) - val patientMappingTaskWithError = patientMappingTask.copy(sourceContext = Map("source" -> FileSystemSource(path = "wrong.csv"))) val fhirMappingJobManager = new FhirMappingJobManager(mappingRepository, contextLoader, schemaRepository, Map(FhirPathUtilFunctionsFactory.defaultPrefix -> FhirPathUtilFunctionsFactory), sparkSession, mappingErrorHandling, runningJobRegistry) val future = fhirMappingJobManager.executeMappingJob(mappingJobExecution = FhirMappingJobExecution( @@ -270,7 +274,6 @@ class FhirMappingJobManagerTest extends AsyncFlatSpec with BeforeAndAfterAll wit it should "continue execute the mapping job when encounter without an error" in { assume(fhirServerIsAvailable) - val patientMappingTaskWithError = patientMappingTask.copy(sourceContext = Map("source" -> FileSystemSource(path = "wrong.csv"))) val fhirMappingJobManager = new FhirMappingJobManager(mappingRepository, contextLoader, schemaRepository, Map(FhirPathUtilFunctionsFactory.defaultPrefix -> FhirPathUtilFunctionsFactory), sparkSession, mappingErrorHandling, runningJobRegistry) val future = fhirMappingJobManager.executeMappingJob(mappingJobExecution = FhirMappingJobExecution(