Source:
<code>public void before() { STUDY.setExternalIdValidationEnabled(false); STUDY.setExternalIdRequiredOnSignup(false); STUDY.setEmailVerificationEnabled(false); STUDY.setAccountLimit(0); participantService = new ParticipantService(); participantService.setAccountDao(accountDao); participantService.setSmsService(smsService); participantService.setSubpopulationService(subpopService); participantService.setUserConsent(consentService); participantService.setCacheProvider(cacheProvider); participantService.setExternalIdService(externalIdService); participantService.setScheduledActivityDao(activityDao); participantService.setUploadService(uploadService); participantService.setNotificationsService(notificationsService); participantService.setScheduledActivityService(scheduledActivityService); participantService.setAccountWorkflowService(accountWorkflowService); participantService.setSubstudyService(substudyService); participantService.setActivityEventService(activityEventService); account = Account.create(); doAnswer((InvocationOnMock invocation) -> { Object[] args = invocation.getArguments(); @SuppressWarnings("unchecked") <START> Consumer<Account> accountConsumer = (Consumer<Account>)args[2]; <END> if (accountConsumer != null) { accountConsumer.accept(account); } return null; }).when(accountDao).createAccount(any(), any(), any()); doAnswer((InvocationOnMock invocation) -> { Object[] args = invocation.getArguments(); @SuppressWarnings("unchecked") Consumer<Account> accountConsumer = (Consumer<Account>)args[1]; if (accountConsumer != null) { accountConsumer.accept(account); } return null; }).when(accountDao).updateAccount(any(), any()); BridgeUtils.setRequestContext(new RequestContext.Builder().withCallerRoles(RESEARCH_CALLER_ROLES) .withCallerSubstudies(CALLER_SUBS).build()); }</code><technical_language>Minor: invocation.getArgumentAt() this slightly wordy</technical_language>

Target:
public void before() { STUDY.setExternalIdValidationEnabled(false); STUDY.setExternalIdRequiredOnSignup(false); STUDY.setEmailVerificationEnabled(false); STUDY.setAccountLimit(0); participantService = new ParticipantService(); participantService.setAccountDao(accountDao); participantService.setSmsService(smsService); participantService.setSubpopulationService(subpopService); participantService.setUserConsent(consentService); participantService.setCacheProvider(cacheProvider); participantService.setExternalIdService(externalIdService); participantService.setScheduledActivityDao(activityDao); participantService.setUploadService(uploadService); participantService.setNotificationsService(notificationsService); participantService.setScheduledActivityService(scheduledActivityService); participantService.setAccountWorkflowService(accountWorkflowService); participantService.setSubstudyService(substudyService); participantService.setActivityEventService(activityEventService); account = Account.create(); account.setStudyId(TestConstants.TEST_STUDY_IDENTIFIER); account.setHealthCode(HEALTH_CODE); doAnswer((InvocationOnMock invocation) -> { @SuppressWarnings("unchecked") Consumer<Account> accountConsumer = (Consumer<Account>) invocation.getArgumentAt(2, Consumer.class); if (accountConsumer != null) { accountConsumer.accept(account); } return null; }).when(accountDao).createAccount(any(), any(), any()); doAnswer((InvocationOnMock invocation) -> { @SuppressWarnings("unchecked") Consumer<Account> accountConsumer = (Consumer<Account>) invocation.getArgumentAt(1, Consumer.class); if (accountConsumer != null) { accountConsumer.accept(account); } return null; }).when(accountDao).updateAccount(any(), any()); BridgeUtils.setRequestContext(new RequestContext.Builder().withCallerRoles(RESEARCH_CALLER_ROLES) .withCallerSubstudies(CALLER_SUBS).build()); }