@Test void onFund_statusNotOPEN() { final long requestId = 254L; final RequestDto requestDto = RequestDtoMother.fundRequestArea51(); requestDto.setStatus(FUNDED); when(fundService.getTotalFundsForRequest(requestId)).thenReturn(Arrays.asList(TokenValueDtoMother.FND().totalAmount(new BigDecimal("45")).build(), TokenValueDtoMother.ZRX().totalAmount(new BigDecimal("23")).build())); when(requestService.findRequest(requestId)).thenReturn(requestDto); handler.handleFund(RequestFundedEvent.builder().requestId(requestId).build()); verify(requestService).findRequest(requestId); verifyNoMoreInteractions(requestService); }
@EventListener public void handleFund(final RequestFundedEvent requestFundedEvent) { final Long requestId = requestFundedEvent.getRequestId(); if (hasTokenValueGtZero(fundService.getTotalFundsForRequest(requestId)) && hasRequestStatus(requestId, OPEN)) { requestService.update(new UpdateRequestStatusCommand(requestId, FUNDED)); } }
CheckFundsGtZeroHandler { @EventListener public void handleFund(final RequestFundedEvent requestFundedEvent) { final Long requestId = requestFundedEvent.getRequestId(); if (hasTokenValueGtZero(fundService.getTotalFundsForRequest(requestId)) && hasRequestStatus(requestId, OPEN)) { requestService.update(new UpdateRequestStatusCommand(requestId, FUNDED)); } } }
CheckFundsGtZeroHandler { @EventListener public void handleFund(final RequestFundedEvent requestFundedEvent) { final Long requestId = requestFundedEvent.getRequestId(); if (hasTokenValueGtZero(fundService.getTotalFundsForRequest(requestId)) && hasRequestStatus(requestId, OPEN)) { requestService.update(new UpdateRequestStatusCommand(requestId, FUNDED)); } } CheckFundsGtZeroHandler(final FundService fundService, final RequestService requestService); }
CheckFundsGtZeroHandler { @EventListener public void handleFund(final RequestFundedEvent requestFundedEvent) { final Long requestId = requestFundedEvent.getRequestId(); if (hasTokenValueGtZero(fundService.getTotalFundsForRequest(requestId)) && hasRequestStatus(requestId, OPEN)) { requestService.update(new UpdateRequestStatusCommand(requestId, FUNDED)); } } CheckFundsGtZeroHandler(final FundService fundService, final RequestService requestService); @EventListener void handleFund(final RequestFundedEvent requestFundedEvent); @EventListener void handleRefund(final RefundProcessedEvent refundProcessedEvent); }
CheckFundsGtZeroHandler { @EventListener public void handleFund(final RequestFundedEvent requestFundedEvent) { final Long requestId = requestFundedEvent.getRequestId(); if (hasTokenValueGtZero(fundService.getTotalFundsForRequest(requestId)) && hasRequestStatus(requestId, OPEN)) { requestService.update(new UpdateRequestStatusCommand(requestId, FUNDED)); } } CheckFundsGtZeroHandler(final FundService fundService, final RequestService requestService); @EventListener void handleFund(final RequestFundedEvent requestFundedEvent); @EventListener void handleRefund(final RefundProcessedEvent refundProcessedEvent);  }