Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 51dee987 authored by Alexandre Pocinho's avatar Alexandre Pocinho
Browse files

Correct http code for DELETE

parent 65ea77d5
No related branches found
No related tags found
3 merge requests!10Remove hardcoded mandatory targetSytem + upgrade HAPI FHIR version,!9Implements ITI-104 transaction + external validation,!8Implements ITI-104 features with external validation process
......@@ -168,7 +168,7 @@ public class IhePatientResourceProvider implements IResourceProvider {
EntityIdentifier deleted = patientRegistryFeedClient.delete(identifier);
MethodOutcome methodOutcome = new MethodOutcome();
int responseStatusCode = deleted == null || deleted.getValue() == null || deleted.getValue().isBlank()
? 404
? 204
: 200;
methodOutcome.setResponseStatusCode(responseStatusCode);
return methodOutcome;
......
......@@ -39,7 +39,7 @@ class IhePatientResourceProviderTest {
private static ConfigurationAdapter configuration;
private static IhePatientResourceProvider provider;
private static final HttpServletRequest iti104Request = createHttpServletRequest("src/test/resources/http_request_iti104.http");
static final String patientString = convertReaderIntoString(iti104Request);
static final String patientString = convertReaderIntoString(iti104Request);
private static final HttpServletRequest iti83GetRequest = createHttpServletRequest("src/test/resources/http_request_get_iti83.http");
......@@ -157,54 +157,54 @@ class IhePatientResourceProviderTest {
assertEquals("PatientIsUpdated", patientReturned.getId());
}
@Test
void testUpdatePatientWithPatientFeedException() {
//Given
Patient patient = provider.createFhirResourceFromString(Patient.class, patientString);
String theConditional = "Patient?identifier=system%7C00001";
@Test
void testUpdatePatientWithPatientFeedException() {
//Given
Patient patient = provider.createFhirResourceFromString(Patient.class, patientString);
String theConditional = "Patient?identifier=system%7C00001";
//When
try {
//When
provider.update(null, theConditional, patient, iti104Request);
} catch (UnprocessableEntityException e) {
//Then
assertEquals(IhePatientResourceProvider.PATIENT_FEED_CLIENT_IS_NOT_SET, e.getMessage());
} catch (Exception e) {
fail(UNPROCESSABLE_ENTITY_EXCEPTION_HAS_TO_BE_THROWN);
}
}
@Test
void testUpdatePatientWithConversionException() {
//Given
Patient patient = provider.createFhirResourceFromString(Patient.class, patientString);
String theConditional = "Patient?identifier=system%7CConversionException";
try {
//When
try {
//When
provider.update(null, theConditional, patient, iti104Request);
} catch (UnprocessableEntityException e) {
//Then
assertEquals(IhePatientResourceProvider.PATIENT_FEED_CLIENT_IS_NOT_SET, e.getMessage());
} catch (Exception e) {
fail(UNPROCESSABLE_ENTITY_EXCEPTION_HAS_TO_BE_THROWN);
}
provider.update(null, theConditional, patient, iti104Request);
} catch (UnprocessableEntityException e) {
//Then
assertEquals(IhePatientResourceProvider.FHIR_PATIENT_COULD_NOT_BE_CONVERTED_TO_REGISTRY_PATIENT, e.getMessage());
} catch (Exception e) {
fail(UNPROCESSABLE_ENTITY_EXCEPTION_HAS_TO_BE_THROWN);
}
}
@Test
void testUpdatePatientWithConversionException() {
//Given
Patient patient = provider.createFhirResourceFromString(Patient.class, patientString);
String theConditional = "Patient?identifier=system%7CConversionException";
try {
//When
provider.update(null, theConditional, patient, iti104Request);
} catch (UnprocessableEntityException e) {
//Then
assertEquals(IhePatientResourceProvider.FHIR_PATIENT_COULD_NOT_BE_CONVERTED_TO_REGISTRY_PATIENT, e.getMessage());
} catch (Exception e) {
fail(UNPROCESSABLE_ENTITY_EXCEPTION_HAS_TO_BE_THROWN);
}
}
@Test
void testUpdatePatientWithNullConditional() {
//Given
Patient patient = provider.createFhirResourceFromString(Patient.class, patientString);
try {
//When
provider.update(null, null, patient, iti104Request);
} catch (UnprocessableEntityException e) {
//Then
assertEquals(NO_IDENTIFIER_PROVIDED, e.getMessage());
} catch (Exception e) {
fail(UNPROCESSABLE_ENTITY_EXCEPTION_HAS_TO_BE_THROWN);
}
}
@Test
void testUpdatePatientWithNullConditional() {
//Given
Patient patient = provider.createFhirResourceFromString(Patient.class, patientString);
try {
//When
provider.update(null, null, patient, iti104Request);
} catch (UnprocessableEntityException e) {
//Then
assertEquals(NO_IDENTIFIER_PROVIDED, e.getMessage());
} catch (Exception e) {
fail(UNPROCESSABLE_ENTITY_EXCEPTION_HAS_TO_BE_THROWN);
}
}
@Test
void testReadOk() {
......@@ -306,7 +306,7 @@ class IhePatientResourceProviderTest {
//When
MethodOutcome mo = provider.delete(id, theConditional, iti104Request);
//Then
assertEquals(404, mo.getResponseStatusCode());
assertEquals(204, mo.getResponseStatusCode());
}
@Test
......@@ -439,7 +439,6 @@ class IhePatientResourceProviderTest {
}
////////////////////////////////////////////////////////////////
// Methods used privately in the exclusive usage of Test Class //
////////////////////////////////////////////////////////////////
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment