@Test public void coinMarketCapHasPriority() { TokenValueDto totalFund = TokenValueDto.builder().tokenAddress("0x0").tokenSymbol("FND").totalAmount(BigDecimal.TEN).build(); when(coinMarketCapService.getCurrentPriceInUsd("FND")).thenReturn(Optional.of(0.56)); double result = fiatService.getUsdPrice(totalFund); assertThat(result).isEqualTo(5.6); verifyZeroInteractions(cryptoCompareService); }
public double getUsdPrice(TokenValueDto... funds) { return Arrays.stream(funds) .filter(f -> f != null && StringUtils.isNotBlank(f.getTokenSymbol())) .map(this::getValue) .mapToDouble(f -> f) .sum(); }
FiatService { public double getUsdPrice(TokenValueDto... funds) { return Arrays.stream(funds) .filter(f -> f != null && StringUtils.isNotBlank(f.getTokenSymbol())) .map(this::getValue) .mapToDouble(f -> f) .sum(); } }
FiatService { public double getUsdPrice(TokenValueDto... funds) { return Arrays.stream(funds) .filter(f -> f != null && StringUtils.isNotBlank(f.getTokenSymbol())) .map(this::getValue) .mapToDouble(f -> f) .sum(); } FiatService(CryptoCompareService cryptoCompareService, CoinMarketCapService coinMarketCapService); }
FiatService { public double getUsdPrice(TokenValueDto... funds) { return Arrays.stream(funds) .filter(f -> f != null && StringUtils.isNotBlank(f.getTokenSymbol())) .map(this::getValue) .mapToDouble(f -> f) .sum(); } FiatService(CryptoCompareService cryptoCompareService, CoinMarketCapService coinMarketCapService); double getUsdPrice(TokenValueDto... funds); }
FiatService { public double getUsdPrice(TokenValueDto... funds) { return Arrays.stream(funds) .filter(f -> f != null && StringUtils.isNotBlank(f.getTokenSymbol())) .map(this::getValue) .mapToDouble(f -> f) .sum(); } FiatService(CryptoCompareService cryptoCompareService, CoinMarketCapService coinMarketCapService); double getUsdPrice(TokenValueDto... funds);  }