@Test void isRefundable() { final String userEtherAddress = "0xeab4"; final UserFundsDto fund = buildUserFundsDto(userEtherAddress, "5", "", "", ""); final long requestId = 35L; final String requestStatus = "Funded"; final UserProfile userProfile = UserProfile.builder().etherAddresses(Collections.singletonList(userEtherAddress)).build(); final TokenValueDto totalFndOnContract = TokenValueDtoMother.FND().totalAmount(TEN).build(); when(fundService.getFundsFor(requestId, userEtherAddress, totalFndOnContract.getTokenAddress())).thenReturn(Optional.of(totalFndOnContract)); when(refundService.findAllRefundRequestsFor(requestId, PENDING, APPROVED)).thenReturn(Collections.emptyList()); final boolean result = refundValidator.isRefundable(userProfile, fund, requestId, requestStatus); assertThat(result).isTrue(); }
public boolean isRefundable(final UserProfile userProfile, final UserFundsDto fund, final long requestId, final String requestStatus) { return userProfile != null && userProfile.userOwnsAddress(fund.getFunderAddress()) && "FUNDED".equalsIgnoreCase(requestStatus) && !refundRequestAlreadyExists(requestId) && hasPositiveBalance(requestId, fund); }
RefundValidator { public boolean isRefundable(final UserProfile userProfile, final UserFundsDto fund, final long requestId, final String requestStatus) { return userProfile != null && userProfile.userOwnsAddress(fund.getFunderAddress()) && "FUNDED".equalsIgnoreCase(requestStatus) && !refundRequestAlreadyExists(requestId) && hasPositiveBalance(requestId, fund); } }
RefundValidator { public boolean isRefundable(final UserProfile userProfile, final UserFundsDto fund, final long requestId, final String requestStatus) { return userProfile != null && userProfile.userOwnsAddress(fund.getFunderAddress()) && "FUNDED".equalsIgnoreCase(requestStatus) && !refundRequestAlreadyExists(requestId) && hasPositiveBalance(requestId, fund); } RefundValidator(final RefundService refundService, final FundService fundService); }
RefundValidator { public boolean isRefundable(final UserProfile userProfile, final UserFundsDto fund, final long requestId, final String requestStatus) { return userProfile != null && userProfile.userOwnsAddress(fund.getFunderAddress()) && "FUNDED".equalsIgnoreCase(requestStatus) && !refundRequestAlreadyExists(requestId) && hasPositiveBalance(requestId, fund); } RefundValidator(final RefundService refundService, final FundService fundService); boolean isRefundable(final UserProfile userProfile,
                                final UserFundsDto fund,
                                final long requestId,
                                final String requestStatus); }
RefundValidator { public boolean isRefundable(final UserProfile userProfile, final UserFundsDto fund, final long requestId, final String requestStatus) { return userProfile != null && userProfile.userOwnsAddress(fund.getFunderAddress()) && "FUNDED".equalsIgnoreCase(requestStatus) && !refundRequestAlreadyExists(requestId) && hasPositiveBalance(requestId, fund); } RefundValidator(final RefundService refundService, final FundService fundService); boolean isRefundable(final UserProfile userProfile,
                                final UserFundsDto fund,
                                final long requestId,
                                final String requestStatus);  }