Source:
<code>public void testCreateDonationViewModelWithPermissions_shouldReturnViewModelWithCorrectDonationAndPermissions() { boolean irrelevantCanDeletePermission = true; boolean irrelevantCanUpdatePermission = true; boolean irrelevantCanDonatePermission = true; Long irrelevantAdverseEventId = 11L; AdverseEvent adverseEvent = anAdverseEvent().withId(irrelevantAdverseEventId).build(); Donation donation = aDonation().withId(IRRELEVANT_DONATION_ID) <START> .withDonor(aDonor().withId(IRRELEVANT_DONATION_ID).build()) <END> .withAdverseEvent(adverseEvent) .build(); AdverseEventViewModel adverseEventViewModel = anAdverseEventViewModel().withId(irrelevantAdverseEventId).build(); DonationViewModel expectedDonationViewModel = aDonationViewModel() .withDonation(donation) .withPermission("canDelete", irrelevantCanDeletePermission) .withPermission("canUpdateDonationFields", irrelevantCanUpdatePermission) .withPermission("canDonate", irrelevantCanDonatePermission) .withAdverseEvent(adverseEventViewModel) .build(); when(donationConstraintChecker.canDeleteDonation(IRRELEVANT_DONATION_ID)).thenReturn(irrelevantCanDeletePermission); when(donationConstraintChecker.canUpdateDonationFields(IRRELEVANT_DONATION_ID)).thenReturn(irrelevantCanUpdatePermission); when(donorConstraintChecker.isDonorEligibleToDonate(IRRELEVANT_DONATION_ID)).thenReturn(irrelevantCanDonatePermission); when(adverseEventViewModelFactory.createAdverseEventViewModel(adverseEvent)).thenReturn(adverseEventViewModel); DonationViewModel returnedDonationViewModel = donationViewModelFactory.createDonationViewModelWithPermissions( donation); assertThat(returnedDonationViewModel, hasSameStateAsDonationViewModel(expectedDonationViewModel)); }</code><technical_language>Donor donation id</technical_language>

Target:
public void testCreateDonationViewModelWithPermissions_shouldReturnViewModelWithCorrectDonationAndPermissions() { boolean irrelevantCanDeletePermission = true; boolean irrelevantCanUpdatePermission = true; boolean irrelevantCanDonatePermission = true; boolean irrelevantIsBackEntryPermission = true; Long irrelevantAdverseEventId = 11L; AdverseEvent adverseEvent = anAdverseEvent().withId(irrelevantAdverseEventId).build(); Donation donation = aDonation().withId(IRRELEVANT_DONATION_ID) .withDonor(aDonor().withId(IRRELEVANT_DONOR_ID).build()) .withDonationBatch(aDonationBatch().thatIsBackEntry().build()) .withAdverseEvent(adverseEvent) .build(); AdverseEventViewModel adverseEventViewModel = anAdverseEventViewModel().withId(irrelevantAdverseEventId).build(); DonationViewModel expectedDonationViewModel = aDonationViewModel() .withDonation(donation) .withPermission("canDelete", irrelevantCanDeletePermission) .withPermission("canUpdateDonationFields", irrelevantCanUpdatePermission) .withPermission("canDonate", irrelevantCanDonatePermission) .withPermission("isBackEntry", irrelevantIsBackEntryPermission) .withAdverseEvent(adverseEventViewModel) .build(); when(donationConstraintChecker.canDeleteDonation(IRRELEVANT_DONATION_ID)).thenReturn(irrelevantCanDeletePermission); when(donationConstraintChecker.canUpdateDonationFields(IRRELEVANT_DONATION_ID)).thenReturn(irrelevantCanUpdatePermission); when(donorConstraintChecker.isDonorEligibleToDonate(IRRELEVANT_DONOR_ID)).thenReturn(irrelevantCanDonatePermission); when(adverseEventViewModelFactory.createAdverseEventViewModel(adverseEvent)).thenReturn(adverseEventViewModel); DonationViewModel returnedDonationViewModel = donationViewModelFactory.createDonationViewModelWithPermissions( donation); assertThat(returnedDonationViewModel, hasSameStateAsDonationViewModel(expectedDonationViewModel)); }