@Test void onRefund_nothingPresent() { final long requestId = 87L; final RequestDto requestDto = RequestDtoMother.fundRequestArea51(); requestDto.setStatus(FUNDED); when(fundService.getTotalFundsForRequest(requestId)).thenReturn(new ArrayList<>()); when(requestService.findRequest(requestId)).thenReturn(requestDto); handler.handleRefund(new RefundProcessedEvent(Refund.builder().requestId(requestId).build())); verify(requestService).update(new UpdateRequestStatusCommand(requestId, OPEN)); }
@EventListener public void handleRefund(final RefundProcessedEvent refundProcessedEvent) { final Long requestId = refundProcessedEvent.getRefund().getRequestId(); if (!hasTokenValueGtZero(fundService.getTotalFundsForRequest(requestId)) && hasRequestStatus(requestId, FUNDED)) { requestService.update(new UpdateRequestStatusCommand(requestId, OPEN)); } }
CheckFundsGtZeroHandler { @EventListener public void handleRefund(final RefundProcessedEvent refundProcessedEvent) { final Long requestId = refundProcessedEvent.getRefund().getRequestId(); if (!hasTokenValueGtZero(fundService.getTotalFundsForRequest(requestId)) && hasRequestStatus(requestId, FUNDED)) { requestService.update(new UpdateRequestStatusCommand(requestId, OPEN)); } } }
CheckFundsGtZeroHandler { @EventListener public void handleRefund(final RefundProcessedEvent refundProcessedEvent) { final Long requestId = refundProcessedEvent.getRefund().getRequestId(); if (!hasTokenValueGtZero(fundService.getTotalFundsForRequest(requestId)) && hasRequestStatus(requestId, FUNDED)) { requestService.update(new UpdateRequestStatusCommand(requestId, OPEN)); } } CheckFundsGtZeroHandler(final FundService fundService, final RequestService requestService); }
CheckFundsGtZeroHandler { @EventListener public void handleRefund(final RefundProcessedEvent refundProcessedEvent) { final Long requestId = refundProcessedEvent.getRefund().getRequestId(); if (!hasTokenValueGtZero(fundService.getTotalFundsForRequest(requestId)) && hasRequestStatus(requestId, FUNDED)) { requestService.update(new UpdateRequestStatusCommand(requestId, OPEN)); } } CheckFundsGtZeroHandler(final FundService fundService, final RequestService requestService); @EventListener void handleFund(final RequestFundedEvent requestFundedEvent); @EventListener void handleRefund(final RefundProcessedEvent refundProcessedEvent); }
CheckFundsGtZeroHandler { @EventListener public void handleRefund(final RefundProcessedEvent refundProcessedEvent) { final Long requestId = refundProcessedEvent.getRefund().getRequestId(); if (!hasTokenValueGtZero(fundService.getTotalFundsForRequest(requestId)) && hasRequestStatus(requestId, FUNDED)) { requestService.update(new UpdateRequestStatusCommand(requestId, OPEN)); } } CheckFundsGtZeroHandler(final FundService fundService, final RequestService requestService); @EventListener void handleFund(final RequestFundedEvent requestFundedEvent); @EventListener void handleRefund(final RefundProcessedEvent refundProcessedEvent);  }