Source:
<code>public void createParticipant() { STUDY.setExternalIdValidationEnabled(true); STUDY.setEmailVerificationEnabled(true); mockHealthCodeAndAccountRetrieval(); when(externalIdService.getExternalId(STUDY.getStudyIdentifier(), EXTERNAL_ID, false)).thenReturn(EXT_ID); IdentifierHolder idHolder = participantService.createParticipant(STUDY, PARTICIPANT, true); assertEquals(ID, idHolder.getIdentifier()); verify(accountDao).constructAccount(STUDY, EMAIL, PHONE, EXTERNAL_ID, PASSWORD); verify(externalIdService).beginAssignExternalId(account, EXTERNAL_ID); verify(externalIdService).getExternalId(STUDY.getStudyIdentifier(), EXTERNAL_ID, false); <START> verify(accountDao).createAccount(eq(STUDY), accountCaptor.capture(), any()); <END> verify(accountWorkflowService).sendEmailVerificationToken(STUDY, ID, EMAIL); Account account = accountCaptor.getValue(); assertEquals(FIRST_NAME, account.getFirstName()); assertEquals(LAST_NAME, account.getLastName()); assertEquals("true", account.getAttributes().get("can_be_recontacted")); assertEquals(DEV_CALLER_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(ImmutableList.of("de","fr"), account.getLanguages()); verify(cacheProvider, never()).removeSessionByUserId(ID); }</code><technical_language>worth putting a thenAnswer() createAccount() calls commit hook, verify commit hook is passed in correctly called. (Here in updateParticipant().)</technical_language>

Target:
public void createParticipant() { STUDY.setExternalIdValidationEnabled(true); STUDY.setEmailVerificationEnabled(true); mockHealthCodeAndAccountRetrieval(); when(externalIdService.getExternalId(STUDY.getStudyIdentifier(), EXTERNAL_ID, false)).thenReturn(EXT_ID); IdentifierHolder idHolder = participantService.createParticipant(STUDY, PARTICIPANT, true); assertEquals(ID, idHolder.getIdentifier()); verify(accountDao).constructAccount(STUDY, EMAIL, PHONE, EXTERNAL_ID, PASSWORD); verify(externalIdService).commitAssignExternalId(EXT_ID); verify(accountDao).createAccount(eq(STUDY), accountCaptor.capture(), any()); verify(accountWorkflowService).sendEmailVerificationToken(STUDY, ID, EMAIL); Account account = accountCaptor.getValue(); assertEquals(FIRST_NAME, account.getFirstName()); assertEquals(LAST_NAME, account.getLastName()); assertEquals("true", account.getAttributes().get("can_be_recontacted")); assertEquals(DEV_CALLER_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(ImmutableList.of("de","fr"), account.getLanguages()); Mockito.verifyNoMoreInteractions(cacheProvider); }