Source:
<code>public void doCapture_shouldCaptureAChargeForANonSandboxAccount() throws Exception { String gatewayTxId = "theTxId"; ChargeEntity charge = createNewChargeWith("worldpay",1L, AUTHORISATION_SUCCESS, gatewayTxId); ChargeEntity chargeSpy = spy(charge); mockChargeDaoOperations(chargeSpy); worldpayWillRespondWithSuccess(gatewayTxId, null); when(mockedProviders.byName(charge.getPaymentGatewayName())).thenReturn(mockedPaymentProvider); GatewayResponse response = cardCaptureService.doCapture(charge.getExternalId()); assertThat(response.isSuccessful(), is(true)); InOrder inOrder = Mockito.inOrder(chargeSpy); inOrder.verify(chargeSpy).setStatus(CAPTURE_READY); inOrder.verify(chargeSpy).setStatus(CAPTURE_SUBMITTED); ArgumentCaptor<ChargeEntity> chargeEntityCaptor = ArgumentCaptor.forClass(ChargeEntity.class); verify(mockedChargeEventDao).persistChargeEventOf(chargeEntityCaptor.capture(), eq(Optional.empty())); verify(mockPaymentRequestDao).updateChargeTransactionStatus(charge.getExternalId(), CAPTURE_READY); <START> verify(mockPaymentRequestDao).updateChargeTransactionStatus(charge.getExternalId(), CAPTURE_SUBMITTED); <END> assertThat(chargeEntityCaptor.getValue().getStatus(), is(CAPTURE_SUBMITTED.getValue())); ArgumentCaptor<CaptureGatewayRequest> request = ArgumentCaptor.forClass(CaptureGatewayRequest.class); verify(mockedPaymentProvider, times(1)).capture(request.capture()); assertThat(request.getValue().getTransactionId(), is(gatewayTxId)); verify(mockUserNotificationService).notifyPaymentSuccessEmail(chargeSpy); }</code><technical_language>Another in-order verification opportunity</technical_language>

Target:
public void doCapture_shouldCaptureAChargeForANonSandboxAccount() throws Exception { String gatewayTxId = "theTxId"; ChargeEntity charge = createNewChargeWith("worldpay",1L, AUTHORISATION_SUCCESS, gatewayTxId); ChargeEntity chargeSpy = spy(charge); mockChargeDaoOperations(chargeSpy); worldpayWillRespondWithSuccess(gatewayTxId, null); when(mockedProviders.byName(charge.getPaymentGatewayName())).thenReturn(mockedPaymentProvider); GatewayResponse response = cardCaptureService.doCapture(charge.getExternalId()); assertThat(response.isSuccessful(), is(true)); InOrder inOrder = Mockito.inOrder(chargeSpy); inOrder.verify(chargeSpy).setStatus(CAPTURE_READY); inOrder.verify(chargeSpy).setStatus(CAPTURE_SUBMITTED); ArgumentCaptor<ChargeEntity> chargeEntityCaptor = ArgumentCaptor.forClass(ChargeEntity.class); verify(mockedChargeEventDao).persistChargeEventOf(chargeEntityCaptor.capture(), eq(Optional.empty())); InOrder inOrderVerifier = inOrder(mockStatusUpdater); inOrderVerifier.verify(mockStatusUpdater).updateChargeTransactionStatus(charge.getExternalId(), CAPTURE_READY); inOrderVerifier.verify(mockStatusUpdater).updateChargeTransactionStatus(charge.getExternalId(), CAPTURE_SUBMITTED); assertThat(chargeEntityCaptor.getValue().getStatus(), is(CAPTURE_SUBMITTED.getValue())); ArgumentCaptor<CaptureGatewayRequest> request = ArgumentCaptor.forClass(CaptureGatewayRequest.class); verify(mockedPaymentProvider, times(1)).capture(request.capture()); assertThat(request.getValue().getTransactionId(), is(gatewayTxId)); verify(mockUserNotificationService).notifyPaymentSuccessEmail(chargeSpy); }