From b8a35ed5311fde6087c17942e2d3a41190c872f9 Mon Sep 17 00:00:00 2001 From: agelledi Date: Mon, 11 Nov 2024 12:02:17 +0000 Subject: [PATCH 1/6] removed stateful behaviour --- .../test/java/mocks/sandbox/patch-patient.js | 1 - .../src/test/java/mocks/sandbox/stubs.js | 3 +- .../patientResponses/patient_5900056449.json | 19 +++- .../patientResponses/patient_9733162051.json | 87 +++++++++++++++ .../updatePatientDetails/addAndRemove.feature | 100 +++++++++++------- 5 files changed, 171 insertions(+), 39 deletions(-) create mode 100644 karate-tests/src/test/java/mocks/stubs/patientResponses/patient_9733162051.json diff --git a/karate-tests/src/test/java/mocks/sandbox/patch-patient.js b/karate-tests/src/test/java/mocks/sandbox/patch-patient.js index 66006964c..c2bf547c9 100644 --- a/karate-tests/src/test/java/mocks/sandbox/patch-patient.js +++ b/karate-tests/src/test/java/mocks/sandbox/patch-patient.js @@ -168,7 +168,6 @@ if (request.pathMatches('/Patient/{nhsNumber}') && request.patch) { const originalPatient = session.patients[nhsNumber] const updatedPatient = patchPatient(originalPatient, request) if (updatedPatient) { - session.patients[nhsNumber] = updatedPatient response.headers = buildResponseHeaders(request, updatedPatient) response.body = updatedPatient response.status = 200 diff --git a/karate-tests/src/test/java/mocks/sandbox/stubs.js b/karate-tests/src/test/java/mocks/sandbox/stubs.js index 3c1740a62..bfe1b19ab 100644 --- a/karate-tests/src/test/java/mocks/sandbox/stubs.js +++ b/karate-tests/src/test/java/mocks/sandbox/stubs.js @@ -42,5 +42,6 @@ session.patients = session.patients || { 9000000025: context.read('classpath:mocks/stubs/patientResponses/patient_9000000025.json'), 9000000033: context.read('classpath:mocks/stubs/patientResponses/patient_9000000033.json'), 9693632109: context.read('classpath:mocks/stubs/patientResponses/patient_9693632109.json'), - 9733162043: context.read('classpath:mocks/stubs/patientResponses/patient_9733162043.json') + 9733162043: context.read('classpath:mocks/stubs/patientResponses/patient_9733162043.json'), + 9733162051: context.read('classpath:mocks/stubs/patientResponses/patient_9733162051.json') } diff --git a/karate-tests/src/test/java/mocks/stubs/patientResponses/patient_5900056449.json b/karate-tests/src/test/java/mocks/stubs/patientResponses/patient_5900056449.json index 880576ed4..04ad6e905 100644 --- a/karate-tests/src/test/java/mocks/stubs/patientResponses/patient_5900056449.json +++ b/karate-tests/src/test/java/mocks/stubs/patientResponses/patient_5900056449.json @@ -60,7 +60,24 @@ "Mr" ], "use": "usual" - } + }, + { + "use": "old", + "period": { + "start": "2018-12-31" + }, + "prefix": [ + "Dr" + ], + "given": [ + "Roger" + ], + "family": "Killen", + "suffix": [ + "PhD" + ], + "id": "4E1F33EF" + } ], "resourceType": "Patient" } \ No newline at end of file diff --git a/karate-tests/src/test/java/mocks/stubs/patientResponses/patient_9733162051.json b/karate-tests/src/test/java/mocks/stubs/patientResponses/patient_9733162051.json new file mode 100644 index 000000000..9f742c570 --- /dev/null +++ b/karate-tests/src/test/java/mocks/stubs/patientResponses/patient_9733162051.json @@ -0,0 +1,87 @@ +{ + "address": [ + { + "id": "OVvLE", + "line": [ + "2 DALE FARM COTTAGE", + "RACE LANE", + "WOOTTON", + "ULCEBY", + "S HUMBERSIDE" + ], + "period": { + "start": "2016-01-31" + }, + "postalCode": "DN39 6RF", + "use": "home" + } + ], + "birthDate": "1939-10-21", + "gender": "male", + "generalPractitioner": [ + { + "id": "KsFNC", + "identifier": { + "period": { + "start": "2004-12-20" + }, + "system": "https://fhir.nhs.uk/Id/ods-organization-code", + "value": "A20047" + }, + "type": "Organization" + } + ], + "id": "9733162051", + "identifier": [ + { + "extension": [ + { + "url": "https://fhir.hl7.org.uk/StructureDefinition/Extension-UKCore-NHSNumberVerificationStatus", + "valueCodeableConcept": { + "coding": [ + { + "code": "01", + "display": "Number present and verified", + "system": "https://fhir.hl7.org.uk/CodeSystem/UKCore-NHSNumberVerificationStatus", + "version": "1.0.0" + } + ] + } + } + ], + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "9733162051" + } + ], + "meta": { + "security": [ + { + "code": "U", + "display": "unrestricted", + "system": "http://terminology.hl7.org/CodeSystem/v3-Confidentiality" + } + ], + "versionId": "4" + }, + "name": [ + { + "family": "FRAZER", + "given": [ + "Nigel" + ], + "id": "vfynR", + "period": { + "start": "1983-10-04" + }, + "prefix": [ + "MR" + ], + "suffix": [ + "PhD", + "MBBS" + ], + "use": "usual" + } + ], + "resourceType": "Patient" +} \ No newline at end of file diff --git a/karate-tests/src/test/java/patients/healthcareWorker/updatePatientDetails/addAndRemove.feature b/karate-tests/src/test/java/patients/healthcareWorker/updatePatientDetails/addAndRemove.feature index 74e8e4c28..07db85e68 100644 --- a/karate-tests/src/test/java/patients/healthcareWorker/updatePatientDetails/addAndRemove.feature +++ b/karate-tests/src/test/java/patients/healthcareWorker/updatePatientDetails/addAndRemove.feature @@ -13,18 +13,14 @@ Feature: Patch patient - Add and remove data * configure headers = call read('classpath:auth/auth-headers.js') * url baseURL + + Scenario: Add and remove patient data * def nhsNumber = '5900056449' * path 'Patient', nhsNumber * method get * status 200 - * def patientObject = response * def originalVersion = parseInt(response.meta.versionId) * def originalEtag = karate.response.header('etag') - * copy originalNameArray = response.name - - @sandbox - Scenario: Add and remove patient data - * match response.name == "#[1]" # 1. Add a new name to the array of patient names # =============================================== @@ -52,8 +48,9 @@ Feature: Patch patient - Add and remove data * request {"patches": [{ "op": "add", "path": "/name/-", "value": "#(newName)" }]} * method patch * status 200 - * match response.name == "#[2]" - * match response.name[1] == expectedName + * def addedName = response.name.find(x => x.family == "Bloggs") + + * match addedName == expectedName * match parseInt(response.meta.versionId) == originalVersion + 1 # 2. Remove the name we just added @@ -62,6 +59,10 @@ Feature: Patch patient - Add and remove data # Now remove the name. To illustrate the remove behaviour, we do two tests here: # 1. We try to remove the name without first testing for it, which should fail # 2. We test for the name and then remove it, which should succeed + * path 'Patient', nhsNumber + * method get + * status 200 + * copy originalNameArray = response.name * def originalVersion = parseInt(response.meta.versionId) * def nameID = response.name[1].id * def etag = karate.response.header('etag') @@ -95,12 +96,15 @@ Feature: Patch patient - Add and remove data * request patchBody * method patch * status 200 - * match response.name == "#[1]" - * match response.name == originalNameArray + * match response.name !contains { id: '#(nameID)' } * match parseInt(response.meta.versionId) == originalVersion + 1 # 3. Add a suffix array # ===================== + * path 'Patient', nhsNumber + * method get + * status 200 + * def patientObject = response * def originalVersion = parseInt(response.meta.versionId) * match response.name[0].suffix == "#notpresent" @@ -121,34 +125,51 @@ Feature: Patch patient - Add and remove data * status 200 * match response.name[0].suffix == suffixArray * match parseInt(response.meta.versionId) == originalVersion + 1 - - # 4. Remove one of the suffixes we just added - # =========================================== - # We added an array of suffixes; now we're going to remove one of the suffixes in the - # array. - * def originalVersion = parseInt(response.meta.versionId) + # 4. Remove the whole suffix array + # ================================ + # And you can get rid of the whole array of suffixes + * path 'Patient', nhsNumber + * method get + * status 200 + * def patientObject = response + * def originalVersion = parseInt(response.meta.versionId) + * def firstNameIndexWithSuffix = response.name.findIndex(x => x.suffix != null) + * def namePath = "/name/"+ firstNameIndexWithSuffix + * def nameId = response.name.find(x => x.suffix != null).id + * configure headers = call read('classpath:auth/auth-headers.js') * header Content-Type = "application/json-patch+json" - * header If-Match = karate.response.header('etag') + * header If-Match = karate.response.header('etag') * path 'Patient', nhsNumber * request """ {"patches":[ - { "op": "test", "path": "/name/0/id", "value": "#(patientObject.name[0].id)" }, - { "op": "remove","path": "/name/0/suffix/0" } + { "op": "test", "path": "#(namePath)/id", "value": "#(nameId)" }, + { "op": "remove", "path": "#(namePath)/suffix" } ]} - """ + """ * method patch * status 200 - * match response.name[0].suffix == ["MBBS"] + * match response.name[0].suffix == '#notpresent' * match parseInt(response.meta.versionId) == originalVersion + 1 - # 5. Add new suffix to the array + Scenario: Add suffix to the existing array of suffixes and then remove the same + # 1. Add new suffix to the array # ============================== # You can also add a new suffix to an existing array of suffixes + * def nhsNumber = '9733162051' + * path 'Patient', nhsNumber + * method get + * status 200 + * def patientObject = response * def originalVersion = parseInt(response.meta.versionId) - + * def firstNameIndexWithSuffix = response.name.findIndex(x => x.suffix != null) + * def namePath = "/name/"+ firstNameIndexWithSuffix + * def nameId = response.name.find(x => x.suffix != null).id + * def suffix = "Esquire" + * print firstNameIndexWithSuffix, nameId + * configure headers = call read('classpath:auth/auth-headers.js') * header Content-Type = "application/json-patch+json" * header If-Match = karate.response.header('etag') @@ -156,34 +177,41 @@ Feature: Patch patient - Add and remove data * request """ {"patches":[ - { "op": "add", "path": "/name/0/id", "value": "#(patientObject.name[0].id)" }, - { "op": "add", "path": "/name/0/suffix/0", "value": "Esquire" } + { "op": "add", "path": "#(namePath)/id", "value": "#(nameId))" }, + { "op": "add", "path": "/name/0/suffix/0", "value": "#(suffix)" } ]} """ * method patch * status 200 - * match response.name[0].suffix == ["Esquire", "MBBS"] + * match response.name[0].suffix contains suffix * match parseInt(response.meta.versionId) == originalVersion + 1 - - # 6. Remove the whole suffix array - # ================================ - # And you can get rid of the whole array of suffixes + + # 2. Remove one of the suffixes we just added + # =========================================== + # We added an array of suffixes; now we're going to remove one of the suffixes in the + # array. + * path 'Patient', nhsNumber + * method get + * status 200 + * def patientObject = response * def originalVersion = parseInt(response.meta.versionId) - + * def firstNameIndexWithSuffix = response.name.findIndex(x => x.suffix != null) + * def namePath = "/name/"+ firstNameIndexWithSuffix + * def nameId = response.name.find(x => x.suffix != null).id + * configure headers = call read('classpath:auth/auth-headers.js') * header Content-Type = "application/json-patch+json" - * header If-Match = karate.response.header('etag') + * header If-Match = karate.response.header('etag') * path 'Patient', nhsNumber * request """ {"patches":[ - { "op": "test", "path": "/name/0/id", "value": "#(patientObject.name[0].id)" }, - { "op": "remove", "path": "/name/0/suffix" } + { "op": "test", "path": "#(namePath)/id", "value": "#(nameId)" }, + { "op": "remove","path": "#(namePath)/suffix/0" } ]} - """ + """ * method patch * status 200 - * match response.name[0].suffix == '#notpresent' * match parseInt(response.meta.versionId) == originalVersion + 1 From 75ac33757e2aa8d9783e948c460038c1c0171ed0 Mon Sep 17 00:00:00 2001 From: agelledi Date: Mon, 11 Nov 2024 12:30:12 +0000 Subject: [PATCH 2/6] removed unused variables --- .../updatePatientDetails/addAndRemove.feature | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/karate-tests/src/test/java/patients/healthcareWorker/updatePatientDetails/addAndRemove.feature b/karate-tests/src/test/java/patients/healthcareWorker/updatePatientDetails/addAndRemove.feature index 07db85e68..11858b503 100644 --- a/karate-tests/src/test/java/patients/healthcareWorker/updatePatientDetails/addAndRemove.feature +++ b/karate-tests/src/test/java/patients/healthcareWorker/updatePatientDetails/addAndRemove.feature @@ -20,7 +20,6 @@ Feature: Patch patient - Add and remove data * method get * status 200 * def originalVersion = parseInt(response.meta.versionId) - * def originalEtag = karate.response.header('etag') # 1. Add a new name to the array of patient names # =============================================== @@ -65,7 +64,6 @@ Feature: Patch patient - Add and remove data * copy originalNameArray = response.name * def originalVersion = parseInt(response.meta.versionId) * def nameID = response.name[1].id - * def etag = karate.response.header('etag') # 2.1. You can't call a "remove" operation without first calling a "test" operation * def diagnostics = "Invalid update with error - removal '/name/1' is not immediately preceded by equivalent test - instead it is the first item" @@ -73,7 +71,7 @@ Feature: Patch patient - Add and remove data * configure headers = call read('classpath:auth/auth-headers.js') * header Content-Type = "application/json-patch+json" - * header If-Match = etag + * header If-Match = karate.response.header('etag') * path 'Patient', nhsNumber * request {"patches":[{"op":"remove","path":"/name/1"}]} * method patch @@ -132,7 +130,6 @@ Feature: Patch patient - Add and remove data * path 'Patient', nhsNumber * method get * status 200 - * def patientObject = response * def originalVersion = parseInt(response.meta.versionId) * def firstNameIndexWithSuffix = response.name.findIndex(x => x.suffix != null) * def namePath = "/name/"+ firstNameIndexWithSuffix @@ -162,13 +159,11 @@ Feature: Patch patient - Add and remove data * path 'Patient', nhsNumber * method get * status 200 - * def patientObject = response * def originalVersion = parseInt(response.meta.versionId) * def firstNameIndexWithSuffix = response.name.findIndex(x => x.suffix != null) * def namePath = "/name/"+ firstNameIndexWithSuffix * def nameId = response.name.find(x => x.suffix != null).id * def suffix = "Esquire" - * print firstNameIndexWithSuffix, nameId * configure headers = call read('classpath:auth/auth-headers.js') * header Content-Type = "application/json-patch+json" @@ -193,7 +188,6 @@ Feature: Patch patient - Add and remove data * path 'Patient', nhsNumber * method get * status 200 - * def patientObject = response * def originalVersion = parseInt(response.meta.versionId) * def firstNameIndexWithSuffix = response.name.findIndex(x => x.suffix != null) * def namePath = "/name/"+ firstNameIndexWithSuffix From bd60c6b5782014ab97ad6440c69b70d14a0c67df Mon Sep 17 00:00:00 2001 From: agelledi Date: Mon, 11 Nov 2024 14:29:33 +0000 Subject: [PATCH 3/6] fixed pipeline failures --- .../updatePatientDetails/addAndRemove.feature | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/karate-tests/src/test/java/patients/healthcareWorker/updatePatientDetails/addAndRemove.feature b/karate-tests/src/test/java/patients/healthcareWorker/updatePatientDetails/addAndRemove.feature index 11858b503..61a3e4864 100644 --- a/karate-tests/src/test/java/patients/healthcareWorker/updatePatientDetails/addAndRemove.feature +++ b/karate-tests/src/test/java/patients/healthcareWorker/updatePatientDetails/addAndRemove.feature @@ -13,7 +13,7 @@ Feature: Patch patient - Add and remove data * configure headers = call read('classpath:auth/auth-headers.js') * url baseURL - + Scenario: Add and remove patient data * def nhsNumber = '5900056449' * path 'Patient', nhsNumber @@ -61,9 +61,6 @@ Feature: Patch patient - Add and remove data * path 'Patient', nhsNumber * method get * status 200 - * copy originalNameArray = response.name - * def originalVersion = parseInt(response.meta.versionId) - * def nameID = response.name[1].id # 2.1. You can't call a "remove" operation without first calling a "test" operation * def diagnostics = "Invalid update with error - removal '/name/1' is not immediately preceded by equivalent test - instead it is the first item" @@ -80,6 +77,11 @@ Feature: Patch patient - Add and remove data # 2.2. How to remove the name object correctly - define the id of the object # you want to remove in the "test" operation + * path 'Patient', nhsNumber + * method get + * status 200 + * def originalVersion = parseInt(response.meta.versionId) + * def nameID = response.name[1].id * def patchBody = """ {"patches":[ @@ -89,7 +91,7 @@ Feature: Patch patient - Add and remove data """ * configure headers = call read('classpath:auth/auth-headers.js') * header Content-Type = "application/json-patch+json" - * header If-Match = etag + * header If-Match = karate.response.header('etag') * path 'Patient', nhsNumber * request patchBody * method patch @@ -131,9 +133,7 @@ Feature: Patch patient - Add and remove data * method get * status 200 * def originalVersion = parseInt(response.meta.versionId) - * def firstNameIndexWithSuffix = response.name.findIndex(x => x.suffix != null) - * def namePath = "/name/"+ firstNameIndexWithSuffix - * def nameId = response.name.find(x => x.suffix != null).id + * def patientObject = response * configure headers = call read('classpath:auth/auth-headers.js') * header Content-Type = "application/json-patch+json" @@ -142,15 +142,15 @@ Feature: Patch patient - Add and remove data * request """ {"patches":[ - { "op": "test", "path": "#(namePath)/id", "value": "#(nameId)" }, - { "op": "remove", "path": "#(namePath)/suffix" } + { "op": "test", "path": "/name/0/id", "value": "#(patientObject.name[0].id)" }, + { "op": "remove", "path": "/name/0/suffix" } ]} """ * method patch * status 200 * match response.name[0].suffix == '#notpresent' * match parseInt(response.meta.versionId) == originalVersion + 1 - + Scenario: Add suffix to the existing array of suffixes and then remove the same # 1. Add new suffix to the array # ============================== @@ -161,7 +161,7 @@ Feature: Patch patient - Add and remove data * status 200 * def originalVersion = parseInt(response.meta.versionId) * def firstNameIndexWithSuffix = response.name.findIndex(x => x.suffix != null) - * def namePath = "/name/"+ firstNameIndexWithSuffix + * def namePath = "/name/"+ firstNameIndexWithSuffix + "/id" * def nameId = response.name.find(x => x.suffix != null).id * def suffix = "Esquire" @@ -172,7 +172,7 @@ Feature: Patch patient - Add and remove data * request """ {"patches":[ - { "op": "add", "path": "#(namePath)/id", "value": "#(nameId))" }, + { "op": "add", "path": "#(namePath)", "value": "#(nameId)" }, { "op": "add", "path": "/name/0/suffix/0", "value": "#(suffix)" } ]} """ @@ -190,8 +190,9 @@ Feature: Patch patient - Add and remove data * status 200 * def originalVersion = parseInt(response.meta.versionId) * def firstNameIndexWithSuffix = response.name.findIndex(x => x.suffix != null) - * def namePath = "/name/"+ firstNameIndexWithSuffix + * def namePath = "/name/"+ firstNameIndexWithSuffix + "/id" * def nameId = response.name.find(x => x.suffix != null).id + * def suffixPath = "/name/"+ firstNameIndexWithSuffix + "/suffix/0" * configure headers = call read('classpath:auth/auth-headers.js') * header Content-Type = "application/json-patch+json" @@ -200,8 +201,8 @@ Feature: Patch patient - Add and remove data * request """ {"patches":[ - { "op": "test", "path": "#(namePath)/id", "value": "#(nameId)" }, - { "op": "remove","path": "#(namePath)/suffix/0" } + { "op": "test", "path": "#(namePath)", "value": "#(nameId)" }, + { "op": "remove","path": "#(suffixPath)" } ]} """ * method patch @@ -262,4 +263,3 @@ Feature: Patch patient - Add and remove data * status 200 * match parseInt(response.meta.versionId) == parseInt(idAftPod)+ 1 * match response.extension[1] == '#notpresent' - From 888f0bb65629a1ee9ef47ef6d7a39fc9e4cd4523 Mon Sep 17 00:00:00 2001 From: agelledi Date: Mon, 11 Nov 2024 16:37:40 +0000 Subject: [PATCH 4/6] marked test as sandbox --- .../healthcareWorker/updatePatientDetails/addAndRemove.feature | 2 ++ 1 file changed, 2 insertions(+) diff --git a/karate-tests/src/test/java/patients/healthcareWorker/updatePatientDetails/addAndRemove.feature b/karate-tests/src/test/java/patients/healthcareWorker/updatePatientDetails/addAndRemove.feature index 61a3e4864..e8a19ddc7 100644 --- a/karate-tests/src/test/java/patients/healthcareWorker/updatePatientDetails/addAndRemove.feature +++ b/karate-tests/src/test/java/patients/healthcareWorker/updatePatientDetails/addAndRemove.feature @@ -14,6 +14,7 @@ Feature: Patch patient - Add and remove data * url baseURL + @sandbox Scenario: Add and remove patient data * def nhsNumber = '5900056449' * path 'Patient', nhsNumber @@ -151,6 +152,7 @@ Feature: Patch patient - Add and remove data * match response.name[0].suffix == '#notpresent' * match parseInt(response.meta.versionId) == originalVersion + 1 + @sandbox Scenario: Add suffix to the existing array of suffixes and then remove the same # 1. Add new suffix to the array # ============================== From bdebcb8c3b27d86be5298618446cd686c1a1a5b9 Mon Sep 17 00:00:00 2001 From: agelledi Date: Tue, 12 Nov 2024 11:07:46 +0000 Subject: [PATCH 5/6] removed sandbox stateful behaviour --- .../test/java/mocks/sandbox/post-patient.js | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/karate-tests/src/test/java/mocks/sandbox/post-patient.js b/karate-tests/src/test/java/mocks/sandbox/post-patient.js index 03d6cc504..78e6defbb 100644 --- a/karate-tests/src/test/java/mocks/sandbox/post-patient.js +++ b/karate-tests/src/test/java/mocks/sandbox/post-patient.js @@ -1,5 +1,5 @@ /* karate objects */ -/* global context, request, response, session */ +/* global context, request, response */ /* functions defined in supporting-functions.js */ /* global basicResponseHeaders */ @@ -9,14 +9,14 @@ * to pick from when we need to create a new patient. When the array is exhausted, the mock server * should reset itself to its initial state, removing all creates and updates. */ -const VALID_NHS_NUMBERS = [ - '5182663366', '5306479413', '5865618296', '5596570559', '5061511085', - '5954974977', '5157195761', '5897052085', '5359513144', '5446520122', - '5103506718', '5468649624', '5002272274', '5941993854', '5574773538', - '5899264950', '5604719625', '5117676297', '5705279671', '5890418181' -] +// const VALID_NHS_NUMBERS = [ +// '5182663366', '5306479413', '5865618296', '5596570559', '5061511085', +// '5954974977', '5157195761', '5897052085', '5359513144', '5446520122', +// '5103506718', '5468649624', '5002272274', '5941993854', '5574773538', +// '5899264950', '5604719625', '5117676297', '5705279671', '5890418181' +// ] -session.nhsNumberIndex = session.nhsNumberIndex || 0 +// session.nhsNumberIndex = session.nhsNumberIndex || 0 function generateObjectId () { // generates a random ID for the name and address objects, e.g. 8F1A21BC @@ -144,9 +144,12 @@ function initializePatientData (request) { const patient = JSON.parse(JSON.stringify(NEW_PATIENT)) // set a new NHS number for the patient - patient.id = VALID_NHS_NUMBERS[session.nhsNumberIndex] - patient.identifier[0].value = VALID_NHS_NUMBERS[session.nhsNumberIndex] - session.nhsNumberIndex += 1 + // patient.id = VALID_NHS_NUMBERS[session.nhsNumberIndex] + // patient.identifier[0].value = VALID_NHS_NUMBERS[session.nhsNumberIndex] + // session.nhsNumberIndex += 1 + + patient.id = '5182663366' + patient.identifier[0].value = '5182663366' // name and address objects need an ID patient.name[0] = request.body.name[0] From d09e9c1a60715f2e78f49873ccd3596f99e5a466 Mon Sep 17 00:00:00 2001 From: agelledi Date: Tue, 12 Nov 2024 11:38:05 +0000 Subject: [PATCH 6/6] removed sandbox stateful behaviour --- .../src/test/java/mocks/sandbox/post-patient.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/karate-tests/src/test/java/mocks/sandbox/post-patient.js b/karate-tests/src/test/java/mocks/sandbox/post-patient.js index 78e6defbb..2d0c23e0d 100644 --- a/karate-tests/src/test/java/mocks/sandbox/post-patient.js +++ b/karate-tests/src/test/java/mocks/sandbox/post-patient.js @@ -9,14 +9,6 @@ * to pick from when we need to create a new patient. When the array is exhausted, the mock server * should reset itself to its initial state, removing all creates and updates. */ -// const VALID_NHS_NUMBERS = [ -// '5182663366', '5306479413', '5865618296', '5596570559', '5061511085', -// '5954974977', '5157195761', '5897052085', '5359513144', '5446520122', -// '5103506718', '5468649624', '5002272274', '5941993854', '5574773538', -// '5899264950', '5604719625', '5117676297', '5705279671', '5890418181' -// ] - -// session.nhsNumberIndex = session.nhsNumberIndex || 0 function generateObjectId () { // generates a random ID for the name and address objects, e.g. 8F1A21BC @@ -144,9 +136,6 @@ function initializePatientData (request) { const patient = JSON.parse(JSON.stringify(NEW_PATIENT)) // set a new NHS number for the patient - // patient.id = VALID_NHS_NUMBERS[session.nhsNumberIndex] - // patient.identifier[0].value = VALID_NHS_NUMBERS[session.nhsNumberIndex] - // session.nhsNumberIndex += 1 patient.id = '5182663366' patient.identifier[0].value = '5182663366'