Skip to content

Commit

Permalink
change integration test from 2.2 to 2.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
mherman22 committed Jun 22, 2023
1 parent e5b5e29 commit 56206b4
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 134 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public class MedicationFhirResourceProviderIntegrationTest extends BaseFhirR4Int

private static final String MEDICATION_DATA_XML = "org/openmrs/module/fhir2/api/dao/impl/FhirMedicationDaoImplTest_initial_data.xml";

private static final String JSON_MERGE_PATCH_MEDICATION_PATH = "org/openmrs/module/fhir2/providers/Medication_patch.json";

private static final String JSON_PATCH_MEDICATION_PATH = "org/openmrs/module/fhir2/providers/Medication_json_patch.json";

private static final String JSON_CREATE_MEDICATION_DOCUMENT = "org/openmrs/module/fhir2/providers/MedicationWebTest_create.json";

private static final String XML_CREATE_MEDICATION_DOCUMENT = "org/openmrs/module/fhir2/providers/MedicationWebTest_create.xml";
Expand Down Expand Up @@ -85,6 +89,54 @@ public void shouldReturnExistingMedicationAsJson() throws Exception {
assertThat(medication, validResource());
}

@Test
public void shouldPatchExistingMedicationViaJsonMergePatch() throws Exception {
String jsonMedicationPatch;
try (InputStream is = this.getClass().getClassLoader().getResourceAsStream(JSON_MERGE_PATCH_MEDICATION_PATH)) {
Objects.requireNonNull(is);
jsonMedicationPatch = inputStreamToString(is, UTF_8);
}

MockHttpServletResponse response = patch("/Medication/" + MEDICATION_UUID).jsonMergePatch(jsonMedicationPatch)
.accept(FhirMediaTypes.JSON).go();

assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
assertThat(response.getContentAsString(), notNullValue());

Medication medication = readResponse(response);

assertThat(medication, notNullValue());
assertThat(medication.getIdElement().getIdPart(), equalTo(MEDICATION_UUID));
assertThat(medication, validResource());

assertThat(medication.getStatus(), is(Medication.MedicationStatus.ACTIVE));
}

@Test
public void shouldPatchExistingMedicationViaJsonPatch() throws Exception {
String jsonMedicationPatch;
try (InputStream is = this.getClass().getClassLoader().getResourceAsStream(JSON_PATCH_MEDICATION_PATH)) {
Objects.requireNonNull(is);
jsonMedicationPatch = inputStreamToString(is, UTF_8);
}

MockHttpServletResponse response = patch("/Medication/" + MEDICATION_UUID).jsonPatch(jsonMedicationPatch)
.accept(FhirMediaTypes.JSON).go();

assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
assertThat(response.getContentAsString(), notNullValue());

Medication medication = readResponse(response);

assertThat(medication, notNullValue());
assertThat(medication.getIdElement().getIdPart(), equalTo(MEDICATION_UUID));
assertThat(medication, validResource());

assertThat(medication.getStatus(), is(Medication.MedicationStatus.ACTIVE));
}

@Test
public void shouldThrow404ForNonExistingMedicationAsJson() throws Exception {
MockHttpServletResponse response = get("/Medication/" + WRONG_MEDICATION_UUID)
Expand Down

This file was deleted.

0 comments on commit 56206b4

Please sign in to comment.