Mentions légales du service

Skip to content
Snippets Groups Projects
Commit c1a1d24e authored by pm's avatar pm
Browse files

First few UTs for next tickets

parent 02f619f8
No related branches found
No related tags found
2 merge requests!5Release/2.0.0,!4Pixm
......@@ -14,6 +14,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
import net.ihe.gazelle.adapter.preferences.Preferences;
import net.ihe.gazelle.app.patientregistryapi.application.PatientFeedException;
import net.ihe.gazelle.app.patientregistryapi.business.EntityIdentifier;
import net.ihe.gazelle.app.patientregistryfeedclient.adapter.PatientFeedClient;
import net.ihe.gazelle.framework.loggerservice.application.GazelleLogger;
import net.ihe.gazelle.framework.loggerservice.application.GazelleLoggerFactory;
......@@ -62,6 +63,56 @@ public class PatientRegistryFeedClient {
this.client = client;
}
/**
* Method called to update a Patient in the PAtient Registry Database.
* @param patient : the Patient object we want to insert in DB
* @param uuid : The uuid of the patient corresponding to it in DB
* @return a String corresponding to the uuid confirming the transaction has been successful.
*/
public String mergePatient(EntityIdentifier patientToOverride, EntityIdentifier newPatient) {
//Prepare entry parameters before calling the feed client
//Call patient Registry update Method and retrieve uuid
try {
// client.updatePatient(patientToOverride, newPatient);
} catch (PatientFeedException e) {
logger.error("pouet pouet ciboulette");
//Map errors
}
return responseUuid;
}
/**
* Method called to update a Patient in the PAtient Registry Database.
* @param patient : the Patient object we want to insert in DB
* @param uuid : The uuid of the patient corresponding to it in DB
* @return a String corresponding to the uuid confirming the transaction has been successful.
*/
public String updatePatient(net.ihe.gazelle.app.patientregistryapi.business.Patient patient, String uuid) {
String responseUuid = uuid;
//Prepare entry parameters before calling the feed client
EntityIdentifier entityIdentifier = new EntityIdentifier();
//Call patient Registry update Method and retrive uuid
try {
client.updatePatient(patient, entityIdentifier);
} catch (PatientFeedException e) {
logger.error("pouet pouet ciboulette");
//Map errors
}
return responseUuid;
}
/**
* Method called to create a Patient in the Patient Registry Database
......
......@@ -361,6 +361,54 @@ public class PatientFeedClientTest {
assertEquals("", e.getMessage());
}
}
@Test
@Description("Test on update, when feeding basic request")
@Severity(SeverityLevel.CRITICAL)
@Story("update")
void TestFeedUpdateNominalCase() throws PreferenceException, NamespaceException, PatientFeedException {
String uuid = TEST_UUID;
Patient patient = createPatient("","",LocalDate.of(1990, 06, 19), GenderCode.MALE);
patientRegistryFeedClient = new PatientRegistryFeedClient();
patientRegistryFeedClient.setClient(patientFeedClientMock);
Mockito.doReturn(TEST_UUID).when(patientFeedClientMock).updatePatient(anyObject());
assertEquals(TEST_UUID, patientRegistryFeedClient.updatePatient(patient, uuid));
}
@Test
@Description("Test on update, exception thrown when no Patient is given")
@Severity(SeverityLevel.CRITICAL)
@Story("update")
void TestFeedUpdateNullPatient() throws PreferenceException, NamespaceException, PatientFeedException {
String uuid = TEST_UUID;
patientRegistryFeedClient = new PatientRegistryFeedClient();
patientRegistryFeedClient.setClient(patientFeedClientMock);
assertThrows(InvalidRequestException.class, () -> patientRegistryFeedClient.updatePatient(null, uuid));
}
@Test
@Description("Test on update, exception thrown when no Uuid is given")
@Severity(SeverityLevel.CRITICAL)
@Story("update")
void TestFeedUpdateNullUuid() throws PreferenceException, NamespaceException, PatientFeedException {
Patient patient = createPatient("","",LocalDate.of(1990, 06, 19), GenderCode.MALE);
patientRegistryFeedClient = new PatientRegistryFeedClient();
patientRegistryFeedClient.setClient(patientFeedClientMock);
assertThrows(InvalidRequestException.class, () -> patientRegistryFeedClient.updatePatient(patient, null));
}
private Patient createPatient(String familyName, String givenName, LocalDate birthDate, GenderCode gender) {
......
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