Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add intergattion test for provider server #1325

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,7 @@ public PatientType readPatientType(String idString) {
public List<PatientType> getPatientTypes(String description) throws LIMSRuntimeException {
List<PatientType> list = new Vector<>();
try {
String sql = "from patientType l where upper(l.description) like upper(:param) order by"
+ " upper(l.description)";
String sql = "from PatientType l where upper(l.description) like upper(:param) order by upper(l.description)";
org.hibernate.query.Query query = entityManager.unwrap(Session.class).createQuery(sql);
query.setParameter("param", description + "%");

Expand Down
100 changes: 85 additions & 15 deletions src/test/java/org/openelisglobal/AppTestConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@

import static org.mockito.Mockito.mock;

import ca.uhn.fhir.context.FhirContext;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.ArrayList;
import java.util.List;
import lombok.NonNull;
import org.apache.http.impl.client.CloseableHttpClient;
import org.openelisglobal.audittrail.dao.AuditTrailService;
import org.openelisglobal.citystatezip.service.CityStateZipService;
import org.openelisglobal.common.services.IStatusService;
import org.openelisglobal.common.util.Versioning;
import org.openelisglobal.dataexchange.fhir.FhirConfig;
import org.openelisglobal.dataexchange.fhir.FhirUtil;
import org.openelisglobal.dataexchange.fhir.service.FhirPersistanceService;
import org.openelisglobal.dataexchange.fhir.service.FhirTransformService;
import org.openelisglobal.dataexchange.service.order.ElectronicOrderService;
import org.openelisglobal.externalconnections.service.BasicAuthenticationDataService;
import org.openelisglobal.externalconnections.service.ExternalConnectionService;
Expand All @@ -22,10 +28,11 @@
import org.openelisglobal.observationhistory.service.ObservationHistoryService;
import org.openelisglobal.observationhistorytype.service.ObservationHistoryTypeService;
import org.openelisglobal.organization.service.OrganizationService;
import org.openelisglobal.panel.service.PanelService;
import org.openelisglobal.panelitem.service.PanelItemService;
import org.openelisglobal.program.service.ImmunohistochemistrySampleService;
import org.openelisglobal.program.service.PathologySampleService;
import org.openelisglobal.program.service.ProgramSampleService;
import org.openelisglobal.provider.service.ProviderService;
import org.openelisglobal.referral.service.ReferralResultService;
import org.openelisglobal.referral.service.ReferralService;
import org.openelisglobal.referral.service.ReferralSetService;
Expand All @@ -35,9 +42,11 @@
import org.openelisglobal.sampleqaevent.service.SampleQaEventService;
import org.openelisglobal.siteinformation.service.SiteInformationService;
import org.openelisglobal.statusofsample.service.StatusOfSampleService;
import org.openelisglobal.systemusersection.service.SystemUserSectionService;
import org.openelisglobal.test.dao.TestDAO;
import org.openelisglobal.test.service.TestSectionService;
import org.openelisglobal.test.service.TestServiceImpl;
import org.openelisglobal.testanalyte.service.TestAnalyteService;
import org.openelisglobal.testresult.service.TestResultService;
import org.openelisglobal.typeofsample.service.TypeOfSampleService;
import org.openelisglobal.typeofsample.service.TypeOfSampleTestService;
Expand Down Expand Up @@ -77,10 +86,11 @@
"org.openelisglobal.view", "org.openelisglobal.search.service", "org.openelisglobal.sample",
"org.openelisglobal.sampleitem.", "org.openelisglobal.analysis", "org.openelisglobal.result.service",
"org.openelisglobal.result.daoimpl", "org.openelisglobal.resultlimit", "org.openelisglobal.resultlimits",
"org.openelisglobal.typeoftestresult", "org.openelisglobal.samplehuman",
"org.openelisglobal.typeoftestresult", "org.openelisglobal.samplehuman", "org.openelisglobal.provider",
"org.openelisglobal.role", }, excludeFilters = {
@ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openelisglobal.patient.controller.*"),
@ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openelisglobal.sample.controller.*"),
@ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openelisglobal.provider.controller.*"),
@ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openelisglobal.dictionary.controller.*.java"),
@ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openelisglobal.config.*"),
@ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openelisglobal.fhir.*"),
Expand All @@ -95,18 +105,84 @@ public FhirPersistanceService fhirPesistence() {
return mock(FhirPersistanceService.class);
}

@Bean()
@Profile("test")
public FhirContext fhirContext() {
return mock(FhirContext.class);
}

@Bean()
@Profile("test")
public FhirTransformService fhirTransformServicehirTransformService() {
return mock(FhirTransformService.class);
}

@Bean()
@Profile("test")
public LocalizationServiceImpl localise() {
return mock(LocalizationServiceImpl.class);
}

@Bean()
@Profile("test")
public FhirTransformService fhirTransformService() {
return mock(FhirTransformService.class);
}

@Bean()
@Profile("test")
public PanelService panelService() {
return mock(PanelService.class);
}

@Bean()
@Profile("test")
public PanelItemService panelItemService() {
return mock(PanelItemService.class);
}

@Bean()
@Profile("test")
public SystemUserSectionService stemUserSectionService() {
return mock(SystemUserSectionService.class);
}

@Bean()
@Profile("test")
public OrganizationService organizationService() {
return mock(OrganizationService.class);
}

@Bean()
@Profile("test")
public TestAnalyteService testAnalyteService() {
return mock(TestAnalyteService.class);
}

@Bean()
@Profile("test")
public FhirUtil fhirUtil() {
return mock(FhirUtil.class);
}

@Bean()
@Profile("test")
public FhirConfig fhirConfig() {
return mock(FhirConfig.class);
}

@Bean()
@Profile("test")
public LocalizationDAO localiseDao() {
return mock(LocalizationDAO.class);
}

@Bean()
@Profile("test")
public CloseableHttpClient cityStateZipServiceloseableHttpClient() {
return mock(CloseableHttpClient.class);
}

@Bean()
@Profile("test")
public ExternalConnectionService externalConnectService() {
Expand Down Expand Up @@ -143,12 +219,6 @@ public RequesterTypeService requesterTypeService() {
return mock(RequesterTypeService.class);
}

@Bean()
@Profile("test")
public OrganizationService organizationService() {
return mock(OrganizationService.class);
}

@Bean()
@Profile("test")
public BasicAuthenticationDataService basicAuthenticationDataService() {
Expand All @@ -167,12 +237,6 @@ public TestSectionService testSectionService() {
return mock(TestSectionService.class);
}

@Bean()
@Profile("test")
public ProviderService providerService() {
return mock(ProviderService.class);
}

@Bean()
@Profile("test")
public UserRoleService userRoleService() {
Expand Down Expand Up @@ -239,6 +303,12 @@ public ReferralResultService ReferralResultService() {
return mock(ReferralResultService.class);
}

@Bean()
@Profile("test")
public CityStateZipService cityStateZipService() {
return mock(CityStateZipService.class);
}

@Bean()
@Profile("test")
public ReferralService referralService() {
Expand Down Expand Up @@ -346,4 +416,4 @@ public void configureMessageConverters(@NonNull List<HttpMessageConverter<?>> co
converters.add(new StringHttpMessageConverter());
converters.add(jsonConverter());
}
}
}
71 changes: 35 additions & 36 deletions src/test/java/org/openelisglobal/patient/PatientServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public void init() throws Exception {
patientService.deleteAll(patientService.getAll());
personService.deleteAll(personService.getAll());
patientTypeService.deleteAll(patientTypeService.getAll());

}

@After
Expand All @@ -62,41 +61,6 @@ public void tearDown() {
patientTypeService.deleteAll(patientTypeService.getAll());
}

@Test
public void createPatient_shouldCreateNewPatient() throws Exception {
String firstName = "John";
String lastname = "Doe";
String dob = "12/12/1992";
String gender = "M";
Patient pat = createPatient(firstName, lastname, dob, gender);

Assert.assertEquals(0, patientService.getAllPatients().size());

String patientId = patientService.insert(pat);
Patient savedPatient = patientService.get(patientId);

Assert.assertEquals(1, patientService.getAllPatients().size());
Assert.assertEquals(firstName, savedPatient.getPerson().getFirstName());
Assert.assertEquals(lastname, savedPatient.getPerson().getLastName());
Assert.assertEquals(gender, savedPatient.getGender());
}

@Test
public void getData_shouldCopyPropertiesFromDatabase() throws Exception {
String firstName = "John";
String lastname = "Doe";
String dob = "12/12/1992";
String gender = "M";
Patient patient = createPatient(firstName, lastname, dob, gender);
String patientId = patientService.insert(patient);

Patient savedPatient = new Patient();
savedPatient.setId(patientId);
patientService.getData(savedPatient);

Assert.assertEquals(gender, savedPatient.getGender());
}

@Test
public void getSubjectNumber_shouldReturnSubjectNumber() throws Exception {
String firstName = "John";
Expand Down Expand Up @@ -504,6 +468,41 @@ public void getPatientForGuid_shouldReturnPatientForGuid() throws Exception {
Assert.assertEquals(gender, savedPatient.getGender());
}

@Test
public void createPatient_shouldCreateNewPatient() throws Exception {
String firstName = "John";
String lastname = "Doe";
String dob = "12/12/1992";
String gender = "M";
Patient pat = createPatient(firstName, lastname, dob, gender);

Assert.assertEquals(0, patientService.getAllPatients().size());

String patientId = patientService.insert(pat);
Patient savedPatient = patientService.get(patientId);

Assert.assertEquals(1, patientService.getAllPatients().size());
Assert.assertEquals(firstName, savedPatient.getPerson().getFirstName());
Assert.assertEquals(lastname, savedPatient.getPerson().getLastName());
Assert.assertEquals(gender, savedPatient.getGender());
}

@Test
public void getData_shouldCopyPropertiesFromDatabase() throws Exception {
String firstName = "John";
String lastname = "Doe";
String dob = "12/12/1992";
String gender = "M";
Patient patient = createPatient(firstName, lastname, dob, gender);
String patientId = patientService.insert(patient);

Patient savedPatient = new Patient();
savedPatient.setId(patientId);
patientService.getData(savedPatient);

Assert.assertEquals(gender, savedPatient.getGender());
}

@Test
public void getData_shouldCopyPropertiesFromDatabaseById() throws Exception {
String firstName = "John";
Expand Down
Loading
Loading