Skip to content

Commit

Permalink
FM2-635: ValueSetTranslatorImplTest relies on hidden context (#538)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibacher authored Nov 26, 2024
1 parent 983b724 commit 4970b16
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.hl7.fhir.r4.model.ValueSet;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.openmrs.Concept;
import org.openmrs.ConceptDescription;
import org.openmrs.ConceptMap;
Expand All @@ -34,33 +33,37 @@
import org.openmrs.ConceptReferenceTerm;
import org.openmrs.ConceptSet;
import org.openmrs.ConceptSource;
import org.openmrs.api.ConceptService;
import org.openmrs.api.context.ServiceContext;
import org.openmrs.module.fhir2.FhirTestConstants;
import org.openmrs.module.fhir2.TestFhirSpringConfiguration;
import org.openmrs.module.fhir2.api.FhirConceptSourceService;
import org.openmrs.module.fhir2.model.FhirConceptSource;
import org.openmrs.test.BaseModuleContextSensitiveTest;
import org.springframework.test.context.ContextConfiguration;

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

private static final String CONCEPT_UUID = "0f97e14e-cdc2-49ac-9255-b5126f8a5147";

@Mock
private ConceptService conceptService;

private FhirConceptSourceService conceptSourceService;

@Mock
private Concept concept;

private final ValueSetTranslatorImpl valueSetTranslator = new ValueSetTranslatorImpl();

@Before
public void setup() {
conceptService = mock(ConceptService.class);
conceptSourceService = mock(FhirConceptSourceService.class);
concept = mock(Concept.class);
valueSetTranslator.setConceptSourceService(conceptSourceService);
}

@Test
public void shouldTranslateConceptSetToValueSet() {
when(conceptService.getDefaultConceptMapType()).thenReturn(new ConceptMapType());
ServiceContext.getInstance().setConceptService(conceptService);

ConceptName conceptName = new ConceptName();
conceptName.setName("test");

Expand Down

0 comments on commit 4970b16

Please sign in to comment.