Commit 6c37135c authored by Matthieu Bonnouvrier's avatar Matthieu Bonnouvrier
Browse files

Rework TUs

parent d336fbb7
Pipeline #263939 failed with stages
in 7 minutes and 6 seconds
......@@ -66,17 +66,12 @@ public class PatientCrossReferenceSearchImpl implements PatientCrossReferenceSea
if (searchCrossReferenceException.getMessage().equals("Search error : No X-ref for given Patient")) {
return convertPatientDBToPatientAliases(patientDB);
}
if(searchCrossReferenceException.getMessage().equals("The current target domain could not be found")){
throw new SearchCrossReferenceException("An error in the target domain list : one does not exist");
}
} catch (Exception exception) {
throw new SearchCrossReferenceException("An error occurred during CrossReference Search", exception);
}
if(targetDomainUsable) {
if (targetDomainUsable) {
return removePatientFromPatientAliasWithNonMatchingTargetDomain(patientAlias, targetDomains);
}else{
} else {
return patientAlias;
}
}
......@@ -100,19 +95,19 @@ public class PatientCrossReferenceSearchImpl implements PatientCrossReferenceSea
/**
* Check if the list of target domain contains the current source identifier
* Return true if the list is not empty, false otherwise
*
* @param targetDomains
* @throws UnrecognizedDomainException
* @throws SearchCrossReferenceException
*/
private boolean isTargetDomainsUsable(List<String> targetDomains) throws SearchCrossReferenceException {
if (!targetDomains.isEmpty()) {
try {
targetDomains.forEach(targetDomain -> domainService.exist(targetDomain));
} catch (NoResultException e) {
throw new SearchCrossReferenceException("The current target domain could not be found");
for (String targetDomain : targetDomains) {
if (!targetDomain.isBlank() && !domainService.exist(targetDomain)) {
throw new SearchCrossReferenceException("An error in the target domain list : one does not exist");
}
}
return true;
}else{
} else {
return false;
}
}
......
......@@ -170,7 +170,7 @@ public class PatientCrossReferenceSearchImplTest {
@Test
public void searchWithZeroTargetDomainMatching() throws SearchCrossReferenceException {
EntityIdentifier sourceIdentifier1 = new EntityIdentifier();
sourceIdentifier1.setSystemIdentifier("toto");
sourceIdentifier1.setSystemIdentifier("valid");
sourceIdentifier1.setValue("searchTargetDomainFound");
EntityIdentifier entityIdentifier2 = new EntityIdentifier();
......@@ -182,41 +182,17 @@ public class PatientCrossReferenceSearchImplTest {
entityIdentifier3.setValue("3456");
List<String> targetDomains = new ArrayList<>();
targetDomains.add("2222");
targetDomains.add("3333");
targetDomains.add("valid");
PatientAliases patientAliases = patientCrossReferenceSearch.search(sourceIdentifier1, targetDomains);
assert (patientAliases.getMembers().size() == 0);
}
@Test
public void searchWithOneTargetDomainMatching() throws SearchCrossReferenceException {
EntityIdentifier sourceIdentifier1 = new EntityIdentifier();
sourceIdentifier1.setSystemIdentifier("Retrieved11");
sourceIdentifier1.setValue("searchTargetDomainFound");
EntityIdentifier entityIdentifier2 = new EntityIdentifier();
entityIdentifier2.setSystemIdentifier("2222");
entityIdentifier2.setValue("2345");
EntityIdentifier entityIdentifier3 = new EntityIdentifier();
entityIdentifier3.setSystemIdentifier("3333");
entityIdentifier3.setValue("3456");
List<String> targetDomains = new ArrayList<>();
targetDomains.add("Retrieved11");
targetDomains.add("2222");
targetDomains.add("3333");
PatientAliases patientAliases = patientCrossReferenceSearch.search(sourceIdentifier1, targetDomains);
assert (patientAliases.getMembers().size() == 1);
}
@Test
void testWithUnkwownTargetDomain() throws SearchCrossReferenceException {
EntityIdentifier entityIdentifier = new EntityIdentifier();
entityIdentifier.setSystemIdentifier("1111");
entityIdentifier.setValue("1234");
entityIdentifier.setValue("searchTargetDomainFound");
EntityIdentifier entityIdentifier2 = new EntityIdentifier();
entityIdentifier2.setSystemIdentifier("2222");
......
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