Source:
public void withdrawFromStudyWithEmail() throws Exception { setupWithdrawTest(); consentService.withdrawFromStudy(study, PARTICIPANT, WITHDRAWAL, SIGNED_ON); verify(accountDao).updateAccount(accountCaptor.capture(), eq(null)); assertEquals(SharingScope.NO_SHARING, account.getSharingScope()); ArgumentCaptor<MimeTypeEmailProvider> emailCaptor = ArgumentCaptor.forClass(MimeTypeEmailProvider.class); verify(sendMailService).sendEmail(emailCaptor.capture()); MimeTypeEmailProvider provider = emailCaptor.getValue(); MimeTypeEmail email = provider.getMimeTypeEmail(); assertEquals("\"Test Study [ConsentServiceMockTest]\" <bridge-testing+support@sagebase.org>", email.getSenderAddress()); assertEquals("bridge-testing+consent@sagebase.org", email.getRecipientAddresses().get(0)); assertEquals("Notification of consent withdrawal for Test Study [ConsentServiceMockTest]", email.getSubject()); assertEquals("<p>User Allen Wrench &lt;" + EMAIL + "&gt; withdrew from the study on October 28, 2015. </p><p>Reason:</p><p>For reasons.</p>", email.getMessageParts().get(0).getContent()); Account updatedAccount = accountCaptor.getValue(); assertEquals(SharingScope.NO_SHARING, account.getSharingScope()); assertNull(account.getFirstName()); assertNull(account.getLastName()); assertFalse(account.getNotifyByEmail()); assertNull(account.getEmail()); assertFalse(account.getEmailVerified()); assertNull(account.getPhone()); assertFalse(account.getPhoneVerified()); assertEquals("externalId", account.getExternalId()); for (List<ConsentSignature> signatures : updatedAccount.getAllConsentSignatureHistories().values()) { for (ConsentSignature sig : signatures) { assertNotNull(sig.getWithdrewOn()); } } }

Target:
public void withdrawFromStudyWithEmail() throws Exception { setupWithdrawTest(); consentService.withdrawFromStudy(study, PARTICIPANT, WITHDRAWAL, SIGNED_ON); verify(accountDao).updateAccount(accountCaptor.capture(), eq(null)); assertEquals(SharingScope.NO_SHARING, account.getSharingScope()); ArgumentCaptor<MimeTypeEmailProvider> emailCaptor = ArgumentCaptor.forClass(MimeTypeEmailProvider.class); verify(sendMailService).sendEmail(emailCaptor.capture()); MimeTypeEmailProvider provider = emailCaptor.getValue(); MimeTypeEmail email = provider.getMimeTypeEmail(); assertEquals("\"Test Study [ConsentServiceMockTest]\" <bridge-testing+support@sagebase.org>", email.getSenderAddress()); assertEquals("bridge-testing+consent@sagebase.org", email.getRecipientAddresses().get(0)); assertEquals("Notification of consent withdrawal for Test Study [ConsentServiceMockTest]", email.getSubject()); assertEquals("<p>User Allen Wrench &lt;" + EMAIL + "&gt; withdrew from the study on October 28, 2015. </p><p>Reason:</p><p>For reasons.</p>", email.getMessageParts().get(0).getContent()); Account updatedAccount = accountCaptor.getValue(); assertEquals(SharingScope.NO_SHARING, account.getSharingScope()); assertNull(account.getFirstName()); assertNull(account.getLastName()); assertFalse(account.getNotifyByEmail()); assertNull(account.getEmail()); assertFalse(account.getEmailVerified()); assertNull(account.getPhone()); assertFalse(account.getPhoneVerified()); assertEquals("externalId", account.getExternalId()); assertEquals(1, account.getAccountSubstudies().size()); AccountSubstudy acctSubstudy = account.getAccountSubstudies().iterator().next(); assertEquals("substudyId", acctSubstudy.getSubstudyId()); assertEquals("anExternalId", acctSubstudy.getExternalId()); for (List<ConsentSignature> signatures : updatedAccount.getAllConsentSignatureHistories().values()) { for (ConsentSignature sig : signatures) { assertNotNull(sig.getWithdrewOn()); } } }