Commit 13bc593f authored by Franck Desaize's avatar Franck Desaize
Browse files

Fixe DomainDAO and Test

parent e0494509
Pipeline #273092 failed with stages
in 6 minutes and 54 seconds
......@@ -9,10 +9,7 @@ import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.servi
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.service.IdentifierDAO;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.service.PatientDAO;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.service.patient.search.PatientSearchDAO;
import net.ihe.gazelle.app.patientregistryservice.application.exceptions.PatientCreationException;
import net.ihe.gazelle.app.patientregistryservice.application.exceptions.PatientDeleteException;
import net.ihe.gazelle.app.patientregistryservice.application.exceptions.PatientNotFoundException;
import net.ihe.gazelle.app.patientregistryservice.application.exceptions.PatientReadException;
import net.ihe.gazelle.app.patientregistryservice.application.exceptions.*;
import net.ihe.gazelle.framework.loggerservice.application.GazelleLogger;
import net.ihe.gazelle.framework.loggerservice.application.GazelleLoggerFactory;
import net.ihe.gazelle.lib.searchmodelapi.business.SearchCriteria;
......@@ -101,7 +98,11 @@ public class PatientDAOImpl implements PatientDAO {
iterator.remove();
identifiersFromDB.add(patientIdentifierFromDB);
} else if (patientIdentifierDB.getDomain() != null) {
patientIdentifierDB.setDomain(domainDAO.retrieve(patientIdentifierDB.getDomain().getUniversalID()));
try {
patientIdentifierDB.setDomain(domainDAO.retrieve(patientIdentifierDB.getDomain().getUniversalID()));
} catch (DomainSearchException e) {
throw new PatientCreationException("System not found",e);
}
}
}
patientDB.getPatientIdentifiers().addAll(identifiersFromDB);
......
......@@ -6,9 +6,12 @@ import net.ihe.gazelle.app.patientregistryapi.business.PatientSearchCriterionKey
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.service.DomainDAOImpl;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.service.IdentifierDAOImpl;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.service.patient.PatientDAOImpl;
import net.ihe.gazelle.app.patientregistryservice.application.exceptions.DomainSearchException;
import net.ihe.gazelle.app.patientregistryservice.application.exceptions.PatientCreationException;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.service.PatientDAO;
import net.ihe.gazelle.app.patientregistryservice.application.exceptions.PatientDeleteException;
import net.ihe.gazelle.framework.loggerservice.application.GazelleLogger;
import net.ihe.gazelle.framework.loggerservice.application.GazelleLoggerFactory;
import net.ihe.gazelle.lib.searchmodelapi.business.SearchCriteria;
import net.ihe.gazelle.lib.searchmodelapi.business.SearchCriteriaLogicalOperator;
import net.ihe.gazelle.lib.searchmodelapi.business.exception.SearchException;
......@@ -27,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.*;
public class PatientSearchDAOTest {
private static final String PERSISTENCE_UNIT_NAME_CONST = "PersistenceUnitTest";
private static final GazelleLogger log = GazelleLoggerFactory.getInstance().getLogger(PatientSearchDAOTest.class);
private EntityManager entityManager;
private PatientSearchDAO patientSearchDAO;
private DomainDAOImpl domainDAO;
......@@ -212,7 +215,7 @@ public class PatientSearchDAOTest {
* Test Patient search on Domain with multiple patients in DB.
*/
@Test
public void patientSearchDomainMultiplePatient() throws SearchException, PatientCreationException, PatientDeleteException {
public void patientSearchDomainMultiplePatient() throws SearchException, PatientCreationException, PatientDeleteException, DomainSearchException {
Patient patient = new Patient();
String uuid = "test-uuid0°";
patient.setUuid(uuid);
......@@ -441,7 +444,7 @@ public class PatientSearchDAOTest {
private void createIdentifiersDomainIfMissing(List<EntityIdentifier> identifiers) {
identifiers.forEach(identifier -> {
if(identifier.getSystemIdentifier() != null && !domainDAO.exist(identifier.getSystemIdentifier())) {
domainDAO.createDomain(identifier.getSystemIdentifier(), identifier.getSystemName());
domainDAO.createDomain(identifier.getSystemIdentifier(), identifier.getSystemName());
}
});
}
......
......@@ -10,6 +10,7 @@ import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.servi
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.service.patient.search.PatientSearchCriterionJPAMappingService;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.service.patient.search.PatientSearchDAO;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.service.patient.search.PatientSearchResultJPAMappingService;
import net.ihe.gazelle.app.patientregistryservice.application.exceptions.DomainSearchException;
import net.ihe.gazelle.app.patientregistryservice.application.exceptions.PatientDeleteException;
import net.ihe.gazelle.lib.searchmodelapi.business.exception.SearchException;
import org.junit.jupiter.api.AfterEach;
......@@ -150,7 +151,7 @@ public class PatientFeedApplicationTest {
* test create + retrieve one patient with existing domain
*/
@Test
public void patientCreationExistingDomainTest() throws PatientFeedException, PatientRetrieveException, PatientDeleteException, SearchException {
public void patientCreationExistingDomainTest() throws PatientFeedException, PatientRetrieveException, PatientDeleteException, SearchException, DomainSearchException {
Patient patient = new Patient();
String domainIdentifier = "domainIdentifier";
String domainName = "domainName";
......@@ -177,7 +178,7 @@ public class PatientFeedApplicationTest {
* test create + retrieve one patient with non-existing domain
*/
@Test
public void patientCreationNonExistingDomainTest() throws PatientFeedException, PatientRetrieveException, PatientDeleteException, SearchException {
public void patientCreationNonExistingDomainTest() throws PatientFeedException, PatientRetrieveException, PatientDeleteException, SearchException, DomainSearchException {
Patient patient = new Patient();
String domainIdentifier = "domainIdentifier";
String domainName = "domainName";
......
......@@ -57,6 +57,23 @@
<property name="hibernate.transaction.auto_close_session" value="true"/>
<!-- <property name="hibernate.hibernate.hbm2ddl.auto" value="create-drop"/>-->
</properties>
</persistence-unit><persistence-unit name="PersistenceUnitDomainTest" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.model.patient.HierarchicDesignatorDB</class>
<properties>
<!-- Configuring JDBC properties -->
<property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:PersistenceUnitCrossRefTest;MODE=PostgreSQL;DATABASE_TO_LOWER=TRUE"/>
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
<!-- Hibernate properties -->
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="hibernate.hbm2ddl.auto" value="create"/>
<property name="hibernate.format_sql" value="false"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.connection.autocommit" value="true"/>
<property name="hibernate.transaction.auto_close_session" value="true"/>
<!-- <property name="hibernate.hibernate.hbm2ddl.auto" value="create-drop"/>-->
</properties>
</persistence-unit>
......
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