Source:
public void shouldCreateEncounterWithGivenParameters() { Location location = new Location(); location.setName("testLocation"); Patient patient = new Patient(); patient.setUuid("10"); Provider provider = new Provider(); provider.setUuid("20"); Person person = new Person(); person.setUuid("30"); provider.setPerson(person); DateTime encounterDatetime = new DateTime("2000-08-16T07:22:05Z"); Map<String, String> observations = new HashMap<>(); observations.put("testConceptName","testObservationValueName"); List<Observation> obsList = createObservationList(); Encounter encounter = new Encounter(location, new EncounterType("testEncounterType"), encounterDatetime.toDate(), patient, Collections.singletonList(provider.getPerson()), obsList); doReturn(patient).when(patientService).getPatientByUuid(eq(CONFIG_NAME), eq(patient.getUuid())); doReturn(provider).when(providerService).getProviderByUuid(eq(CONFIG_NAME), eq(provider.getUuid())); doReturn(encounter).when(encounterService).createEncounter(eq(CONFIG_NAME), eq(encounter)); doReturn(Collections.singletonList(location)) .when(locationService).getLocations(eq(CONFIG_NAME), eq(location.getName())); openMRSActionProxyService.createEncounter(CONFIG_NAME, new DateTime(encounter.getEncounterDatetime()), encounter.getEncounterType().getName(), location.getName(), patient.getUuid(), provider.getUuid(), observations); verify(encounterService).createEncounter(eq(CONFIG_NAME), encounterCaptor.capture()); assertEquals(encounter, encounterCaptor.getValue()); assertEquals(encounter, openMRSActionProxyService.createEncounter(CONFIG_NAME, new DateTime(encounter.getEncounterDatetime()), encounter.getEncounterType().getName(), location.getName(), patient.getUuid(), provider.getUuid(), observations)); }

Target:
public void shouldCreateEncounterWithGivenParameters() { Location location = new Location(); location.setName("testLocation"); Patient patient = new Patient(); patient.setUuid("10"); Provider provider = new Provider(); provider.setUuid("20"); Person person = new Person(); person.setUuid("30"); provider.setPerson(person); DateTime encounterDatetime = new DateTime("2000-08-16T07:22:05Z"); Map<String, String> observations = new HashMap<>(); observations.put("testConceptName","testObservationValueName"); List<Observation> obsList = createObservationList(); Encounter encounter = new Encounter(location, new EncounterType("testEncounterType"), encounterDatetime.toDate(), patient, Collections.singletonList(provider.getPerson()), obsList); doReturn(patient).when(patientService).getPatientByUuid(eq(CONFIG_NAME), eq(patient.getUuid())); doReturn(provider).when(providerService).getProviderByUuid(eq(CONFIG_NAME), eq(provider.getUuid())); doReturn(encounter).when(encounterService).createEncounter(eq(CONFIG_NAME), eq(encounter)); doReturn(Collections.singletonList(location)) .when(locationService).getLocations(eq(CONFIG_NAME), eq(location.getName())); Encounter encounterCreated = openMRSActionProxyService.createEncounter(CONFIG_NAME, new DateTime(encounter.getEncounterDatetime()), encounter.getEncounterType().getName(), location.getName(), patient.getUuid(), provider.getUuid(), observations); assertEquals(encounter, encounterCreated); }