diff --git a/src/test/java/org/openmrs/performance/http/DoctorHttpService.java b/src/test/java/org/openmrs/performance/http/DoctorHttpService.java index e2ed17a..381d17f 100644 --- a/src/test/java/org/openmrs/performance/http/DoctorHttpService.java +++ b/src/test/java/org/openmrs/performance/http/DoctorHttpService.java @@ -16,6 +16,8 @@ import static io.gatling.javaapi.core.CoreDsl.StringBody; import static io.gatling.javaapi.core.CoreDsl.bodyString; import static io.gatling.javaapi.core.CoreDsl.jsonPath; +import static io.gatling.javaapi.http.HttpDsl.RawFileBodyPart; +import static io.gatling.javaapi.http.HttpDsl.StringBodyPart; import static io.gatling.javaapi.http.HttpDsl.http; import static org.openmrs.performance.Constants.ALLERGY_REACTION_UUID; import static org.openmrs.performance.Constants.ARTERIAL_BLOOD_OXYGEN_SATURATION; @@ -230,6 +232,19 @@ public HttpRequestActionBuilder getAllowedFileExtensions() { .get("/openmrs/ws/rest/v1/systemsetting?&v=custom:(value)&q=attachments.allowedFileExtensions"); } + public HttpRequestActionBuilder uploadAttachment(String patientUuid) { + return http("Upload Attachment Request") + .post("/openmrs/ws/rest/v1/attachment") + .bodyPart(StringBodyPart("fileCaption", "Test Image")) + .bodyPart(StringBodyPart("patient", patientUuid)) + .bodyPart( + RawFileBodyPart("file", "Sample_1MB_image.jpg") + .contentType("image/jpg") + .fileName("Sample_1MB_image.jpg") + ) + .asMultipartForm(); + } + public HttpRequestActionBuilder getLabResults(String patientUuid) { return http("Get Lab Results of Patient") .get("/openmrs/ws/fhir2/R4/Observation?category=laboratory&patient=" + patientUuid + "&_count=100&_summary=data") diff --git a/src/test/java/org/openmrs/performance/registries/DoctorRegistry.java b/src/test/java/org/openmrs/performance/registries/DoctorRegistry.java index 33edd55..027ef25 100644 --- a/src/test/java/org/openmrs/performance/registries/DoctorRegistry.java +++ b/src/test/java/org/openmrs/performance/registries/DoctorRegistry.java @@ -135,6 +135,11 @@ public ChainBuilder openAttachmentsTab(String patientUuid) { .exec(httpService.getAllowedFileExtensions()); } + public ChainBuilder addAttachment(String patientUuid){ + return exec(httpService.uploadAttachment(patientUuid)) + .exec(httpService.getAttachments(patientUuid)); + } + public ChainBuilder openVisitsTab(String patientUuid) { return exec(httpService.getVisitsOfPatient(patientUuid)); } diff --git a/src/test/java/org/openmrs/performance/scenarios/VisitPatientScenario.java b/src/test/java/org/openmrs/performance/scenarios/VisitPatientScenario.java index 1e56c98..71f4ba5 100644 --- a/src/test/java/org/openmrs/performance/scenarios/VisitPatientScenario.java +++ b/src/test/java/org/openmrs/performance/scenarios/VisitPatientScenario.java @@ -50,6 +50,8 @@ public ScenarioBuilder getScenarioBuilder() { .pause(5) .exec(registry.openAttachmentsTab("#{patient_uuid}")) .pause(5) + .exec(registry.addAttachment("#{patient_uuid}")) + .pause(5) .exec(registry.addDrugOrder("#{patient_uuid}", "#{visitUuid}", "#{currentUserUuid}")) .pause(5) .exec(registry.addVisitNote("#{patient_uuid}", "#{currentUserUuid}")) diff --git a/src/test/resources/Sample_1MB_image.jpg b/src/test/resources/Sample_1MB_image.jpg new file mode 100644 index 0000000..c886692 Binary files /dev/null and b/src/test/resources/Sample_1MB_image.jpg differ