Skip to content

Commit

Permalink
Fixed unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
icrc-psousa committed Jul 2, 2024
1 parent af66ac6 commit e1c53ae
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.openmrs.Provider;
import org.openmrs.api.EncounterService;
import org.openmrs.module.fhir2.FhirConstants;
import org.openmrs.module.fhir2.api.FhirGlobalPropertyService;
import org.openmrs.module.fhir2.api.dao.FhirPractitionerDao;

@RunWith(MockitoJUnitRunner.class)
Expand All @@ -44,6 +45,9 @@ public class EncounterParticipantTranslatorImplTest {
@Mock
private EncounterService encounterService;

@Mock
private FhirGlobalPropertyService globalPropertyService;

private EncounterParticipantTranslatorImpl participantTranslator;

private EncounterProvider encounterProvider;
Expand All @@ -56,6 +60,7 @@ public class EncounterParticipantTranslatorImplTest {
public void setUp() {
participantTranslator = new EncounterParticipantTranslatorImpl();
participantTranslator.setPractitionerDao(practitionerDao);
participantTranslator.setGlobalPropertyService(globalPropertyService);

encounterProvider = new EncounterProvider();
provider = new Provider();
Expand Down Expand Up @@ -88,7 +93,8 @@ public void shouldTranslateEncounterProviderToFhirTypeWithCorrectIndividualRefer

@Test
public void shouldTranslateEncounterParticipantToOpenMrsType() {
when(encounterService.getEncounterRoleByName("Unknown")).thenReturn(new EncounterRole());
when(encounterService.getEncounterRoleByUuid(EncounterRole.UNKNOWN_ENCOUNTER_ROLE_UUID))
.thenReturn(new EncounterRole());
EncounterProvider encounterProvider = participantTranslator.toOpenmrsType(new EncounterProvider(),
encounterParticipantComponent);
assertThat(encounterProvider, notNullValue());
Expand All @@ -97,7 +103,8 @@ public void shouldTranslateEncounterParticipantToOpenMrsType() {
@Test
public void shouldTranslateEncounterParticipantToEncounterProviderWithCorrectProvider() {
when(practitionerDao.get(PROVIDER_UUID)).thenReturn(provider);
when(encounterService.getEncounterRoleByName("Unknown")).thenReturn(new EncounterRole());
when(encounterService.getEncounterRoleByUuid(EncounterRole.UNKNOWN_ENCOUNTER_ROLE_UUID))
.thenReturn(new EncounterRole());

EncounterProvider encounterProvider = participantTranslator.toOpenmrsType(new EncounterProvider(),
encounterParticipantComponent);
Expand Down

0 comments on commit e1c53ae

Please sign in to comment.