Commit 603b8c7a authored by Matthieu Bonnouvrier's avatar Matthieu Bonnouvrier
Browse files

Refactoring to match [1...*] specification on targetDomain

parent 073ed664
......@@ -42,6 +42,14 @@ public class PatientCrossReferenceDAOImpl implements PatientCrossReferenceDAO {
this.entityManager = entityManager;
}
/**
* Search for a patient by its entity identifier.
* The request need to go through HierarchicDesignatorDB => PatientIdentifierDB => PatientDB
*
* @param entityIdentifier
* @return
* @throws SearchCrossReferenceException
*/
@Override
public PatientDB searchForPatientDBWithSourceIdentifier(EntityIdentifier entityIdentifier) throws SearchCrossReferenceException {
checkSourceIdentifier(entityIdentifier);
......@@ -56,7 +64,13 @@ public class PatientCrossReferenceDAOImpl implements PatientCrossReferenceDAO {
return patientDB;
}
//TODO Javadoc
/**
* Search for a list of patientAliases by its patient cross reference id
*
* @param patientDB
* @return
* @throws SearchCrossReferenceException
*/
@Override
public List<CrossReferenceDB> searchForPatientAliasesWithPatientDB(PatientDB patientDB) throws SearchCrossReferenceException {
if (patientDB != null) {
......@@ -100,6 +114,13 @@ public class PatientCrossReferenceDAOImpl implements PatientCrossReferenceDAO {
}
}
/**
* Search for a HierarchicDesignatorDB given a system identifier
*
* @param systemIdentifier
* @return
* @throws SearchCrossReferenceException
*/
private HierarchicDesignatorDB searchForHierarchicDesignator(String systemIdentifier) throws SearchCrossReferenceException {
try {
TypedQuery<HierarchicDesignatorDB> queryForAPatient = entityManager.createNamedQuery("HierarchicDesignatorDB.findByUniversalID", HierarchicDesignatorDB.class);
......@@ -112,6 +133,14 @@ public class PatientCrossReferenceDAOImpl implements PatientCrossReferenceDAO {
}
}
/**
* search for a PatientIdentifierDB given its HierarchicDesignatorDB and its id_number
*
* @param hierarchicDesignatorDB
* @param idNumber
* @return
* @throws SearchCrossReferenceException
*/
private PatientIdentifierDB searchForPatientIdentifier(HierarchicDesignatorDB hierarchicDesignatorDB, String idNumber) throws SearchCrossReferenceException {
try {
TypedQuery<PatientIdentifierDB> queryForAPatient = entityManager.createNamedQuery("PatientIdentifierDB.findByHierarchicDomainAndId", PatientIdentifierDB.class);
......@@ -123,6 +152,13 @@ public class PatientCrossReferenceDAOImpl implements PatientCrossReferenceDAO {
}
}
/**
* Search for a PatientDB given its PatientIdentifierDB
*
* @param patientIdentifier
* @return
* @throws SearchCrossReferenceException
*/
private PatientDB searchforPatient(PatientIdentifierDB patientIdentifier) throws SearchCrossReferenceException {
try {
String patient_identifier = patientIdentifier.getIdentifier();
......
......@@ -3,7 +3,6 @@ package net.ihe.gazelle.app.patientregistryservice.application;
import net.ihe.gazelle.app.patientregistryapi.application.DomainService;
import net.ihe.gazelle.app.patientregistryapi.application.PatientCrossReferenceSearch;
import net.ihe.gazelle.app.patientregistryapi.application.SearchCrossReferenceException;
import net.ihe.gazelle.app.patientregistryapi.application.UnrecognizedDomainException;
import net.ihe.gazelle.app.patientregistryapi.business.EntityIdentifier;
import net.ihe.gazelle.app.patientregistryapi.business.Patient;
import net.ihe.gazelle.app.patientregistryapi.business.PatientAliases;
......@@ -11,15 +10,12 @@ import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.conve
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.converter.PatientConverter;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.model.patient.PatientDB;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.model.references.CrossReferenceDB;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.service.DomainDAO;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.service.PatientCrossReferenceDAO;
import javax.inject.Inject;
import javax.inject.Named;
import javax.persistence.NoResultException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class PatientCrossReferenceSearchImpl implements PatientCrossReferenceSearch {
private PatientCrossReferenceDAO patientCrossReferenceDAO;
......@@ -47,7 +43,7 @@ public class PatientCrossReferenceSearchImpl implements PatientCrossReferenceSea
@Override
public PatientAliases search(EntityIdentifier sourceIdentifier, List<String> targetDomains) throws SearchCrossReferenceException {
checkSourceIdentifier(sourceIdentifier);
boolean targetDomainUsable = isTargetDomainsUsable(targetDomains);
checkTargetDomains(targetDomains);
PatientDB patientDB = null;
PatientAliases patientAlias = null;
......@@ -57,24 +53,23 @@ public class PatientCrossReferenceSearchImpl implements PatientCrossReferenceSea
patientAlias = processingOnResult(crossReferenceDBS, patientDB);
} catch (SearchCrossReferenceException searchCrossReferenceException) {
if (searchCrossReferenceException.getMessage().equals("System not found")) {
throw new SearchCrossReferenceException("Error in the sourceIdentifier : System doesn't exit");
} else if (searchCrossReferenceException.getMessage().equals("PatientIdentifier not found")) {
throw new SearchCrossReferenceException("Error in the sourceIdentifier : it doesn't match any identity");
} else if (searchCrossReferenceException.getMessage().equals("Patient not found with with corresponding PatientIdentifier")) {
throw new SearchCrossReferenceException("Error in the sourceIdentifier : it doesn't match any Patient");
}
if (searchCrossReferenceException.getMessage().equals("Search error : No X-ref for given Patient")) {
return convertPatientDBToPatientAliases(patientDB);
switch (searchCrossReferenceException.getMessage()) {
case "System not found":
throw new SearchCrossReferenceException("Error in the sourceIdentifier : System does not exit");
case "PatientIdentifier not found":
throw new SearchCrossReferenceException("Error in the sourceIdentifier : it does not match any identity");
case "Patient not found with with corresponding PatientIdentifier":
throw new SearchCrossReferenceException("Error in the sourceIdentifier : it does not match any Patient");
case "Search error : No X-ref for given Patient":
return convertPatientDBToPatientAliases(patientDB);
}
} catch (Exception exception) {
throw new SearchCrossReferenceException("An error occurred during CrossReference Search", exception);
}
if (targetDomainUsable) {
return removePatientFromPatientAliasWithNonMatchingTargetDomain(patientAlias, targetDomains);
} else {
return patientAlias;
if (patientAlias == null) {
throw new SearchCrossReferenceException("An error occurred during CrossReference Search and the patient aliases could not have been set");
}
return removePatientFromPatientAliasWithNonMatchingTargetDomain(patientAlias, targetDomains);
}
/**
......@@ -105,16 +100,14 @@ public class PatientCrossReferenceSearchImpl implements PatientCrossReferenceSea
* @param targetDomains
* @throws SearchCrossReferenceException
*/
private boolean isTargetDomainsUsable(List<String> targetDomains) throws SearchCrossReferenceException {
if (!targetDomains.isEmpty()) {
for (String targetDomain : targetDomains) {
if (!targetDomain.isBlank() && !domainService.exist(targetDomain)) {
throw new SearchCrossReferenceException("An error in the target domain list : one does not exist");
}
private void checkTargetDomains(List<String> targetDomains) throws SearchCrossReferenceException {
if (targetDomains.isEmpty()) {
throw new SearchCrossReferenceException("The target domains shall not be empty");
}
for (String targetDomain : targetDomains) {
if (targetDomain.isBlank() || !domainService.exist(targetDomain)) {
throw new SearchCrossReferenceException("One of the target domain does not exist");
}
return true;
} else {
return false;
}
}
......@@ -163,6 +156,12 @@ public class PatientCrossReferenceSearchImpl implements PatientCrossReferenceSea
}
}
/**
* Convert
*
* @param patientDB
* @return
*/
private PatientAliases convertPatientDBToPatientAliases(PatientDB patientDB) {
PatientAliases patientAliases = new PatientAliases();
patientAliases.addMember(PatientConverter.toPatient(patientDB));
......@@ -170,10 +169,17 @@ public class PatientCrossReferenceSearchImpl implements PatientCrossReferenceSea
}
private List<CrossReferenceDB> deleteKnownPatientInCrossReference(PatientDB patientDB, List<CrossReferenceDB> crossReferences) {
for (CrossReferenceDB crossReference : crossReferences) {
if (crossReference.getPatients().size() > 1) {
crossReference.getPatients().remove(patientDB);
List<PatientDB> patientDBS = new ArrayList<>();
if (crossReference.getPatients() != null) {
for (PatientDB patientInCrossRef : crossReference.getPatients()) {
if (!patientInCrossRef.getUuid().equals(patientDB.getUuid())) {
patientDBS.add(patientInCrossRef);
}
}
}
crossReference.setPatients(patientDBS);
}
return crossReferences;
}
......
......@@ -28,18 +28,6 @@ class PatientCrossReferenceDAOImplTest {
/**
* database init
*/
// @BeforeAll
// void startup() throws ParseException {
// entityManager = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME_CONST).createEntityManager();
// patientCrossReferenceDAO = new PatientCrossReferenceDAOImpl(entityManager);
// addTestEntitiesToDB(entityManager);
// }
//
// @BeforeEach
// public void initializeDatabase() {
// entityManager.getTransaction().begin();
// entityManager.getTransaction().commit();
// }
@BeforeAll
public void initializeDatabase() throws ParseException {
entityManager = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME_CONST).createEntityManager();
......@@ -48,12 +36,10 @@ class PatientCrossReferenceDAOImplTest {
addTestEntitiesToDB(entityManager);
}
private void addTestEntitiesToDB(EntityManager entityManager) throws ParseException {
initializeDb(entityManager);
}
/**
* Close the connection to the database after all tests are executed.
*/
......@@ -75,7 +61,6 @@ class PatientCrossReferenceDAOImplTest {
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class,
() -> patientCrossReferenceDAO.searchForPatientAliasesWithPatientDB(null));
assertEquals("Patient Cannot be null", exception.getMessage());
}
@Test
......@@ -85,7 +70,6 @@ class PatientCrossReferenceDAOImplTest {
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class,
() -> patientCrossReferenceDAO.searchForPatientAliasesWithPatientDB(patientDB));
assertEquals("The uuid of patientDB shall not be null", exception.getMessage());
}
@Test
......@@ -95,7 +79,6 @@ class PatientCrossReferenceDAOImplTest {
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class,
() -> patientCrossReferenceDAO.searchForPatientAliasesWithPatientDB(patientDB));
assertEquals("The uuid of patientDB shall not be null", exception.getMessage());
}
@Test
......@@ -107,7 +90,6 @@ class PatientCrossReferenceDAOImplTest {
SearchCrossReferenceException exception = assertThrows(SearchCrossReferenceException.class,
() -> patientCrossReferenceDAO.searchForPatientAliasesWithPatientDB(patientDB));
assertEquals("Search error : No X-ref for given Patient", exception.getMessage());
}
@Test
......@@ -117,7 +99,6 @@ class PatientCrossReferenceDAOImplTest {
entityIdentifier.setValue("1235");
PatientDB patientDB = patientCrossReferenceDAO.searchForPatientDBWithSourceIdentifier(entityIdentifier);
patientCrossReferenceDAO.searchForPatientAliasesWithPatientDB(patientDB);
}
@Test
......@@ -125,7 +106,6 @@ class PatientCrossReferenceDAOImplTest {
SearchCrossReferenceException exception = assertThrows(SearchCrossReferenceException.class,
() -> patientCrossReferenceDAO.searchForPatientDBWithSourceIdentifier(null));
assertEquals("The source identifier cannot be null", exception.getMessage());
}
@Test
......@@ -134,7 +114,6 @@ class PatientCrossReferenceDAOImplTest {
SearchCrossReferenceException exception = assertThrows(SearchCrossReferenceException.class,
() -> patientCrossReferenceDAO.searchForPatientDBWithSourceIdentifier(entityIdentifier));
assertEquals("The system identifier from entityIdentifier cannot be null or empty", exception.getMessage());
}
@Test
......@@ -144,7 +123,6 @@ class PatientCrossReferenceDAOImplTest {
SearchCrossReferenceException exception = assertThrows(SearchCrossReferenceException.class,
() -> patientCrossReferenceDAO.searchForPatientDBWithSourceIdentifier(entityIdentifier));
assertEquals("The system identifier from entityIdentifier cannot be null or empty", exception.getMessage());
}
@Test
......@@ -154,7 +132,6 @@ class PatientCrossReferenceDAOImplTest {
SearchCrossReferenceException exception = assertThrows(SearchCrossReferenceException.class,
() -> patientCrossReferenceDAO.searchForPatientDBWithSourceIdentifier(entityIdentifier));
assertEquals("The value from entityIdentifier cannot be null or empty", exception.getMessage());
}
@Test
......@@ -165,7 +142,6 @@ class PatientCrossReferenceDAOImplTest {
SearchCrossReferenceException exception = assertThrows(SearchCrossReferenceException.class,
() -> patientCrossReferenceDAO.searchForPatientDBWithSourceIdentifier(entityIdentifier));
assertEquals("The value from entityIdentifier cannot be null or empty", exception.getMessage());
}
@Test
......@@ -176,7 +152,6 @@ class PatientCrossReferenceDAOImplTest {
SearchCrossReferenceException exception = assertThrows(SearchCrossReferenceException.class,
() -> patientCrossReferenceDAO.searchForPatientDBWithSourceIdentifier(entityIdentifier));
assertEquals("System not found", exception.getMessage());
}
@Test
......@@ -187,7 +162,6 @@ class PatientCrossReferenceDAOImplTest {
SearchCrossReferenceException exception = assertThrows(SearchCrossReferenceException.class,
() -> patientCrossReferenceDAO.searchForPatientDBWithSourceIdentifier(entityIdentifier));
assertEquals("PatientIdentifier not found", exception.getMessage());
}
@Test
......@@ -198,7 +172,6 @@ class PatientCrossReferenceDAOImplTest {
SearchCrossReferenceException exception = assertThrows(SearchCrossReferenceException.class,
() -> patientCrossReferenceDAO.searchForPatientDBWithSourceIdentifier(entityIdentifier));
assertEquals("Patient not found with corresponding PatientIdentifier", exception.getMessage());
}
......
......@@ -12,11 +12,15 @@ public class DomainServiceMock implements DomainDAO, DomainService {
@Override
public boolean exist(String domainIdentifier) {
if(domainIdentifier == null){
if (domainIdentifier == null) {
return false;
}
if(domainIdentifier.equals("valid")){
return true;
switch (domainIdentifier) {
case "valid":
case "targetDomain":
case "Retrieved11":
case "original3":
return true;
}
return false;
}
......
......@@ -4,7 +4,9 @@ import net.ihe.gazelle.app.patientregistryapi.application.SearchCrossReferenceEx
import net.ihe.gazelle.app.patientregistryapi.business.EntityIdentifier;
import net.ihe.gazelle.app.patientregistryapi.business.Patient;
import net.ihe.gazelle.app.patientregistryapi.business.PatientAliases;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.model.patient.HierarchicDesignatorDB;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.model.patient.PatientDB;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.model.patient.PatientIdentifierDB;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.model.references.CrossReferenceDB;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.service.PatientCrossReferenceDAO;
......@@ -39,9 +41,17 @@ public class PatientCrossReferenceDAOMock implements PatientCrossReferenceDAO {
return patientDB2;
case "3CrossFound":
PatientDB patientDB3 = new PatientDB();
patientDB3.setUuid("original3");
patientDB3.setUuid("searchTargetDomainFound");
patientDB3.setFirstName("testFirstName");
patientDB3.setLastName("testLastName");
PatientIdentifierDB patientIdentifierDB = new PatientIdentifierDB();
patientIdentifierDB.setIdentifier("patientIdentifierDB1");
PatientIdentifierDB patientIdentifierDB2 = new PatientIdentifierDB();
patientIdentifierDB2.setIdentifier("patientIdentifierDB2");
List<PatientIdentifierDB> patientIdentifierDBS = new ArrayList<>();
patientIdentifierDBS.add(patientIdentifierDB);
patientIdentifierDBS.add(patientIdentifierDB2);
patientDB3.setPatientIdentifiers(patientIdentifierDBS);
return patientDB3;
case "searchTargetDomainFound":
PatientDB patientDB4 = new PatientDB();
......@@ -61,10 +71,11 @@ public class PatientCrossReferenceDAOMock implements PatientCrossReferenceDAO {
throw new SearchCrossReferenceException("Search error : No X-ref for given Patient");
case "original":
List<CrossReferenceDB> crossReferenceDBS = new ArrayList<>();
crossReferenceDBS.add(crossReferenceDBS(patient,""));
crossReferenceDBS.add(crossReferenceDBS(patient, ""));
return crossReferenceDBS;
case "original3":
case "targetDomain":
case "searchTargetDomainFound":
return multipleCrossReferenceDBS(patient);
}
......@@ -72,33 +83,50 @@ public class PatientCrossReferenceDAOMock implements PatientCrossReferenceDAO {
}
private List<CrossReferenceDB> multipleCrossReferenceDBS(PatientDB patient){
List<CrossReferenceDB>crossReferenceDBS= new ArrayList<>();
crossReferenceDBS.add(crossReferenceDBS(patient,"1"));
crossReferenceDBS.add(crossReferenceDBS(patient,"2"));
crossReferenceDBS.add(crossReferenceDBS(patient,"3"));
private List<CrossReferenceDB> multipleCrossReferenceDBS(PatientDB patient) {
List<CrossReferenceDB> crossReferenceDBS = new ArrayList<>();
crossReferenceDBS.add(crossReferenceDBS(patient, "1"));
crossReferenceDBS.add(crossReferenceDBS(patient, "2"));
crossReferenceDBS.add(crossReferenceDBS(patient, "3"));
return crossReferenceDBS;
}
private CrossReferenceDB crossReferenceDBS(PatientDB patient, String numb){
private CrossReferenceDB crossReferenceDBS(PatientDB patient, String numb) {
String lastModifier = "test";
Date lastModifierDateTime = new Date();
CrossReferenceDB patientAliases = new CrossReferenceDB();
patientAliases.setLastChanged(lastModifierDateTime);
patientAliases.setLastModifier(lastModifier);
HierarchicDesignatorDB hierarchicDesignatorDB = new HierarchicDesignatorDB();
hierarchicDesignatorDB.setUniversalID("targetDomain");
PatientIdentifierDB patientIdentifierDB = new PatientIdentifierDB();
patientIdentifierDB.setIdentifier("patientIdentifierDBX1");
patientIdentifierDB.setDomain(hierarchicDesignatorDB);
PatientIdentifierDB patientIdentifierDB2 = new PatientIdentifierDB();
patientIdentifierDB2.setIdentifier("patientIdentifierDBX2");
List<PatientIdentifierDB> patientIdentifierDBS = new ArrayList<>();
patientIdentifierDBS.add(patientIdentifierDB);
patientIdentifierDBS.add(patientIdentifierDB2);
PatientDB patientDB = new PatientDB();
patientDB.setUuid("Retrieved1"+ numb);
patientDB.setUuid("Retrieved1" + numb);
patientDB.setFirstName("testFirstName");
patientDB.setLastName("testLastName");
patientDB.setPatientIdentifiers(patientIdentifierDBS);
PatientDB patientDB2 = new PatientDB();
patientDB2.setUuid("Retrieved2"+ numb);
patientDB2.setUuid("Retrieved2" + numb);
patientDB2.setFirstName("testFirstName");
patientDB2.setLastName("testLastName");
PatientDB patientDB3 = new PatientDB();
patientDB3.setUuid("Retrieved3"+ numb);
patientDB3.setUuid("Retrieved3" + numb);
patientDB3.setFirstName("testFirstName");
patientDB3.setLastName("testLastName");
List<PatientDB> patientDBS = new ArrayList<>();
patientDBS.add(patient);
patientDBS.add(patientDB);
......
......@@ -26,7 +26,7 @@ public class PatientCrossReferenceSearchImplTest {
@Test
public void searchTestWithNullSourceIdentifier() {
SearchCrossReferenceException exception = assertThrows(SearchCrossReferenceException.class, () -> patientCrossReferenceSearch.search(null,null));
SearchCrossReferenceException exception = assertThrows(SearchCrossReferenceException.class, () -> patientCrossReferenceSearch.search(null, null));
assertEquals("The source identifier cannot be null", exception.getMessage());
}
......@@ -35,7 +35,7 @@ public class PatientCrossReferenceSearchImplTest {
EntityIdentifier sourceIdentifier = new EntityIdentifier();
List<String> targetDomains = new ArrayList<>();
SearchCrossReferenceException exception = assertThrows(SearchCrossReferenceException.class,
() -> patientCrossReferenceSearch.search(sourceIdentifier,targetDomains));
() -> patientCrossReferenceSearch.search(sourceIdentifier, targetDomains));
assertEquals("The system identifier from sourceIdentifier cannot be null or empty", exception.getMessage());
}
......@@ -46,7 +46,7 @@ public class PatientCrossReferenceSearchImplTest {
sourceIdentifier.setSystemIdentifier("");
List<String> targetDomains = new ArrayList<>();
SearchCrossReferenceException exception = assertThrows(SearchCrossReferenceException.class,
() -> patientCrossReferenceSearch.search(sourceIdentifier,targetDomains));
() -> patientCrossReferenceSearch.search(sourceIdentifier, targetDomains));
assertEquals("The system identifier from sourceIdentifier cannot be null or empty", exception.getMessage());
}
......@@ -57,7 +57,7 @@ public class PatientCrossReferenceSearchImplTest {
sourceIdentifier.setSystemIdentifier("toto");
List<String> targetDomains = new ArrayList<>();
SearchCrossReferenceException exception = assertThrows(SearchCrossReferenceException.class,
() -> patientCrossReferenceSearch.search(sourceIdentifier,targetDomains));
() -> patientCrossReferenceSearch.search(sourceIdentifier, targetDomains));
assertEquals("The value from sourceIdentifier cannot be null or empty", exception.getMessage());
}
......@@ -69,7 +69,7 @@ public class PatientCrossReferenceSearchImplTest {
sourceIdentifier.setValue("");
List<String> targetDomains = new ArrayList<>();
SearchCrossReferenceException exception = assertThrows(SearchCrossReferenceException.class,
() -> patientCrossReferenceSearch.search(sourceIdentifier,targetDomains));
() -> patientCrossReferenceSearch.search(sourceIdentifier, targetDomains));
assertEquals("The value from sourceIdentifier cannot be null or empty", exception.getMessage());
}
......@@ -80,9 +80,9 @@ public class PatientCrossReferenceSearchImplTest {
sourceIdentifier.setValue("SystemNotFound");
List<String> targetDomains = new ArrayList<>();
SearchCrossReferenceException exception = assertThrows(SearchCrossReferenceException.class,
() -> patientCrossReferenceSearch.search(sourceIdentifier,targetDomains));
() -> patientCrossReferenceSearch.search(sourceIdentifier, targetDomains));
assertEquals("Error in the sourceIdentifier : System doesn't exit", exception.getMessage());
assertEquals("The target domains shall not be empty", exception.getMessage());
}
@Test
......@@ -91,8 +91,9 @@ public class PatientCrossReferenceSearchImplTest {
sourceIdentifier.setSystemIdentifier("toto");
sourceIdentifier.setValue("UnexpectedException");
List<String> targetDomains = new ArrayList<>();
targetDomains.add("valid");
SearchCrossReferenceException exception = assertThrows(SearchCrossReferenceException.class,
() -> patientCrossReferenceSearch.search(sourceIdentifier,targetDomains));
() -> patientCrossReferenceSearch.search(sourceIdentifier, targetDomains));
assertEquals("An error occurred during CrossReference Search", exception.getMessage());
}
......@@ -103,10 +104,11 @@ public class PatientCrossReferenceSearchImplTest {
sourceIdentifier.setSystemIdentifier("toto");
sourceIdentifier.setValue("PatientIdentifiernotfound");
List<String> targetDomains = new ArrayList<>();
targetDomains.add("valid");
SearchCrossReferenceException exception = assertThrows(SearchCrossReferenceException.class,
() -> patientCrossReferenceSearch.search(sourceIdentifier,targetDomains));
() -> patientCrossReferenceSearch.search(sourceIdentifier, targetDomains));
assertEquals("Error in the sourceIdentifier : it doesn't match any identity", exception.getMessage());
assertEquals("Error in the sourceIdentifier : it does not match any identity", exception.getMessage());
}
@Test
......@@ -115,10 +117,11 @@ public class PatientCrossReferenceSearchImplTest {
sourceIdentifier.setSystemIdentifier("toto");
sourceIdentifier.setValue("PatientNotFound");
List<String> targetDomains = new ArrayList<>();
targetDomains.add("valid");
SearchCrossReferenceException exception = assertThrows(SearchCrossReferenceException.class,
() -> patientCrossReferenceSearch.search(sourceIdentifier,targetDomains));
() -> patientCrossReferenceSearch.search(sourceIdentifier, targetDomains));
assertEquals("Error in the sourceIdentifier : it doesn't match any Patient", exception.getMessage());
assertEquals("Error in the sourceIdentifier : it does not match any Patient", exception.getMessage());
}
@Test
......@@ -127,7 +130,8 @@ public class PatientCrossReferenceSearchImplTest {
sourceIdentifier.setSystemI