Source:
<code>public void createParticipant() { STUDY.setExternalIdValidationEnabled(true); STUDY.setEmailVerificationEnabled(true); mockHealthCodeAndAccountRetrieval(); when(externalIdService.getExternalId(STUDY.getStudyIdentifier(), EXTERNAL_ID)) <START> .thenReturn(new DynamoExternalIdentifier()); <END> IdentifierHolder idHolder = participantService.createParticipant(STUDY, CALLER_ROLES, PARTICIPANT, true); assertEquals(ID, idHolder.getIdentifier()); verify(externalIdService).assignExternalId(STUDY, EXTERNAL_ID, HEALTH_CODE); verify(externalIdService).getExternalId(STUDY.getStudyIdentifier(), EXTERNAL_ID); verify(accountDao).createAccount(eq(STUDY), accountCaptor.capture()); verify(accountWorkflowService).sendEmailVerificationToken(STUDY, ID, EMAIL); Account account = accountCaptor.getValue(); assertEquals(FIRST_NAME, account.getFirstName()); assertEquals(LAST_NAME, account.getLastName()); assertEquals("true", account.getAttribute("can_be_recontacted")); assertEquals(USER_ROLES, account.getRoles()); assertEquals(TestUtils.getClientData(), account.getClientData()); assertEquals(AccountStatus.UNVERIFIED, account.getStatus()); assertNull(account.getEmailVerified()); assertEquals(SharingScope.ALL_QUALIFIED_RESEARCHERS, account.getSharingScope()); assertEquals(Boolean.TRUE, account.getNotifyByEmail()); assertEquals(EXTERNAL_ID, account.getExternalId()); assertNull(account.getTimeZone()); assertEquals(Sets.newHashSet("group1","group2"), account.getDataGroups()); assertEquals(TestUtils.newLinkedHashSet("de","fr"), account.getLanguages()); verify(cacheProvider, never()).removeSessionByUserId(ID); }</code><technical_language>ExternalIdentifier.create() avoid leaking DDB implementation non-DDB classes. (Here other places in this PR.)</technical_language>

Target:
public void createParticipant() { STUDY.setExternalIdValidationEnabled(true); STUDY.setEmailVerificationEnabled(true); mockHealthCodeAndAccountRetrieval(); when(externalIdService.getExternalId(STUDY.getStudyIdentifier(), EXTERNAL_ID)).thenReturn(EXT_ID); IdentifierHolder idHolder = participantService.createParticipant(STUDY, CALLER_ROLES, PARTICIPANT, true); assertEquals(ID, idHolder.getIdentifier()); verify(accountDao).constructAccount(STUDY, EMAIL, PHONE, EXTERNAL_ID, PASSWORD); verify(externalIdService).assignExternalId(STUDY, EXTERNAL_ID, HEALTH_CODE); verify(externalIdService).getExternalId(STUDY.getStudyIdentifier(), EXTERNAL_ID); verify(accountDao).createAccount(eq(STUDY), accountCaptor.capture()); verify(accountWorkflowService).sendEmailVerificationToken(STUDY, ID, EMAIL); Account account = accountCaptor.getValue(); assertEquals(FIRST_NAME, account.getFirstName()); assertEquals(LAST_NAME, account.getLastName()); assertEquals("true", account.getAttribute("can_be_recontacted")); assertEquals(USER_ROLES, account.getRoles()); assertEquals(TestUtils.getClientData(), account.getClientData()); assertEquals(AccountStatus.UNVERIFIED, account.getStatus()); assertNull(account.getEmailVerified()); assertEquals(SharingScope.ALL_QUALIFIED_RESEARCHERS, account.getSharingScope()); assertEquals(Boolean.TRUE, account.getNotifyByEmail()); assertEquals(EXTERNAL_ID, account.getExternalId()); assertNull(account.getTimeZone()); assertEquals(Sets.newHashSet("group1","group2"), account.getDataGroups()); assertEquals(TestUtils.newLinkedHashSet("de","fr"), account.getLanguages()); verify(cacheProvider, never()).removeSessionByUserId(ID); }