@Test public void testGenerateMrn() { final String prefixMock = "PREFIXMOCK"; ReflectionTestUtils.setField(sut, "prefix", prefixMock); when(patientRepository.findAllByMedicalRecordNumber(anyString())) .thenReturn(new ArrayList<Patient>(1)); String mrn = sut.generateMrn(); assertTrue(StringUtils.hasText(mrn)); assertTrue(mrn.startsWith(prefixMock)); }
@Override public String generateMrn() { final short iterationLimit = 3; return UniqueValueGenerator .generateUniqueValue(this::generateRandomMrn, generatedValue -> patientRepository .findAllByMedicalRecordNumber(generatedValue) .size() == 0, iterationLimit); }
MrnServiceImpl implements MrnService { @Override public String generateMrn() { final short iterationLimit = 3; return UniqueValueGenerator .generateUniqueValue(this::generateRandomMrn, generatedValue -> patientRepository .findAllByMedicalRecordNumber(generatedValue) .size() == 0, iterationLimit); } }
MrnServiceImpl implements MrnService { @Override public String generateMrn() { final short iterationLimit = 3; return UniqueValueGenerator .generateUniqueValue(this::generateRandomMrn, generatedValue -> patientRepository .findAllByMedicalRecordNumber(generatedValue) .size() == 0, iterationLimit); } MrnServiceImpl(String prefix, PatientRepository patientRepository); }
MrnServiceImpl implements MrnService { @Override public String generateMrn() { final short iterationLimit = 3; return UniqueValueGenerator .generateUniqueValue(this::generateRandomMrn, generatedValue -> patientRepository .findAllByMedicalRecordNumber(generatedValue) .size() == 0, iterationLimit); } MrnServiceImpl(String prefix, PatientRepository patientRepository); @Override String generateMrn(); }
MrnServiceImpl implements MrnService { @Override public String generateMrn() { final short iterationLimit = 3; return UniqueValueGenerator .generateUniqueValue(this::generateRandomMrn, generatedValue -> patientRepository .findAllByMedicalRecordNumber(generatedValue) .size() == 0, iterationLimit); } MrnServiceImpl(String prefix, PatientRepository patientRepository); @Override String generateMrn();  }