Commit 99d09df5 authored by Alexandre Pocinho's avatar Alexandre Pocinho
Browse files

Work on PATREG-199 adding Allure Annotation and modifying GITB TEst

parent 72c2fd69
Pipeline #274571 failed with stages
in 11 minutes and 59 seconds
......@@ -37,12 +37,11 @@ public class PatientFeedProcessingService {
/**
* Process the Patient Feed request.
*
* @param processRequest : GITB request received.
* @return ProcessResponse corresponding to the received request
*/
public ProcessResponse processPatientCreate(ProcessRequest processRequest) {
String uuidOfFedPatient;
String uuidOfCreatedPatient;
List<AnyContent> patientToFeed = processRequest.getInput();
if (patientToFeed.size() != 1) {
throw new IllegalArgumentException("ProcessRequest.input shall contain one and only one patient !");
......@@ -51,8 +50,8 @@ public class PatientFeedProcessingService {
PatientProcessingWebserviceConstants.PATIENT_INPUT_NAME, PatientProcessingWebserviceConstants.PATIENT_CREATE_OPERATION));
}
try {
uuidOfFedPatient = patientFeedService.createPatient(mapper.getObject(patientToFeed.get(0), Patient.class));
return createPatientFeedProcessResponse(uuidOfFedPatient);
uuidOfCreatedPatient = patientFeedService.createPatient(mapper.getObject(patientToFeed.get(0), Patient.class));
return createPatientCreatedOrMergeProcessResponse(uuidOfCreatedPatient);
} catch (MappingException e) {
throw new IllegalArgumentException("Cannot decode Request inputs as Patients !");
} catch (PatientFeedException e) {
......@@ -60,9 +59,8 @@ public class PatientFeedProcessingService {
}
}
/** TODO
/**
* Process the Patient Update request.
*
* @param processRequest : GITB request received.
* @return ProcessResponse corresponding to the received request
*/
......@@ -85,8 +83,8 @@ public class PatientFeedProcessingService {
}
}
/** TODO
*
/**
* Process the Patient Merge Request
* @param processRequest : GITB request received
* @return ProcessResponse corresponding to the received request
*/
......@@ -101,7 +99,7 @@ public class PatientFeedProcessingService {
}
try {
originalPatientUUID = patientFeedService.mergePatient(mapper.getObject(patientToFeed.get(0), String.class),mapper.getObject(patientToFeed.get(1), String.class));
return createPatientFeedProcessResponse(originalPatientUUID);
return createPatientCreatedOrMergeProcessResponse(originalPatientUUID);
} catch (MappingException e) {
throw new IllegalArgumentException("Cannot decode Request inputs as UUIDs !");
} catch (PatientFeedException e) {
......@@ -109,8 +107,8 @@ public class PatientFeedProcessingService {
}
}
/** TODO define method
*
/**
* Process the Patient Delete Request
* @param processRequest : GITB request received
* @return ProcessResponse corresponding to the received request
*/
......@@ -136,13 +134,13 @@ public class PatientFeedProcessingService {
/**
* Create a {@link ProcessResponse} to a {@link ProcessRequest} sent to this service after a successful processing.
* The response will contain a {@link TAR} report containing the result Status for the processing operation,
* as well as a single Output containing the UUID assigned to the merged patient.
* as well as a single Output containing the UUID assigned to the created OR merged patient.
*
* @param uuid : UUID assigned to the merged Patient, null can be used if the operation fails. No output will appear in the response.
* @param uuid : UUID assigned to the created OR merged Patient, null can be used if the operation fails. No output will appear in the response.
* @return the process response to return to the WebService
* @throws PatientFeedException when response output cannot be mapped to AnyContent
*/
private ProcessResponse createPatientFeedProcessResponse(String uuid) throws PatientFeedException {
private ProcessResponse createPatientCreatedOrMergeProcessResponse(String uuid) throws PatientFeedException {
ProcessResponse processResponse = new ProcessResponse();
if (uuid == null) {
throw new IllegalArgumentException("Successful operation shall return a valued UUID as an output !");
......@@ -161,7 +159,7 @@ public class PatientFeedProcessingService {
/**
* Create a {@link ProcessResponse} to a {@link ProcessRequest} sent to this service after a successful processing.
* The response will contain a {@link TAR} report containing the result Status for the processing operation,
* as well as a single Output containing the UUID assigned to the merged patient.
* as well as a single Output containing the UUID assigned to the updated patient.
*
* @param patientToReturn : Patient assigned to the original Patient, null can be used if the operation fails. No output will appear in the response.
* @return the process response to return to the WebService
......
......@@ -7,6 +7,7 @@ import com.gitb.ps.ProcessResponse;
import com.gitb.tr.BAR;
import com.gitb.tr.TestResultType;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import net.ihe.gazelle.app.patientregistryapi.adapter.ws.PatientProcessingWebserviceConstants;
import net.ihe.gazelle.app.patientregistryapi.business.Patient;
import net.ihe.gazelle.app.patientregistryapi.business.PersonName;
......@@ -22,6 +23,7 @@ import static org.junit.jupiter.api.Assertions.*;
/**
* Test Feed processing service
*/
@Feature("GITB Feed Webservices")
public class PatientFeedProcessingServiceTest {
private PatientFeedProcessingService patientFeedProcessingService;
......@@ -37,11 +39,13 @@ public class PatientFeedProcessingServiceTest {
}
/**
* Test Processing a patient feed, nominal case.
* Test Processing a patient create, nominal case.
*/
@Test
@Covers(requirements = {"PATREG-30","PATREG-36","PATREG-37","PATREG-39"})
public void process() {
@Description("Creation of a patient in Nominal Case")
public void processCreate() {
testPatientFeedServiceImpl.setFeedResult(TestPatientFeedServiceImpl.FeedResult.OK);
Patient patient = new Patient();
PersonName personName = new PersonName();
personName.setFamily("Bars");
......@@ -74,12 +78,10 @@ public class PatientFeedProcessingServiceTest {
*/
@Test
@Covers(requirements = {"PATREG-35","PATREG-38","PATREG-39"})
public void process_with_exception() {
@Description("Creation of a patient with an PatientFeedException")
public void processCreate_with_PatientFeedException_return() {
testPatientFeedServiceImpl.setFeedResult(TestPatientFeedServiceImpl.FeedResult.KO);
Patient patient = new Patient();
PersonName personName = new PersonName();
personName.setFamily("Bars");
patient.addName(personName);
ProcessRequest processRequest = new ProcessRequest();
processRequest.setOperation(PatientProcessingWebserviceConstants.PATIENT_CREATE_OPERATION);
......@@ -107,12 +109,10 @@ public class PatientFeedProcessingServiceTest {
*/
@Test
@Covers(requirements = {"PATREG-31"})
@Description("Creation of a patient with an null return")
public void process_with_null_return() {
testPatientFeedServiceImpl.setFeedResult(TestPatientFeedServiceImpl.FeedResult.NULL);
Patient patient = new Patient();
PersonName personName = new PersonName();
personName.setFamily("Bars");
patient.addName(personName);
ProcessRequest processRequest = new ProcessRequest();
processRequest.setOperation(PatientProcessingWebserviceConstants.PATIENT_CREATE_OPERATION);
......@@ -122,7 +122,6 @@ public class PatientFeedProcessingServiceTest {
} catch (MappingException e){
fail("No exception is supposed to be thrown when transforming test patient to AnyContent !", e);
}
assertThrows(IllegalArgumentException.class, () -> patientFeedProcessingService.processPatientCreate(processRequest));
}
......@@ -131,6 +130,7 @@ public class PatientFeedProcessingServiceTest {
*/
@Test
@Covers(requirements = {"PATREG-32","PATREG-33"})
@Description("Creation of a patient with a STRING object instead of Patient object")
public void process_Incorrect_Patient() {
AnyContent anyContent = new AnyContent();
anyContent.setName("Test");
......@@ -148,6 +148,7 @@ public class PatientFeedProcessingServiceTest {
*/
@Test
@Covers(requirements = {"PATREG-33","PATREG-34"})
@Description("Creation of a patient with no input on the start of the process")
public void process_no_input() {
ProcessRequest processRequest = new ProcessRequest();
processRequest.setOperation(PatientProcessingWebserviceConstants.PATIENT_CREATE_OPERATION);
......@@ -158,10 +159,10 @@ public class PatientFeedProcessingServiceTest {
/**
* Test Processing a patient update, nominal case.
*/
//TO SEE WITH FDE
@Test
@Description("")
@Description("Updating Patient in Nominal/OK Case")
public void processUpdate() {
testPatientFeedServiceImpl.setFeedResult(TestPatientFeedServiceImpl.FeedResult.OK);
Patient patient = new Patient();
PersonName personName = new PersonName();
personName.setFamily("Joestar");
......@@ -178,14 +179,12 @@ public class PatientFeedProcessingServiceTest {
ProcessResponse processResponse = patientFeedProcessingService.processPatientUpdate(processRequest);
assertNotNull(processResponse, "ProcessResponse shall not be null !");
assertEquals(1, processResponse.getOutput().size(), "Response shall contain a unique output which is the value of the" +
" UUID assigned to the fed patient.");
//SEE WITH FDE change back to excepted Patient
assertEquals(1, processResponse.getOutput().size(), "Response shall contain a unique output which is all the values " +
" assigned to the updated patient.");
assertEquals("object", processResponse.getOutput().get(0).getType(), "Returned Patient shall be stored in a Patient GITB AnyContent");
assertEquals(PatientProcessingWebserviceConstants.PATIENT_OUTPUT_NAME, processResponse.getOutput().get(0).getName(), "Name of returned GITB AnyContent shall be 'Patient'");
assertEquals(ValueEmbeddingEnumeration.BASE_64, processResponse.getOutput().get(0).getEmbeddingMethod(), "Embedding method of returned " +
"GITB AnyContent shall be 'BASE_64'");
assertNotNull(processResponse.getReport(), "ProcessResponse.report shall not be null !");
assertEquals(TestResultType.SUCCESS, processResponse.getReport().getResult(), "Result of the processing shall be success !");
}
......@@ -194,13 +193,10 @@ public class PatientFeedProcessingServiceTest {
* Test Processing a patient feed, service throwing an exception.
*/
@Test
@Description("")
public void processUpdate_with_exception() {
@Description("Updating Patient in KO Case with a PatientFeedException return")
public void processUpdate_with_PatientFeedException_return() {
testPatientFeedServiceImpl.setFeedResult(TestPatientFeedServiceImpl.FeedResult.KO);
Patient patient = new Patient();
PersonName personName = new PersonName();
personName.setFamily("Joestar");
patient.addName(personName);
ProcessRequest processRequest = new ProcessRequest();
processRequest.setOperation(PatientProcessingWebserviceConstants.PATIENT_UPDATE_OPERATION);
......@@ -226,14 +222,10 @@ public class PatientFeedProcessingServiceTest {
* Test Processing a patient feed, service returning null.
*/
@Test
@Description("")
@Description("Updating Patient in Null Case with a null return")
public void processUpdate_with_null_return() {
testPatientFeedServiceImpl.setFeedResult(TestPatientFeedServiceImpl.FeedResult.NULL);
Patient patient = new Patient();
PersonName personName = new PersonName();
personName.setFamily("Joestar");
patient.addName(personName);
ProcessRequest processRequest = new ProcessRequest();
processRequest.setOperation(PatientProcessingWebserviceConstants.PATIENT_UPDATE_OPERATION);
try {
......@@ -242,7 +234,6 @@ public class PatientFeedProcessingServiceTest {
} catch (MappingException e){
fail("No exception is supposed to be thrown when transforming test patient to AnyContent !", e);
}
assertThrows(IllegalArgumentException.class, () -> patientFeedProcessingService.processPatientUpdate(processRequest));
}
......@@ -250,7 +241,7 @@ public class PatientFeedProcessingServiceTest {
* Test Processing a patient UPDATE, error case using and AnyContent input that is not convertible to a Patient.
*/
@Test
@Description("")
@Description("Updating Patient w/ a String object as input (incorrect Type of object)")
public void process_Incorrect_UpdatedPatient() {
AnyContent anyContent = new AnyContent();
anyContent.setName("Test");
......@@ -267,7 +258,7 @@ public class PatientFeedProcessingServiceTest {
* Test Processing a patient Update, error case using no input in ProcessRequest
*/
@Test
@Description("")
@Description("Updating Patient w/ no inputs")
public void processUpdate_no_input() {
ProcessRequest processRequest = new ProcessRequest();
processRequest.setOperation(PatientProcessingWebserviceConstants.PATIENT_UPDATE_OPERATION);
......@@ -280,20 +271,19 @@ public class PatientFeedProcessingServiceTest {
* Test Processing a patient to merge, nominal case.
*/
@Test
@Description("")
@Description("Merging 2 patients in Nominal/OK Case")
public void processMerge() {
Patient originalPatient = new Patient();
Patient duplicatedPatient = new Patient();
originalPatient.setUuid("123");
duplicatedPatient.setUuid("456");
testPatientFeedServiceImpl.setFeedResult(TestPatientFeedServiceImpl.FeedResult.OK);
String originalPatientUUID = "123";
String duplicatedPatientUUID="456";
ProcessRequest processRequest = new ProcessRequest();
processRequest.setOperation(PatientProcessingWebserviceConstants.PATIENT_MERGE_OPERATION);
try {
processRequest.getInput().add(new MapperObjectToAnyContent().getAnyContent(PatientProcessingWebserviceConstants.UUID_OF_ORIGINAL_PATIENT_INPUT_NAME,
originalPatient.getUuid()));
originalPatientUUID));
processRequest.getInput().add(new MapperObjectToAnyContent().getAnyContent(PatientProcessingWebserviceConstants.UUID_OF_DUPLICATED_PATIENT_INPUT_NAME,
duplicatedPatient.getUuid()));
duplicatedPatientUUID));
} catch (MappingException e){
fail("No exception is supposed to be thrown when transforming test patient to AnyContent !", e);
}
......@@ -315,25 +305,22 @@ public class PatientFeedProcessingServiceTest {
* Test Processing a patient Merge, service throwing an exception.
*/
@Test
@Description("")
public void processMerge_with_exception() {
@Description("Merging 2 patients in KO Case w/ a PatientFeedException")
public void processMerge_with_PatientFeedException() {
testPatientFeedServiceImpl.setFeedResult(TestPatientFeedServiceImpl.FeedResult.KO);
Patient originalPatient = new Patient();
Patient duplicatedPatient = new Patient();
originalPatient.setUuid("123");
duplicatedPatient.setUuid("456");
String originalPatientUUID = "123";
String duplicatedPatientUUID="456";
ProcessRequest processRequest = new ProcessRequest();
processRequest.setOperation(PatientProcessingWebserviceConstants.PATIENT_MERGE_OPERATION);
try {
processRequest.getInput().add(new MapperObjectToAnyContent().getAnyContent(PatientProcessingWebserviceConstants.UUID_OF_ORIGINAL_PATIENT_INPUT_NAME,
originalPatient.getUuid()));
originalPatientUUID));
processRequest.getInput().add(new MapperObjectToAnyContent().getAnyContent(PatientProcessingWebserviceConstants.UUID_OF_DUPLICATED_PATIENT_INPUT_NAME,
duplicatedPatient.getUuid()));
duplicatedPatientUUID));
} catch (MappingException e){
fail("No exception is supposed to be thrown when transforming test patient to AnyContent !", e);
}
ProcessResponse processResponse = patientFeedProcessingService.processPatientMerge(processRequest);
assertNotNull(processResponse, "ProcessResponse shall not be null !");
assertNotNull(processResponse.getReport(), "ProcessResponse.report shall not be null !");
......@@ -344,32 +331,50 @@ public class PatientFeedProcessingServiceTest {
assertNotNull(processResponse.getReport().getReports().getInfoOrWarningOrError().get(0), "Report shall contain error");
assertNotNull(((BAR) processResponse.getReport().getReports().getInfoOrWarningOrError().get(0).getValue()).getDescription(),
"Report shall contain error with valued description !");
}
/**
* Test Processing a patient Merge, service throwing an exception.
*/
@Test
@Description("Merging 2 patients w/ a wrong Content Name")
public void processMerge_with_wrongContentName() {
testPatientFeedServiceImpl.setFeedResult(TestPatientFeedServiceImpl.FeedResult.OK);
String originalPatientUUID = "123";
String duplicatedPatientUUID="456";
ProcessRequest processRequest = new ProcessRequest();
processRequest.setOperation(PatientProcessingWebserviceConstants.PATIENT_MERGE_OPERATION);
try {
processRequest.getInput().add(new MapperObjectToAnyContent().getAnyContent(PatientProcessingWebserviceConstants.UUID_OF_DUPLICATED_PATIENT_INPUT_NAME,
originalPatientUUID));
processRequest.getInput().add(new MapperObjectToAnyContent().getAnyContent(PatientProcessingWebserviceConstants.UUID_OF_ORIGINAL_PATIENT_INPUT_NAME,
duplicatedPatientUUID));
} catch (MappingException e){
fail("No exception is supposed to be thrown when transforming test patient to AnyContent !", e);
}
assertThrows(IllegalArgumentException.class, ()-> patientFeedProcessingService.processPatientMerge(processRequest));
}
/**
* Test Processing a patient merge, service returning null.
*/
@Test
@Description("")
@Description("Merging 2 patients in Null Case w/ a null return")
public void processMerge_with_null_return() {
testPatientFeedServiceImpl.setFeedResult(TestPatientFeedServiceImpl.FeedResult.NULL);
Patient originalPatient = new Patient();
Patient duplicatedPatient = new Patient();
originalPatient.setUuid("123");
duplicatedPatient.setUuid("456");
String originalPatientUUID = "123";
String duplicatedPatientUUID="456";
ProcessRequest processRequest = new ProcessRequest();
processRequest.setOperation(PatientProcessingWebserviceConstants.PATIENT_MERGE_OPERATION);
try {
processRequest.getInput().add(new MapperObjectToAnyContent().getAnyContent(PatientProcessingWebserviceConstants.UUID_OF_ORIGINAL_PATIENT_INPUT_NAME,
originalPatient.getUuid()));
originalPatientUUID));
processRequest.getInput().add(new MapperObjectToAnyContent().getAnyContent(PatientProcessingWebserviceConstants.UUID_OF_DUPLICATED_PATIENT_INPUT_NAME,
duplicatedPatient.getUuid()));
duplicatedPatientUUID));
} catch (MappingException e){
fail("No exception is supposed to be thrown when transforming test patient to AnyContent !", e);
}
assertThrows(IllegalArgumentException.class, () -> patientFeedProcessingService.processPatientMerge(processRequest));
}
......@@ -377,7 +382,7 @@ public class PatientFeedProcessingServiceTest {
* Test Processing a patient MERGE, error case using and AnyContent input that is not convertible to a Patient.
*/
@Test
@Description("")
@Description("Merging 2 patients w/ a patient object as input (incorrect Type of object)")
public void process_Incorrect_MergedPatient() {
AnyContent anyContent = new AnyContent();
anyContent.setName("Test");
......@@ -389,12 +394,11 @@ public class PatientFeedProcessingServiceTest {
processRequest.getInput().add(anyContent);
assertThrows(IllegalArgumentException.class, () -> patientFeedProcessingService.processPatientMerge(processRequest));
}
/**
* Test Processing a patient merge, error case using no input in ProcessRequest
*/
@Test
@Description("")
@Description("Merging 2 patients w/ no inputs")
public void processMerge_no_input() {
ProcessRequest processRequest = new ProcessRequest();
processRequest.setOperation(PatientProcessingWebserviceConstants.PATIENT_MERGE_OPERATION);
......@@ -408,7 +412,7 @@ public class PatientFeedProcessingServiceTest {
* Test Processing a patient to delete, nominal case.
*/
@Test
@Description("")
@Description("Deleting 1 patient in Nominal/OK Case")
public void processDelete() {
String uuidPatient="123";
......@@ -439,7 +443,7 @@ public class PatientFeedProcessingServiceTest {
* Test Processing a patient merge, with a false return.
*/
@Test
@Description("")
@Description("Deleting 1 patient in Nominal/OK Case w/ FALSE return")
public void processDelete_with_false_return() {
String uuidPatient="789";
......@@ -455,7 +459,7 @@ public class PatientFeedProcessingServiceTest {
ProcessResponse processResponse = patientFeedProcessingService.processPatientDelete(processRequest);
assertNotNull(processResponse, "ProcessResponse shall not be null !");
assertEquals(1, processResponse.getOutput().size(), "Response shall contain 1 output which is the value of the" +
" UUID assigned to the deleted patient.");
" Delete status.");
assertEquals("string", processResponse.getOutput().get(0).getType(), "Returned Patient shall be stored in a String GITB AnyContent");
assertEquals(PatientProcessingWebserviceConstants.DELETE_STATUS_OUTPUT_NAME, processResponse.getOutput().get(0).getName(), "Name of returned GITB AnyContent shall be 'UUID'");
assertEquals(ValueEmbeddingEnumeration.STRING, processResponse.getOutput().get(0).getEmbeddingMethod(), "Embedding method of returned " +
......@@ -469,8 +473,8 @@ public class PatientFeedProcessingServiceTest {
* Test Processing a patient Delete, service throwing an exception.
*/
@Test
@Description("")
public void processDelete_with_exception() {
@Description("Deleting 1 patient in KO Case w/ a PatientFeedException return")
public void processDelete_with_PatientFeedException() {
String uuidPatient="456";
ProcessRequest processRequest = new ProcessRequest();
......@@ -498,7 +502,7 @@ public class PatientFeedProcessingServiceTest {
* Test Processing a patient DELETE, error case using and AnyContent input that is not convertible to a Patient.
*/
@Test
@Description("")
@Description("Deleting 1 patient w/ a Patient object as input (incorrect Type of object)")
public void process_Incorrect_DeletedPatient() {
AnyContent anyContent = new AnyContent();
anyContent.setName("Test");
......@@ -510,14 +514,11 @@ public class PatientFeedProcessingServiceTest {
processRequest.getInput().add(anyContent);
assertThrows(IllegalArgumentException.class, () -> patientFeedProcessingService.processPatientDelete(processRequest));
}
/**
* Test Processing a patient Delete, error case using no input in ProcessRequest
*/
@Test
@Description("")
@Description("Deleting 1 patient w/ no inputs")
public void processDelete_no_input() {
ProcessRequest processRequest = new ProcessRequest();
processRequest.setOperation(PatientProcessingWebserviceConstants.PATIENT_DELETE_OPERATION);
......
......@@ -91,10 +91,11 @@ public class PatientProcessingServiceTest {
}
/**
* Test Processing a patient feed.
* Test Processing a patient create.
*/
@Test
public void process_Patient_Feed() {
@Description("Test the process of Create Patient")
public void process_Patient_Create() {
Patient patient = new Patient();
PersonName personName = new PersonName();
personName.setFamily("Bars");
......@@ -117,7 +118,7 @@ public class PatientProcessingServiceTest {
* Test Processing a patient update.
*/
@Test
@Description("Test the process of Update Patient")
public void process_Patient_Update() {
Patient patient = new Patient();
PersonName personName = new PersonName();
......@@ -141,6 +142,7 @@ public class PatientProcessingServiceTest {
* Test Processing a patient Search.
*/
@Test
@Description("Test the process of Search Patient")
public void process_Patient_Search() {
ProcessRequest processRequest = new ProcessRequest();
......@@ -160,6 +162,7 @@ public class PatientProcessingServiceTest {
* Test Processing a patient Search.
*/
@Test
@Description("Test the process of Delete Patient")
public void process_Patient_Delete() {
ProcessRequest processRequest = new ProcessRequest();
......@@ -174,9 +177,10 @@ public class PatientProcessingServiceTest {
ProcessResponse processResponse = patientProcessingService.process(processRequest);
assertNotNull(processResponse, "ProcessResponse shall not be null !");
}/**
* Test Processing a patient Search.
* Test Processing a patient Merge.
*/
@Test
@Description("Test the process of Merge Patient")
public void process_Patient_Merge() {
ProcessRequest processRequest = new ProcessRequest();
......@@ -194,7 +198,6 @@ public class PatientProcessingServiceTest {
assertNotNull(processResponse, "ProcessResponse shall not be null !");
}
//TODO Add allure annotations
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment