Source:
public void shouldCreatePatientWithDefaultLocationWhenLocationNameIsNotProvided() { Person person = createTestPerson(); Location location = new Location(); location.setName(OpenMRSActionProxyService.DEFAULT_LOCATION_NAME); Identifier identifier = new Identifier("1000", new IdentifierType("CommCare CaseID")); identifier.setLocation(location); Patient patient = new Patient(Collections.singletonList(identifier), person, "500", location); Map<String, String> identifiersMap = new HashMap<>(); identifiersMap.put("CommCare CaseID", "1000"); doReturn(Collections.singletonList(location)) .when(locationService).getLocations(eq(CONFIG_NAME), eq(OpenMRSActionProxyService.DEFAULT_LOCATION_NAME)); Person.Address personAddress = person.getPreferredAddress(); openMRSActionProxyService.createPatient(CONFIG_NAME, person.getPreferredName().getGivenName(), person.getPreferredName().getMiddleName(), person.getPreferredName().getFamilyName(), personAddress.getAddress1(), personAddress.getAddress2(), personAddress.getAddress3(), personAddress.getAddress4(), personAddress.getAddress5(), personAddress.getAddress6(), personAddress.getCityVillage(), personAddress.getStateProvince(), personAddress.getCountry(), personAddress.getPostalCode(), personAddress.getCountyDistrict(), personAddress.getLatitude(), personAddress.getLongitude(), new DateTime(personAddress.getStartDate()), new DateTime(personAddress.getEndDate()), new DateTime(person.getBirthdate()), person.getBirthdateEstimated(), person.getGender(), person.getDead(), "", patient.getMotechId(), location.getName(), identifiersMap); verify(patientService).createPatient(eq(CONFIG_NAME), patientCaptor.capture()); assertEquals(patient, patientCaptor.getValue()); }

Target:
public void shouldCreatePatientWithDefaultLocationWhenLocationNameIsNotProvided() { Person person = createTestPerson(); Location location = new Location(); location.setName(OpenMRSActionProxyService.DEFAULT_LOCATION_NAME); Identifier identifier = new Identifier("1000", new IdentifierType("CommCare CaseID")); Patient patient = new Patient(Collections.singletonList(identifier), person, "500", location); Map<String, String> identifiersMap = new HashMap<>(); identifiersMap.put("CommCare CaseID", "1000"); doReturn(Collections.singletonList(location)) .when(locationService).getLocations(eq(CONFIG_NAME), eq(OpenMRSActionProxyService.DEFAULT_LOCATION_NAME)); Person.Address personAddress = person.getPreferredAddress(); openMRSActionProxyService.createPatient(CONFIG_NAME, person.getPreferredName().getGivenName(), person.getPreferredName().getMiddleName(), person.getPreferredName().getFamilyName(), personAddress.getAddress1(), personAddress.getAddress2(), personAddress.getAddress3(), personAddress.getAddress4(), personAddress.getAddress5(), personAddress.getAddress6(), personAddress.getCityVillage(), personAddress.getStateProvince(), personAddress.getCountry(), personAddress.getPostalCode(), personAddress.getCountyDistrict(), personAddress.getLatitude(), personAddress.getLongitude(), new DateTime(personAddress.getStartDate()), new DateTime(personAddress.getEndDate()), new DateTime(person.getBirthdate()), person.getBirthdateEstimated(), person.getGender(), person.getDead(), "", patient.getMotechId(), location.getName(), identifiersMap); verify(patientService).createPatient(eq(CONFIG_NAME), patientCaptor.capture()); assertEquals(patient, patientCaptor.getValue()); }