Mentions légales du service

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

TUs ended, ready for qualityGate

parent 7a506bb6
No related branches found
No related tags found
2 merge requests!5Release/2.0.0,!4Pixm
package net.ihe.gazelle.adapter.connector; package net.ihe.gazelle.adapter.connector;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import io.qameta.allure.*; import io.qameta.allure.*;
import net.ihe.gazelle.app.patientregistryapi.business.*; import net.ihe.gazelle.app.patientregistryapi.business.*;
import net.ihe.gazelle.app.patientregistryapi.business.Person; import net.ihe.gazelle.app.patientregistryapi.business.Person;
...@@ -20,7 +21,7 @@ public class BundleToPatientRegistryConverterTest { ...@@ -20,7 +21,7 @@ public class BundleToPatientRegistryConverterTest {
@Description("Test on unitary conversion") @Description("Test on unitary conversion")
@Severity(SeverityLevel.CRITICAL) @Severity(SeverityLevel.CRITICAL)
@Story("Name conversion") @Story("Name conversion")
void TestPatientNameConverion(){ void TestPatientNameConversion(){
Patient pat = new Patient(); Patient pat = new Patient();
HumanName name = new HumanName(); HumanName name = new HumanName();
name.addGiven("Patrick"); name.addGiven("Patrick");
...@@ -48,7 +49,7 @@ public class BundleToPatientRegistryConverterTest { ...@@ -48,7 +49,7 @@ public class BundleToPatientRegistryConverterTest {
@Description("Test on unitary conversion") @Description("Test on unitary conversion")
@Severity(SeverityLevel.CRITICAL) @Severity(SeverityLevel.CRITICAL)
@Story("Gender conversion") @Story("Gender conversion")
void TestPatientGenderConverion(){ void TestPatientGenderConversion(){
Patient pat1 = new Patient(); Patient pat1 = new Patient();
pat1.setGender(Enumerations.AdministrativeGender.FEMALE); pat1.setGender(Enumerations.AdministrativeGender.FEMALE);
...@@ -85,7 +86,7 @@ public class BundleToPatientRegistryConverterTest { ...@@ -85,7 +86,7 @@ public class BundleToPatientRegistryConverterTest {
@Description("Test on unitary conversion") @Description("Test on unitary conversion")
@Severity(SeverityLevel.CRITICAL) @Severity(SeverityLevel.CRITICAL)
@Story("Contact conversion") @Story("Contact conversion")
void TestPatientContactConverion(){ void TestPatientContactConversion(){
Patient pat = new Patient(); Patient pat = new Patient();
Patient.ContactComponent comp = new Patient.ContactComponent(); Patient.ContactComponent comp = new Patient.ContactComponent();
...@@ -113,7 +114,7 @@ public class BundleToPatientRegistryConverterTest { ...@@ -113,7 +114,7 @@ public class BundleToPatientRegistryConverterTest {
@Description("Test on unitary conversion") @Description("Test on unitary conversion")
@Severity(SeverityLevel.CRITICAL) @Severity(SeverityLevel.CRITICAL)
@Story("Address conversion") @Story("Address conversion")
void TestPatientAddressConverion(){ void TestPatientAddressConversion(){
Patient pat = new Patient(); Patient pat = new Patient();
Address address = new Address(); Address address = new Address();
...@@ -178,7 +179,7 @@ public class BundleToPatientRegistryConverterTest { ...@@ -178,7 +179,7 @@ public class BundleToPatientRegistryConverterTest {
@Description("Test on unitary conversion") @Description("Test on unitary conversion")
@Severity(SeverityLevel.CRITICAL) @Severity(SeverityLevel.CRITICAL)
@Story("Single parameters conversion") @Story("Single parameters conversion")
void TestPatientParametersConverion(){ void TestPatientParametersConversion(){
LocalDate dateValue = LocalDate.now(); LocalDate dateValue = LocalDate.now();
...@@ -199,4 +200,36 @@ public class BundleToPatientRegistryConverterTest { ...@@ -199,4 +200,36 @@ public class BundleToPatientRegistryConverterTest {
} }
@Test
@Description("Test on unitary conversion")
@Severity(SeverityLevel.CRITICAL)
@Story("Single parameters conversion")
void TestPatientIdentifiersConversion(){
Patient pat = new Patient();
Identifier id = new Identifier();
id.setSystem("urn:oid:Hello_Vincent");
id.setValue("69420");
pat.addIdentifier(id);
Patient pat1 = new Patient();
Identifier id1 = new Identifier();
pat.addIdentifier(id1);
try {
net.ihe.gazelle.app.patientregistryapi.business.Patient response = BundleToPatientRegistryConverter.hl7PatientToPatientRegistry(pat);
assertEquals("Hello_Vincent", response.getIdentifiers().get(0).getSystemIdentifier());
assertEquals("69420", response.getIdentifiers().get(0).getValue());
response = BundleToPatientRegistryConverter.hl7PatientToPatientRegistry(pat1);
} catch (InvalidRequestException e) {
assertEquals("Cannot create Patient without any Identifier", e.getMessage());
} catch (ConversionException e) {
fail();
}
}
} }
...@@ -176,31 +176,6 @@ public class BusinessToFhirConverterTest { ...@@ -176,31 +176,6 @@ public class BusinessToFhirConverterTest {
cp6.setUse(ContactPointUse.PRIMARY_HOME); cp6.setUse(ContactPointUse.PRIMARY_HOME);
pat6.addContactPoint(cp6); pat6.addContactPoint(cp6);
/*case HOME:
case PRIMARY_HOME:
return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.HOME;
case MOBILE:
return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.MOBILE;
case WORK:
return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.WORK;
case TEMPORARY:
return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.TEMP;
case BEEPER:
return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PAGER;
case PHONE:
return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PHONE;
case FAX:
return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.FAX;
case URL:
return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.URL;
case EMAIL:
return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.EMAIL;
case SMS:
return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.SMS;
case OTHER:
return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.OTHER;*/
try { try {
Patient response = BusinessToFhirConverter.patientToFhirPatient(pat); Patient response = BusinessToFhirConverter.patientToFhirPatient(pat);
assertEquals("Hello", response.getTelecom().get(0).getValue()); assertEquals("Hello", response.getTelecom().get(0).getValue());
...@@ -237,4 +212,28 @@ public class BusinessToFhirConverterTest { ...@@ -237,4 +212,28 @@ public class BusinessToFhirConverterTest {
} }
@Test
@Description("Test on unitary conversion")
@Severity(SeverityLevel.CRITICAL)
@Story("CrossReference conversion")
void TestPatientCrossReferenceConversion(){
net.ihe.gazelle.app.patientregistryapi.business.Patient pat = new net.ihe.gazelle.app.patientregistryapi.business.Patient();
EntityIdentifier id = new EntityIdentifier();
id.setSystemIdentifier("Hello_Vincent");
id.setValue("69420");
pat.addIdentifier(id);
try {
Patient response = BusinessToFhirConverter.patientToFhirPatient(pat);
assertEquals("urn:oid:Hello_Vincent", response.getIdentifier().get(0).getSystem());
assertEquals("69420", response.getIdentifier().get(0).getValue());
} catch (ConversionException e) {
fail("could not convert Patient with just a gender");
}
}
} }
...@@ -359,6 +359,44 @@ public class PatientFeedClientTest { ...@@ -359,6 +359,44 @@ public class PatientFeedClientTest {
} }
} }
@Test
@Description("Test on create, for particular exceptions returned from PatientFeedApplication")
@Severity(SeverityLevel.CRITICAL)
@Story("create")
void TestFeedBlankNameOnCreation() throws PreferenceException, NamespaceException, PatientFeedException {
Patient patient = createPatient("","name",LocalDate.of(1990, 06, 19), GenderCode.MALE);
patientRegistryFeedClient = new PatientRegistryFeedClient();
patientRegistryFeedClient.setClient(patientFeedClientMock);
assertThrows(InvalidRequestException.class, () -> patientRegistryFeedClient.createPatient(patient));
try {
patientRegistryFeedClient.createPatient(patient);
} catch (InvalidRequestException e) {
assertEquals("Mandatory fields are missing", e.getMessage());
}
}
@Test
@Description("Test on create, for particular exceptions returned from PatientFeedApplication")
@Severity(SeverityLevel.CRITICAL)
@Story("create")
void TestFeedBlankGenderOnCreation() throws PreferenceException, NamespaceException, PatientFeedException {
Patient patient = createPatient("name","name",LocalDate.of(1990, 06, 19), null);
patientRegistryFeedClient = new PatientRegistryFeedClient();
patientRegistryFeedClient.setClient(patientFeedClientMock);
assertThrows(InvalidRequestException.class, () -> patientRegistryFeedClient.createPatient(patient));
try {
patientRegistryFeedClient.createPatient(patient);
} catch (InvalidRequestException e) {
assertEquals("Mandatory fields are missing", e.getMessage());
}
}
@Test @Test
@Description("Test on update, when feeding basic request") @Description("Test on update, when feeding basic request")
...@@ -392,6 +430,131 @@ public class PatientFeedClientTest { ...@@ -392,6 +430,131 @@ public class PatientFeedClientTest {
} }
@Test
@Description("Test on update, exception thrown from PatReg")
@Severity(SeverityLevel.CRITICAL)
@Story("update")
void TestFeedUpdatePatientFeedThrown() throws PreferenceException, NamespaceException, PatientFeedException {
String uuid = TEST_UUID;
Patient patient = createPatient("","",LocalDate.of(1990, 06, 19), GenderCode.MALE);
PatientFeedException embedException = new PatientFeedException("Invalid Request sent to distant PatientFeedProcessingService !");
patientRegistryFeedClient = new PatientRegistryFeedClient();
patientRegistryFeedClient.setClient(patientFeedClientMock);
Mockito.doThrow(embedException).when(patientFeedClientMock).updatePatient(anyObject());
assertThrows(InvalidRequestException.class, () -> patientRegistryFeedClient.updatePatient(patient, uuid));
try {
patientRegistryFeedClient.updatePatient(patient, uuid);
}
catch (InvalidRequestException e) {
assertEquals("Invalid Request sent to distant PatientFeedProcessingService !", e.getMessage());
}
}
@Test
@Description("Test on update, exception thrown from PatReg")
@Severity(SeverityLevel.CRITICAL)
@Story("update")
void TestFeedUpdatePatientFeedResourceThrown() throws PreferenceException, NamespaceException, PatientFeedException {
String uuid = TEST_UUID;
Patient patient = createPatient("","",LocalDate.of(1990, 06, 19), GenderCode.MALE);
PatientFeedException embedException = new PatientFeedException("Invalid operation used on distant PatientFeedProcessingService !");
patientRegistryFeedClient = new PatientRegistryFeedClient();
patientRegistryFeedClient.setClient(patientFeedClientMock);
Mockito.doThrow(embedException).when(patientFeedClientMock).updatePatient(anyObject());
assertThrows(ResourceNotFoundException.class, () -> patientRegistryFeedClient.updatePatient(patient, uuid));
try {
patientRegistryFeedClient.updatePatient(patient, uuid);
}
catch (ResourceNotFoundException e) {
assertEquals("Invalid operation used on distant PatientFeedProcessingService !", e.getMessage());
}
}
@Test
@Description("Test on update, exception thrown from PatReg")
@Severity(SeverityLevel.CRITICAL)
@Story("update")
void TestFeedUpdatePatientFeedInvalidThrown() throws PreferenceException, NamespaceException, PatientFeedException {
String uuid = TEST_UUID;
Patient patient = createPatient("","",LocalDate.of(1990, 06, 19), GenderCode.MALE);
PatientFeedException embedException = new PatientFeedException("Invalid Response from distant PatientFeedProcessingService !");
patientRegistryFeedClient = new PatientRegistryFeedClient();
patientRegistryFeedClient.setClient(patientFeedClientMock);
Mockito.doThrow(embedException).when(patientFeedClientMock).updatePatient(anyObject());
assertThrows(InternalErrorException.class, () -> patientRegistryFeedClient.updatePatient(patient, uuid));
try {
patientRegistryFeedClient.updatePatient(patient, uuid);
}
catch (InternalErrorException e) {
assertEquals("Invalid Response from distant PatientFeedProcessingService !", e.getMessage());
}
}
@Test
@Description("Test on update, exception thrown from PatReg")
@Severity(SeverityLevel.CRITICAL)
@Story("update")
void TestFeedUpdatePatientFeedGitbThrown() throws PreferenceException, NamespaceException, PatientFeedException {
String uuid = TEST_UUID;
Patient patient = createPatient("","",LocalDate.of(1990, 06, 19), GenderCode.MALE);
PatientFeedException embedException = new PatientFeedException("Exception while Mapping with GITB elements !");
patientRegistryFeedClient = new PatientRegistryFeedClient();
patientRegistryFeedClient.setClient(patientFeedClientMock);
Mockito.doThrow(embedException).when(patientFeedClientMock).updatePatient(anyObject());
assertThrows(InternalErrorException.class, () -> patientRegistryFeedClient.updatePatient(patient, uuid));
try {
patientRegistryFeedClient.updatePatient(patient, uuid);
}
catch (InternalErrorException e) {
assertEquals("Exception while Mapping with GITB elements !", e.getMessage());
}
}
@Test
@Description("Test on update, exception thrown from PatReg")
@Severity(SeverityLevel.CRITICAL)
@Story("update")
void TestFeedUpdatePatientFeedUnhandled() throws PreferenceException, NamespaceException, PatientFeedException {
String uuid = TEST_UUID;
Patient patient = createPatient("","",LocalDate.of(1990, 06, 19), GenderCode.MALE);
PatientFeedException embedException = new PatientFeedException("This is supposed to be an unhandled error occuring");
patientRegistryFeedClient = new PatientRegistryFeedClient();
patientRegistryFeedClient.setClient(patientFeedClientMock);
Mockito.doThrow(embedException).when(patientFeedClientMock).updatePatient(anyObject());
assertThrows(InternalErrorException.class, () -> patientRegistryFeedClient.updatePatient(patient, uuid));
try {
patientRegistryFeedClient.updatePatient(patient, uuid);
}
catch (InternalErrorException e) {
assertEquals("An unhandled error occured", e.getMessage());
}
}
@Test @Test
@Description("Test on update, exception thrown when no Uuid is given") @Description("Test on update, exception thrown when no Uuid is given")
@Severity(SeverityLevel.CRITICAL) @Severity(SeverityLevel.CRITICAL)
......
...@@ -11,6 +11,8 @@ import java.util.List; ...@@ -11,6 +11,8 @@ import java.util.List;
import javax.xml.ws.WebServiceException; import javax.xml.ws.WebServiceException;
import net.ihe.gazelle.adapter.connector.BusinessToFhirConverter;
import net.ihe.gazelle.adapter.connector.ConversionException;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
......
...@@ -89,6 +89,16 @@ class CHBundleProviderTest { ...@@ -89,6 +89,16 @@ class CHBundleProviderTest {
assertThrows(InvalidRequestException.class, ()-> bundle_feed_provider.delete(id, cbpm.returnBundleFromResource(fileName)),"Bundle Could not be converted to HL7 Patient"); assertThrows(InvalidRequestException.class, ()-> bundle_feed_provider.delete(id, cbpm.returnBundleFromResource(fileName)),"Bundle Could not be converted to HL7 Patient");
} }
@Test
@Description("Test on the delete operation, deleting a Patient but with a null bundle")
@Severity(SeverityLevel.CRITICAL)
@Story("delete operation")
void testDeleteBlankId() {
String fileName = "post_request.json";
IdType id = new IdType("");
assertThrows(InvalidRequestException.class, ()-> bundle_feed_provider.delete(id, cbpm.returnBundleFromResource(fileName)),"Bundle is null or Empty");
}
@Test @Test
@Description("Test on the update operation, clean update without issue") @Description("Test on the update operation, clean update without issue")
@Severity(SeverityLevel.CRITICAL) @Severity(SeverityLevel.CRITICAL)
......
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