AdminServiceImpl implements AdminService { @Override @Transactional public void updatePatient(PatientProfileDto patientProfileDto) { patientProfileDto.setAddressCountryCode("US"); Patient patient = patientRepository.findOne(patientProfileDto.getId()); final String mrn = patient.getMedicalRecordNumber(); patientProfileDto.setUsername(patient.getUsername()); PixManagerBean pixManagerBean = pixService.updatePatient(TypeConverter .patientProfileDtoToPixPatientDto(patientProfileDto, mrn)); Assert.isTrue( pixManagerBean.isSuccess(), "Patient cannot be updated on MPI! Error: " + pixManagerBean.getUpdateMessage()); final String eid = pixService.getEid(mrn); Assert.hasText(eid, "EID cannot be retrieved from MPI!"); patient.setEnterpriseIdentifier(eid); patient = patientProfileDtoToPatientMapper.map(patientProfileDto); patientRepository.save(patient); } AdminServiceImpl(
			Integer accountVerificationTokenExpireInHours,
			StaffRepository administratorRepository,
			PatientRepository patientRepository,
			DtoToDomainEntityMapper<PatientProfileDto, Patient> patientProfileDtoToPatientMapper,
			AdminProfileDtoToAdministratorMapper adminProfileDtoToAdministratorMapper,
			ModelMapper modelMapper,
			UserContext userContext,
			PasswordEncoder passwordEncoder,
			EmailSender emailSender,
			TokenGenerator tokenGenerator,
			EmailTokenRepository emailTokenRepository,
			UsersRepository usersRepository,
			AdministrativeGenderCodeRepository administrativeGenderCodeRepository,
			MrnService mrnService, PixService pixService); @Override AdminProfileDto findAdminProfileByUsername(String username); @Override @Transactional void updateAdministrator(AdminProfileDto adminProfileDto); @Override @Transactional void updatePatient(PatientProfileDto patientProfileDto); @Override AdminCreatePatientResponseDto createPatientAccount(
			BasicPatientAccountDto basicPatientAccountDto); @Override Boolean sendLoginInformationEmail(long patientId, String linkUrl);  }
@Test public void testUpdatePatient() { final long id = 1L; final String username = "username"; final String mrn = "mrn"; final String eid = "eid"; Patient patientCurrent = mock(Patient.class); Patient patientNew = mock(Patient.class); PatientProfileDto patientDto = new PatientProfileDto(); patientDto.setId(id); patientDto.setBirthDate(new Date()); LookupDto code = new LookupDto(); code.setCode("M"); patientDto.setMaritalStatusCode(code); when(patientProfileDtoToPatientMapper.map(patientDto)).thenReturn( patientNew); when(patientRepository.findOne(id)).thenReturn(patientCurrent); when(patientCurrent.getUsername()).thenReturn(username); when(patientCurrent.getMedicalRecordNumber()).thenReturn(mrn); PixManagerBean pixManagerBean = new PixManagerBean(); pixManagerBean.setSuccess(true); when(pixService.updatePatient(any(PixPatientDto.class))).thenReturn( pixManagerBean); when(pixService.getEid(mrn)).thenReturn(eid); sut.updatePatient(patientDto); verify(patientRepository, times(1)).save(patientNew); verify(pixService, times(1)).updatePatient(any(PixPatientDto.class)); }