### Question:
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);  }### Answer:
@Test void onFund_fundsPresent() { final long requestId = 254L; final RequestDto requestDto = RequestDtoMother.fundRequestArea51(); requestDto.setStatus(OPEN); 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).update(new UpdateRequestStatusCommand(requestId, FUNDED)); }
@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); }
@Test void onFund_noMoreFundsPresent() { final long requestId = 32L; when(fundService.getTotalFundsForRequest(requestId)).thenReturn(Arrays.asList(TokenValueDtoMother.FND().totalAmount(new BigDecimal("0")).build(), TokenValueDtoMother.ZRX().totalAmount(new BigDecimal("0")).build())); handler.handleFund(RequestFundedEvent.builder().requestId(requestId).build()); verifyZeroInteractions(requestService); }
@Test void onFund_nothingPresent() { final long requestId = 87L; when(fundService.getTotalFundsForRequest(requestId)).thenReturn(new ArrayList<>()); handler.handleFund(RequestFundedEvent.builder().requestId(requestId).build()); verifyZeroInteractions(requestService); }