Attention une mise à jour du serveur va être effectuée le lundi 17 mai entre 13h et 13h30. Cette mise à jour va générer une interruption du service de quelques minutes.

Commit bc6afd6f authored by Nicolas Bailliet's avatar Nicolas Bailliet

PATREG-79 | Patient Search Client and Server coverage added on UT

parent 656fa9ec
package net.ihe.gazelle.app.patientregistrysearchclient.adapter;
import net.ihe.gazelle.app.patientregistryapi.business.Patient;
import net.ihe.gazelle.lib.annotations.Covers;
import net.ihe.gazelle.lib.searchmodelapi.business.SearchCriteria;
import net.ihe.gazelle.lib.searchmodelapi.business.exception.SearchException;
import org.junit.jupiter.api.BeforeEach;
......@@ -33,6 +34,7 @@ public class PatientSearchClientTest {
* @throws SearchException
*/
@Test
@Covers(requirements = {"PATREG-40","PATREG-41","PATREG-42","PATREG-43","PATREG-44"})
public void search_With_Success() throws SearchException {
List<Patient> patients = patientSearchClient.search(new SearchCriteria());
assertEquals(TestProcessingService.getPatients(), patients);
......@@ -42,6 +44,7 @@ public class PatientSearchClientTest {
* Test of the client when the underlying service returns no report
*/
@Test
@Covers(requirements = {"PATREG-110"})
public void search_With_Success_missing_report() {
testProcessingService.setResponseToReturn(TestProcessingService.ResponseTypes.MISSING_REPORT);
SearchException exception = assertThrows(SearchException.class, () -> patientSearchClient.search(new SearchCriteria()));
......@@ -53,6 +56,7 @@ public class PatientSearchClientTest {
* Test of the client when the underlying service returns a failure report
*/
@Test
@Covers(requirements = {"PATREG-111"})
public void search_With_Success_failed_report() {
testProcessingService.setResponseToReturn(TestProcessingService.ResponseTypes.FAILED_REPORT);
SearchException exception = assertThrows(SearchException.class, () -> patientSearchClient.search(new SearchCriteria()));
......@@ -63,6 +67,7 @@ public class PatientSearchClientTest {
* Test of the client when the underlying service returns a response with multiple output.
*/
@Test
@Covers(requirements = {"PATREG-112"})
public void search_With_Success_multiple_output() {
testProcessingService.setResponseToReturn(TestProcessingService.ResponseTypes.MULTIPLE_OUTPUT);
SearchException exception = assertThrows(SearchException.class, () -> patientSearchClient.search(new SearchCriteria()));
......@@ -74,6 +79,7 @@ public class PatientSearchClientTest {
* Test of the client when the underlying service returns a response with invalid output (not a list of patient)
*/
@Test
@Covers(requirements = "PATREG-48")
public void search_With_Success_invalid_output() {
testProcessingService.setResponseToReturn(TestProcessingService.ResponseTypes.INVALID_OUTPUT);
SearchException exception = assertThrows(SearchException.class, () -> patientSearchClient.search(new SearchCriteria()));
......@@ -85,6 +91,7 @@ public class PatientSearchClientTest {
* Test of the client when the underlying service returns a null repsonse
*/
@Test
@Covers(requirements = "PATREG-45")
public void search_null_response() {
testProcessingService.setResponseToReturn(TestProcessingService.ResponseTypes.NULL_RESPONSE);
SearchException exception = assertThrows(SearchException.class, () -> patientSearchClient.search(new SearchCriteria()));
......@@ -95,6 +102,7 @@ public class PatientSearchClientTest {
* Test of the client when the underlying service returns a report with an unexpected status
*/
@Test
@Covers(requirements = "PATREG-45")
public void search_unexpected_processing_status() {
testProcessingService.setResponseToReturn(TestProcessingService.ResponseTypes.UNEXPECTED_STATUS);
SearchException exception = assertThrows(SearchException.class, () -> patientSearchClient.search(new SearchCriteria()));
......@@ -106,6 +114,7 @@ public class PatientSearchClientTest {
* Test of the client when the underlying service returns a report with on error report inside
*/
@Test
@Covers(requirements = "PATREG-46")
public void search_no_reports_in_report() {
testProcessingService.setResponseToReturn(TestProcessingService.ResponseTypes.NO_REPORTS_IN_REPORT);
SearchException exception = assertThrows(SearchException.class, () -> patientSearchClient.search(new SearchCriteria()));
......@@ -116,6 +125,7 @@ public class PatientSearchClientTest {
* Test of the client when the underlying service returns a failure report without an error
*/
@Test
@Covers(requirements = "PATREG-46")
public void search_no_error_in_failure_report() {
testProcessingService.setResponseToReturn(TestProcessingService.ResponseTypes.NO_ERROR_IN_FAILURE_REPORT);
SearchException exception = assertThrows(SearchException.class, () -> patientSearchClient.search(new SearchCriteria()));
......@@ -126,6 +136,7 @@ public class PatientSearchClientTest {
* Test of the client when the underlying service returns a failure report with an error with no description
*/
@Test
@Covers(requirements = "PATREG-47")
public void search_no_error_description() {
testProcessingService.setResponseToReturn(TestProcessingService.ResponseTypes.NO_ERROR_DESCRIPTION);
SearchException exception = assertThrows(SearchException.class, () -> patientSearchClient.search(new SearchCriteria()));
......@@ -136,6 +147,7 @@ public class PatientSearchClientTest {
* Test of the client when the underlying service returns an IllegalArgumentException
*/
@Test
@Covers(requirements = "PATREG-49")
public void search_illegalArgumentException() {
testProcessingService.setResponseToReturn(TestProcessingService.ResponseTypes.ILLEGAL_ARGUMENT_EXCEPTION);
SearchException exception = assertThrows(SearchException.class, () -> patientSearchClient.search(new SearchCriteria()));
......@@ -146,9 +158,10 @@ public class PatientSearchClientTest {
* Test of the client when the underlying service returns an UnsupportedOperationException
*/
@Test
@Covers(requirements = {"PATREG-113"})
public void search_unsupportedOperationException() {
testProcessingService.setResponseToReturn(TestProcessingService.ResponseTypes.UNSUPPORTED_OPERATION_EXCEPTION);
SearchException exception = assertThrows(SearchException.class, () -> patientSearchClient.search(new SearchCriteria()));
assertEquals("Invalid operation used on distant PatientFeedProcessingService !", exception.getMessage());
}
}
}
\ No newline at end of file
......@@ -8,6 +8,7 @@ import com.gitb.tr.BAR;
import com.gitb.tr.TestResultType;
import net.ihe.gazelle.app.patientregistryapi.adapter.ws.PatientRegistryGITBWebserviceConstants;
import net.ihe.gazelle.app.patientregistryservice.application.TestPatientSearchServiceImpl;
import net.ihe.gazelle.lib.annotations.Covers;
import net.ihe.gazelle.lib.gitbutils.adapter.MapperObjectToAnyContent;
import net.ihe.gazelle.lib.gitbutils.adapter.MappingException;
import net.ihe.gazelle.lib.searchmodelapi.business.SearchCriteria;
......@@ -28,9 +29,10 @@ public class PatientSearchProcessingServiceTest {
}
/**
* Test Processing a patient feed, nominal case.
* Test Processing a patient client, nominal case.
*/
@Test
@Covers(requirements = {"PATREG-50","PATREG-56","PATREG-57","PATREG-59"})
public void process() {
ProcessRequest processRequest = new ProcessRequest();
processRequest.setOperation(PatientRegistryGITBWebserviceConstants.PATIENT_SEARCH_OPERATION);
......@@ -54,9 +56,10 @@ public class PatientSearchProcessingServiceTest {
}
/**
* Test Processing a patient feed, service throwing an exception.
* Test Processing a patient client, service throwing an exception.
*/
@Test
@Covers(requirements = {"PATREG-55","PATREG-58","PATREG-59"})
public void process_with_exception() {
testPatientSearchService.setSearchResult(TestPatientSearchServiceImpl.SearchResult.KO);
ProcessRequest processRequest = new ProcessRequest();
......@@ -81,9 +84,10 @@ public class PatientSearchProcessingServiceTest {
}
/**
* Test Processing a patient feed, service returning null.
* Test Processing a patient client, service returning null.
*/
@Test
@Covers(requirements = {"PATREG-51"})
public void process_with_null_return() {
testPatientSearchService.setSearchResult(TestPatientSearchServiceImpl.SearchResult.NULL);
ProcessRequest processRequest = new ProcessRequest();
......@@ -99,9 +103,10 @@ public class PatientSearchProcessingServiceTest {
}
/**
* Test Processing a patient feed, error case using and AnyContent input that is not convertible to a Patient.
* Test Processing a patient client, error case using and AnyContent input that is not convertible to a Patient.
*/
@Test
@Covers(requirements = {"PATREG-52","PATREG-53"})
public void process_Incorrect_Patient() {
AnyContent anyContent = new AnyContent();
anyContent.setName("Test");
......@@ -115,12 +120,13 @@ public class PatientSearchProcessingServiceTest {
}
/**
* Test Processing a patient feed, error case using no input in ProcessRequest
* Test Processing a patient client, error case using no input in ProcessRequest
*/
@Test
@Covers(requirements = {"PATREG-53","PATREG-54"})
public void process_no_input() {
ProcessRequest processRequest = new ProcessRequest();
processRequest.setOperation(PatientRegistryGITBWebserviceConstants.PATIENT_FEED_OPERATION);
assertThrows(IllegalArgumentException.class, () -> patientSearchProcessingService.processPatientSearch(processRequest));
}
}
}
\ No newline at end of file
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