@Test public void testGeneratePolicyId() { when(consentRepository.findAllByConsentReferenceId(anyString())) .thenReturn(new ArrayList<Consent>(1)); ConsentDto consentDto = new ConsentDto(); Set<String> organizationalProvidersDisclosureIsMadeTo = new HashSet<String>(); organizationalProvidersDisclosureIsMadeTo.add("111"); Set<String> providersPermittedToDisclose = new HashSet<String>(); providersPermittedToDisclose.add("222"); consentDto .setOrganizationalProvidersDisclosureIsMadeTo(organizationalProvidersDisclosureIsMadeTo); consentDto .setProvidersPermittedToDisclose(providersPermittedToDisclose); String policyId = sut.generatePolicyId(consentDto, MRNMOCK); assertTrue(StringUtils.hasText(policyId)); assertTrue(policyId.startsWith(MRNMOCK)); assertTrue(policyId.contains(PIDDOMAINIDMOCK)); assertTrue(policyId.contains(PIDDOMAINTYPEMOCK)); }
@Override public String generatePolicyId(ConsentDto consentDto, String mrn) { final short iterationLimit = 3; return UniqueValueGenerator .generateUniqueValue(() -> generateRandomPolicyId(consentDto, mrn), generatedValue -> consentRepository.findAllByConsentReferenceId(generatedValue) .size() == 0, iterationLimit); }
PolicyIdServiceImpl implements PolicyIdService { @Override public String generatePolicyId(ConsentDto consentDto, String mrn) { final short iterationLimit = 3; return UniqueValueGenerator .generateUniqueValue(() -> generateRandomPolicyId(consentDto, mrn), generatedValue -> consentRepository.findAllByConsentReferenceId(generatedValue) .size() == 0, iterationLimit); } }
PolicyIdServiceImpl implements PolicyIdService { @Override public String generatePolicyId(ConsentDto consentDto, String mrn) { final short iterationLimit = 3; return UniqueValueGenerator .generateUniqueValue(() -> generateRandomPolicyId(consentDto, mrn), generatedValue -> consentRepository.findAllByConsentReferenceId(generatedValue) .size() == 0, iterationLimit); } PolicyIdServiceImpl(String pidDomainId, String pidDomainType,
			ConsentRepository consentRepository); }
PolicyIdServiceImpl implements PolicyIdService { @Override public String generatePolicyId(ConsentDto consentDto, String mrn) { final short iterationLimit = 3; return UniqueValueGenerator .generateUniqueValue(() -> generateRandomPolicyId(consentDto, mrn), generatedValue -> consentRepository.findAllByConsentReferenceId(generatedValue) .size() == 0, iterationLimit); } PolicyIdServiceImpl(String pidDomainId, String pidDomainType,
			ConsentRepository consentRepository); @Override String generatePolicyId(ConsentDto consentDto, String mrn); }
PolicyIdServiceImpl implements PolicyIdService { @Override public String generatePolicyId(ConsentDto consentDto, String mrn) { final short iterationLimit = 3; return UniqueValueGenerator .generateUniqueValue(() -> generateRandomPolicyId(consentDto, mrn), generatedValue -> consentRepository.findAllByConsentReferenceId(generatedValue) .size() == 0, iterationLimit); } PolicyIdServiceImpl(String pidDomainId, String pidDomainType,
			ConsentRepository consentRepository); @Override String generatePolicyId(ConsentDto consentDto, String mrn);  }