Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
camemre49 committed Feb 6, 2025
1 parent 1af283a commit 18c8f08
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,15 @@ class MappingExecutionEndpointTest extends BaseEndpointTest with OnFhirTestConta
// Run the job
Post(s"/${webServerConfig.baseUri}/${ProjectEndpoint.SEGMENT_PROJECTS}/$projectId/${JobEndpoint.SEGMENT_JOB}/${job.id}/${JobEndpoint.SEGMENT_RUN}", HttpEntity(ContentTypes.`application/json`, "")) ~> route ~> check {
status shouldEqual StatusCodes.OK
val startTime = System.nanoTime()

// test if erroneous records are written to error folder
val success = waitForCondition(120) {
val erroneousRecordsFolder = Paths.get(toFhirEngineConfig.erroneousRecordsFolder, FhirMappingErrorCodes.MAPPING_ERROR)
val jobFolder = Paths.get(erroneousRecordsFolder.toString, s"job-${job.id}").toFile
jobFolder.exists() && {

println("TEST STARTED")
val condition: Boolean = jobFolder.exists() && {
val sourceFolders = jobFolder.listFiles().headOption.flatMap( // execution folder
_.listFiles().headOption.map( // mapping task folder
_.listFiles())) // source folder i.e. main source, secondary source etc.
Expand Down Expand Up @@ -269,6 +272,11 @@ class MappingExecutionEndpointTest extends BaseEndpointTest with OnFhirTestConta
}
}
}
println("TEST ENDED")
val endTime = System.nanoTime()
val elapsedTime = (endTime - startTime) / 1e9 // Convert nanoseconds to seconds
println(s"TEST EXECUTION TIME: $elapsedTime seconds")
condition
}
if (!success) fail("Failed to find expected number of erroneous records. Either the erroneous record file is not available or the number of records does not match")
}
Expand Down

0 comments on commit 18c8f08

Please sign in to comment.