Commit 3668545b authored by Wylem Bars's avatar Wylem Bars

PATREG-33 | Sonar analysis : update coverage

parent 3c327a09
Pipeline #138072 passed with stages
in 8 minutes and 22 seconds
package net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.service.patient.search;
import net.ihe.gazelle.app.patientregistryapi.business.PatientSearchCriterionKey;
import net.ihe.gazelle.app.patientregistryservice.adapter.dao.pamsimulator.model.patient.PatientDB;
import net.ihe.gazelle.lib.searchmodelapi.business.searchcriterion.key.SearchCriterionKey;
import net.ihe.gazelle.lib.searchmodelapi.business.searchcriterion.operator.SearchCriterionOperator;
import net.ihe.gazelle.lib.searchmodelapi.business.searchcriterion.option.SearchCriterionOptions;
......@@ -10,6 +11,7 @@ import org.junit.jupiter.api.Test;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;
import javax.persistence.criteria.From;
import javax.persistence.criteria.Join;
import static org.junit.jupiter.api.Assertions.*;
......@@ -18,6 +20,7 @@ public class PatientSearchCriterionJPAMappingServiceTest {
private static final String PERSISTENCE_UNIT_NAME_CONST = "PersistenceUnitTest";
private EntityManager entityManager;
private From originalFrom;
/**
* Database init
......@@ -26,6 +29,7 @@ public class PatientSearchCriterionJPAMappingServiceTest {
public void initializeDatabase(){
entityManager = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME_CONST).createEntityManager();
entityManager.getTransaction().begin();
originalFrom = entityManager.getCriteriaBuilder().createQuery(PatientDB.class).from(PatientDB.class);
}
/**
......@@ -33,8 +37,6 @@ public class PatientSearchCriterionJPAMappingServiceTest {
*/
@Test
public void fromUuid(){
From originalFrom = new FromTestModel();
From from = new PatientSearchCriterionJPAMappingService(entityManager).from(PatientSearchCriterionKey.UUID, originalFrom);
assertEquals(originalFrom, from);
......@@ -45,8 +47,6 @@ public class PatientSearchCriterionJPAMappingServiceTest {
*/
@Test
public void fromDomain(){
From originalFrom = new FromTestModel();
From from = new PatientSearchCriterionJPAMappingService(entityManager).from(PatientSearchCriterionKey.DOMAIN, originalFrom);
assertNotNull(from, "from should not be null for domain");
......@@ -57,13 +57,12 @@ public class PatientSearchCriterionJPAMappingServiceTest {
*/
@Test
public void fromDomainMultiple() {
From originalFrom = new FromTestModel();
PatientSearchCriterionJPAMappingService patientSearchCriterionJPAMappingService = new PatientSearchCriterionJPAMappingService(entityManager);
patientSearchCriterionJPAMappingService.from(PatientSearchCriterionKey.DOMAIN, originalFrom);
patientSearchCriterionJPAMappingService.from(PatientSearchCriterionKey.DOMAIN, originalFrom);
From from = new PatientSearchCriterionJPAMappingService(entityManager).from(PatientSearchCriterionKey.DOMAIN, originalFrom);
From from2 = new PatientSearchCriterionJPAMappingService(entityManager).from(PatientSearchCriterionKey.DOMAIN, originalFrom);
assertNotNull(from, "from should not be null for domain");
assertEquals(from, from2);
assertEquals(1, originalFrom.getJoins().size());
assertEquals(1, ((Join) originalFrom.getJoins().iterator().next()).getJoins().size());
}
/**
......@@ -71,8 +70,6 @@ public class PatientSearchCriterionJPAMappingServiceTest {
*/
@Test
public void fromIdentifier(){
From originalFrom = new FromTestModel();
From from = new PatientSearchCriterionJPAMappingService(entityManager).from(PatientSearchCriterionKey.IDENTIFIER, originalFrom);
assertNotNull(from, "from should not be null for identifier");
......@@ -83,13 +80,11 @@ public class PatientSearchCriterionJPAMappingServiceTest {
*/
@Test
public void fromIdentifierMultiple() {
From originalFrom = new FromTestModel();
From from = new PatientSearchCriterionJPAMappingService(entityManager).from(PatientSearchCriterionKey.IDENTIFIER, originalFrom);
From from2 = new PatientSearchCriterionJPAMappingService(entityManager).from(PatientSearchCriterionKey.IDENTIFIER, originalFrom);
PatientSearchCriterionJPAMappingService patientSearchCriterionJPAMappingService = new PatientSearchCriterionJPAMappingService(entityManager);
patientSearchCriterionJPAMappingService.from(PatientSearchCriterionKey.IDENTIFIER, originalFrom);
patientSearchCriterionJPAMappingService.from(PatientSearchCriterionKey.IDENTIFIER, originalFrom);
assertNotNull(from, "from should not be null for identifier");
assertEquals(from, from2);
assertEquals(1, originalFrom.getJoins().size());
}
/**
......
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