### Question:
ExchangeRateService { @Transactional public void fetchRates() { LOG.info("Fetching rates..."); Long blockNrETH = blockNrProviderService.getCurrentBlockNrEthereum(); if (blockNrETH == null) { LOG.error("Could not fetch current ETH block number."); return; } Long blockNrBTC = blockNrProviderService.getCurrentBlockNrBitcoin(); if (blockNrBTC == null) { LOG.error("Could not fetch current BTC block number."); return; } List<CurrencyType> enabledCryptoCurrencies = ratesAppConfigHolder.getEnabledCryptoCurrencies(); List<ExchangeType> enabledExchanges = ratesAppConfigHolder.getEnabledExchanges(); CurrencyType baseFiatCurrency = ratesAppConfigHolder.getBaseFiatCurrency(); ExchangeAggregateRate exchangeAggregateRate = new ExchangeAggregateRate(new Date(), blockNrETH, blockNrBTC); enabledExchanges.stream().forEach((enabledExchange) -> { ExchangeEntryRate exchangeEntryRate = new ExchangeEntryRate(new Date(), enabledExchange); enabledCryptoCurrencies.stream().forEach((enabledCryptoCurrency) -> { getRateAndAddCurrencyRate(exchangeEntryRate, enabledExchange, enabledCryptoCurrency, baseFiatCurrency); }); exchangeAggregateRate.addExchangeEntry(exchangeEntryRate); }); enabledCryptoCurrencies.stream().forEach((enabledCryptoCurrency) -> { List<ExchangeCurrencyRate> allExchangeCurrencyRates = exchangeAggregateRate.getAllExchangeCurrencyRates(enabledCryptoCurrency); BigDecimal mean = aggregationService.removeOutliersAndGetMean(allExchangeCurrencyRates); ExchangeAggregateCurrencyRate aggCurrencyRate = new ExchangeAggregateCurrencyRate(enabledCryptoCurrency, mean); exchangeAggregateRate.addExchangeAggregateCurrencyRate(aggCurrencyRate); }); exchangeAggregateRateRepository.save(exchangeAggregateRate); }  Optional<BigDecimal> getRate(ExchangeType exchangeType, CurrencyPair currencyPair); @Transactional void fetchRates();  }### Answer:
@Test public void testFetchRates() { exchangeRateService.fetchRates(); List<ExchangeAggregateRate> all = exchangeAggregateRateRepository.findAllByOrderByCreationDate(); assertTrue(all.stream().anyMatch((aggregateRate) -> aggregateRate.getExchangeEntryRates().size() > 0)); assertTrue(checkIfExchangeIsPresent(all, ExchangeType.BITFINEX)); assertTrue(checkIfExchangeIsPresent(all, ExchangeType.BITSTAMP)); assertTrue(checkIfExchangeIsPresent(all, ExchangeType.KRAKEN)); assertTrue(checkIfExchangeIsPresent(all, ExchangeType.GDAX)); assertTrue(checkIfExchangeIsPresent(all, ExchangeType.COINMARKETCAP)); assertTrue(checkIfCurrencyIsPresent(all, CurrencyType.ETH)); assertTrue(checkIfCurrencyIsPresent(all, CurrencyType.BTC)); }