Skip to content

Commit

Permalink
FM2-652 - Update unit and integration tests to remove test conflicts …
Browse files Browse the repository at this point in the history
…and fix resulting failures (#555)
  • Loading branch information
mseaton authored Jan 6, 2025
1 parent 46e3b96 commit 29dce59
Show file tree
Hide file tree
Showing 63 changed files with 347 additions and 612 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ jobs:
path: ${{ github.workspace }}/omod/target
- name: run db and web containers
run: |
docker-compose -f docker/docker-compose-refqa.yml up -d
docker compose -f docker/docker-compose-refqa.yml up -d
- name: wait for openmrs instance to start
run: while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost:8080/openmrs/login.htm)" != "200" ]]; do sleep 1; done
- name: Run End to End tests
run: mvn verify --batch-mode -P e2e-test --file pom.xml
- name: Stop db and web containers
if: always()
run: docker-compose -f "docker/docker-compose-refqa.yml" down
run: docker compose -f "docker/docker-compose-refqa.yml" down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.Optional;

import ca.uhn.fhir.rest.param.StringAndListParam;
import lombok.AccessLevel;
import lombok.Setter;
import org.hibernate.Criteria;
import org.hibernate.transform.DistinctRootEntityResultTransformer;
Expand All @@ -38,7 +37,7 @@
import org.springframework.stereotype.Component;

@Component
@Setter(AccessLevel.PACKAGE)
@Setter
public class FhirConceptDaoImpl extends BaseFhirDao<Concept> implements FhirConceptDao {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.util.List;
import java.util.Optional;

import lombok.AccessLevel;
import lombok.Setter;
import org.openmrs.Concept;
import org.openmrs.ConceptMap;
Expand All @@ -26,7 +25,7 @@

@Component
@Transactional
@Setter(AccessLevel.PACKAGE)
@Setter
public class FhirConceptServiceImpl implements FhirConceptService {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import java.util.Collection;
import java.util.Optional;

import lombok.AccessLevel;
import lombok.Setter;
import org.openmrs.ConceptSource;
import org.openmrs.Duration;
Expand All @@ -28,7 +27,7 @@

@Component
@Transactional
@Setter(AccessLevel.PACKAGE)
@Setter
public class FhirConceptSourceServiceImpl implements FhirConceptSourceService {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ public Type toFhirResource(@Nonnull Obs obs) {

// IMPORTANT boolean values are stored as a coded value, so for this to
// work, we must check for a boolean value before a general coded value
if (obs.getValueBoolean() != null) {
return new BooleanType(obs.getValueBoolean());
Boolean valueBoolean = getValueBoolean(obs);
if (valueBoolean != null) {
return new BooleanType(valueBoolean);
} else if (obs.getValueCoded() != null) {
return conceptTranslator.toFhirResource(obs.getValueCoded());
} else if (obs.getValueDrug() != null) {
Expand Down Expand Up @@ -99,11 +100,25 @@ public Obs toOpenmrsType(@Nonnull Obs obs, @Nonnull Type resource) {
} else if (resource instanceof Quantity) {
obs.setValueNumeric(((Quantity) resource).getValue().doubleValue());
} else if (resource instanceof BooleanType) {
obs.setValueBoolean(((BooleanType) resource).getValue());
setValueBoolean(obs, ((BooleanType) resource).getValue());
} else if (resource instanceof StringType) {
obs.setValueText(((StringType) resource).getValue());
}

return obs;
}

/**
* @return the valueBoolean of the given obs
*/
protected Boolean getValueBoolean(Obs obs) {
return obs.getValueBoolean();
}

/**
* sets the valueBoolean property of the given obs to the given value
*/
protected void setValueBoolean(Obs obs, Boolean valueBoolean) {
obs.setValueBoolean(valueBoolean);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,16 @@
*/
package org.openmrs.module.fhir2;

import org.mockito.Mockito;
import org.openmrs.module.fhir2.api.util.LocalDateTimeFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.junit.Before;
import org.openmrs.module.fhir2.api.util.FhirGlobalPropertyHolder;
import org.openmrs.test.BaseModuleContextSensitiveTest;
import org.springframework.test.context.ContextConfiguration;

@Configuration
public class MockedCalendarFactoryConfiguration {
@ContextConfiguration(classes = { TestFhirSpringConfiguration.class }, inheritLocations = false)
public abstract class BaseFhirContextSensitiveTest extends BaseModuleContextSensitiveTest {

@Bean
@Primary
public LocalDateTimeFactory getCalendarFactory() {
return Mockito.mock(LocalDateTimeFactory.class);
@Before
public void setupBaseFhirContextSensitive() {
FhirGlobalPropertyHolder.reset();
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,19 @@
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;

import org.hibernate.SessionFactory;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.openmrs.Allergen;
import org.openmrs.AllergenType;
import org.openmrs.Allergy;
import org.openmrs.AllergyReaction;
import org.openmrs.Concept;
import org.openmrs.module.fhir2.TestFhirSpringConfiguration;
import org.openmrs.module.fhir2.api.FhirGlobalPropertyService;
import org.openmrs.module.fhir2.BaseFhirContextSensitiveTest;
import org.openmrs.module.fhir2.api.dao.FhirAllergyIntoleranceDao;
import org.openmrs.module.fhir2.api.dao.FhirConceptDao;
import org.openmrs.test.BaseModuleContextSensitiveTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;

@ContextConfiguration(classes = TestFhirSpringConfiguration.class, inheritLocations = false)
public class FhirAllergyIntoleranceDaoImplTest extends BaseModuleContextSensitiveTest {
public class FhirAllergyIntoleranceDaoImplTest extends BaseFhirContextSensitiveTest {

private static final String ALLERGY_INTOLERANCE_INITIAL_DATA_XML = "org/openmrs/module/fhir2/api/dao/impl/FhirAllergyIntoleranceDaoImplTest_initial_data.xml";

Expand All @@ -43,22 +37,13 @@ public class FhirAllergyIntoleranceDaoImplTest extends BaseModuleContextSensitiv
private static final String CODED_REACTION_UUID = "5087AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";

@Autowired
@Qualifier("sessionFactory")
private SessionFactory sessionFactory;

@Mock
private FhirGlobalPropertyService globalPropertyService;

private FhirAllergyIntoleranceDaoImpl allergyDao;
private FhirAllergyIntoleranceDao allergyDao;

@Autowired
private FhirConceptDao conceptDao;

@Before
public void setup() throws Exception {
allergyDao = new FhirAllergyIntoleranceDaoImpl();
allergyDao.setSessionFactory(sessionFactory);
allergyDao.setGlobalPropertyService(globalPropertyService);
executeDataSet(ALLERGY_INTOLERANCE_INITIAL_DATA_XML);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,12 @@
import org.openmrs.ConceptSource;
import org.openmrs.api.ConceptService;
import org.openmrs.api.context.Context;
import org.openmrs.module.fhir2.TestFhirSpringConfiguration;
import org.openmrs.module.fhir2.BaseFhirContextSensitiveTest;
import org.openmrs.module.fhir2.api.dao.FhirConceptDao;
import org.openmrs.test.BaseModuleContextSensitiveTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;

@ContextConfiguration(classes = TestFhirSpringConfiguration.class, inheritLocations = false)
public class FhirConceptDaoImplTest extends BaseModuleContextSensitiveTest {
public class FhirConceptDaoImplTest extends BaseFhirContextSensitiveTest {

private static final String CONCEPT_DATA_XML = "org/openmrs/api/include/ConceptServiceTest-initialConcepts.xml";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,12 @@
import org.junit.Test;
import org.openmrs.ConceptSource;
import org.openmrs.api.ConceptService;
import org.openmrs.module.fhir2.BaseFhirContextSensitiveTest;
import org.openmrs.module.fhir2.FhirTestConstants;
import org.openmrs.module.fhir2.TestFhirSpringConfiguration;
import org.openmrs.module.fhir2.model.FhirConceptSource;
import org.openmrs.test.BaseModuleContextSensitiveTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;

@ContextConfiguration(classes = TestFhirSpringConfiguration.class, inheritLocations = false)
public class FhirConceptSourceDaoImplTest extends BaseModuleContextSensitiveTest {
public class FhirConceptSourceDaoImplTest extends BaseFhirContextSensitiveTest {

private static final String CONCEPT_SOURCE_FHIR_DATA = "org/openmrs/module/fhir2/api/dao/impl/FhirConceptSourceDaoImplTest_initial_data.xml";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,11 @@
import org.openmrs.ConditionVerificationStatus;
import org.openmrs.api.ConceptService;
import org.openmrs.api.PatientService;
import org.openmrs.module.fhir2.TestFhirSpringConfiguration;
import org.openmrs.test.BaseModuleContextSensitiveTest;
import org.openmrs.module.fhir2.BaseFhirContextSensitiveTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;

@ContextConfiguration(classes = TestFhirSpringConfiguration.class, inheritLocations = false)
public class FhirConditionDaoImpl_Test extends BaseModuleContextSensitiveTest {
public class FhirConditionDaoImpl_Test extends BaseFhirContextSensitiveTest {

private static final String CONDITION_UUID = "2cc6880e-2c46-15e4-9038-a6c5e4d22fb7";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,12 @@
import org.openmrs.api.LocationService;
import org.openmrs.api.PersonService;
import org.openmrs.api.ProviderService;
import org.openmrs.module.fhir2.TestFhirSpringConfiguration;
import org.openmrs.module.fhir2.BaseFhirContextSensitiveTest;
import org.openmrs.module.fhir2.api.FhirContactPointMapService;
import org.openmrs.module.fhir2.model.FhirContactPointMap;
import org.openmrs.test.BaseModuleContextSensitiveTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;

@ContextConfiguration(classes = TestFhirSpringConfiguration.class, inheritLocations = false)
public class FhirContactPointMapDaoImplTest extends BaseModuleContextSensitiveTest {
public class FhirContactPointMapDaoImplTest extends BaseFhirContextSensitiveTest {

@Autowired
private SessionFactory sessionFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,12 @@
import org.openmrs.api.ConceptService;
import org.openmrs.api.ObsService;
import org.openmrs.api.PatientService;
import org.openmrs.module.fhir2.TestFhirSpringConfiguration;
import org.openmrs.module.fhir2.BaseFhirContextSensitiveTest;
import org.openmrs.module.fhir2.model.FhirDiagnosticReport;
import org.openmrs.test.BaseModuleContextSensitiveTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;

@ContextConfiguration(classes = TestFhirSpringConfiguration.class, inheritLocations = false)
public class FhirDiagnosticReportDaoImplTest extends BaseModuleContextSensitiveTest {
public class FhirDiagnosticReportDaoImplTest extends BaseFhirContextSensitiveTest {

private static final String DATA_XML = "org/openmrs/module/fhir2/api/dao/impl/FhirDiagnosticReportDaoImplTest_initial_data.xml";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,13 @@
import org.openmrs.Encounter;
import org.openmrs.Order;
import org.openmrs.api.context.Context;
import org.openmrs.module.fhir2.BaseFhirContextSensitiveTest;
import org.openmrs.module.fhir2.FhirConstants;
import org.openmrs.module.fhir2.TestFhirSpringConfiguration;
import org.openmrs.module.fhir2.api.search.param.SearchParameterMap;
import org.openmrs.test.BaseModuleContextSensitiveTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;

@ContextConfiguration(classes = TestFhirSpringConfiguration.class, inheritLocations = false)
public class FhirEncounterDaoImplTest extends BaseModuleContextSensitiveTest {
public class FhirEncounterDaoImplTest extends BaseFhirContextSensitiveTest {

private static final String ENCOUNTER_UUID = "430bbb70-6a9c-4e1e-badb-9d1034b1b5e9";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@
import org.junit.Before;
import org.junit.Test;
import org.openmrs.PatientProgram;
import org.openmrs.module.fhir2.TestFhirSpringConfiguration;
import org.openmrs.test.BaseModuleContextSensitiveTest;
import org.openmrs.module.fhir2.BaseFhirContextSensitiveTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;

@ContextConfiguration(classes = TestFhirSpringConfiguration.class, inheritLocations = false)
public class FhirEpisodeOfCareDaoImplTest extends BaseModuleContextSensitiveTest {
public class FhirEpisodeOfCareDaoImplTest extends BaseFhirContextSensitiveTest {

private static final String ENCOUNTER_INITIAL_DATA_XML = "org/openmrs/module/fhir2/api/dao/impl/FhirEpisodeOfCareDaoImpl_2_2Test_initial_data.xml";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,11 @@
import org.junit.Before;
import org.junit.Test;
import org.openmrs.Cohort;
import org.openmrs.module.fhir2.TestFhirSpringConfiguration;
import org.openmrs.test.BaseModuleContextSensitiveTest;
import org.openmrs.module.fhir2.BaseFhirContextSensitiveTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;

@ContextConfiguration(classes = TestFhirSpringConfiguration.class, inheritLocations = false)
public class FhirGroupDaoImplTest extends BaseModuleContextSensitiveTest {
public class FhirGroupDaoImplTest extends BaseFhirContextSensitiveTest {

private static final String COHORT_UUID = "1d64befb-3b2e-48e5-85f5-353d43e23e46";

Expand Down
Loading

0 comments on commit 29dce59

Please sign in to comment.