Source:
public void testMarkComponentsBelongingToDonationAsUnsafeIfContainsPlasma_shouldMarkComponentsAsUnsafe() { Component firstComponent = aComponent().withId(1L) .withComponentType(aComponentType() .thatContainsPlasma() .build()) .build(); Component secondComponent = aComponent().withId(2L) .withComponentType(aComponentType() .build()) .build(); Component thirdComponent = aComponent().withId(2L) .withComponentType(aComponentType() .thatContainsPlasma() .build()) .build(); Component deletedComponent = aComponent().withId(3L).withIsDeleted(true).build(); Donation donation = aDonation() .withId(1L) .withComponents(Arrays.asList(firstComponent, secondComponent, thirdComponent, deletedComponent)) .build(); doAnswer(returnsFirstArg()).when(componentCRUDService).markComponentAsUnsafe( argThat(hasSameStateAsComponent(firstComponent)), eq(ComponentStatusChangeReasonType.TEST_RESULTS_CONTAINS_PLASMA)); componentCRUDService.markComponentsBelongingToDonationAsUnsafeIfContainsPlasma(donation); verify(componentCRUDService).markComponentAsUnsafe(argThat(hasSameStateAsComponent(firstComponent)), eq(ComponentStatusChangeReasonType.TEST_RESULTS_CONTAINS_PLASMA)); verify(componentCRUDService).markComponentAsUnsafe(argThat(hasSameStateAsComponent(thirdComponent)), eq(ComponentStatusChangeReasonType.TEST_RESULTS_CONTAINS_PLASMA)); verify(componentCRUDService, never()).markComponentAsUnsafe(argThat(hasSameStateAsComponent(deletedComponent)), eq(ComponentStatusChangeReasonType.TEST_RESULTS)); }

Target:
public void testMarkComponentsBelongingToDonationAsUnsafeIfContainsPlasma_shouldMarkComponentsAsUnsafe() { Component firstComponent = aComponent().withId(1L) .withComponentType(aComponentType() .thatContainsPlasma() .build()) .build(); Component secondComponent = aComponent().withId(2L) .withComponentType(aComponentType() .build()) .build(); Component thirdComponent = aComponent().withId(2L) .withComponentType(aComponentType() .thatContainsPlasma() .build()) .build(); Component deletedComponent = aComponent().withId(3L) .withComponentType(aComponentType() .thatContainsPlasma() .build()) .withIsDeleted(true) .build(); Donation donation = aDonation() .withId(1L) .withComponents(Arrays.asList(firstComponent, secondComponent, thirdComponent, deletedComponent)) .build(); doAnswer(returnsFirstArg()).when(componentCRUDService).markComponentAsUnsafe( argThat(hasSameStateAsComponent(firstComponent)), eq(ComponentStatusChangeReasonType.TEST_RESULTS_CONTAINS_PLASMA)); componentCRUDService.markComponentsBelongingToDonationAsUnsafeIfContainsPlasma(donation); verify(componentCRUDService).markComponentAsUnsafe(argThat(hasSameStateAsComponent(firstComponent)), eq(ComponentStatusChangeReasonType.TEST_RESULTS_CONTAINS_PLASMA)); verify(componentCRUDService, never()).markComponentAsUnsafe(argThat(hasSameStateAsComponent(secondComponent)), eq(ComponentStatusChangeReasonType.TEST_RESULTS_CONTAINS_PLASMA)); verify(componentCRUDService).markComponentAsUnsafe(argThat(hasSameStateAsComponent(thirdComponent)), eq(ComponentStatusChangeReasonType.TEST_RESULTS_CONTAINS_PLASMA)); verify(componentCRUDService, never()).markComponentAsUnsafe(argThat(hasSameStateAsComponent(deletedComponent)), eq(ComponentStatusChangeReasonType.TEST_RESULTS_CONTAINS_PLASMA)); }