### Question:
FxRateMarketDataFunction implements MarketDataFunction<FxRate, FxRateId> { @Override public MarketDataRequirements requirements(FxRateId id, MarketDataConfig marketDataConfig) { FxRateConfig fxRateConfig = marketDataConfig.get(FxRateConfig.class, id.getObservableSource()); Optional<QuoteId> optional = fxRateConfig.getObservableRateKey(id.getPair()); return optional.map(key -> MarketDataRequirements.of(key)).orElse(MarketDataRequirements.empty()); }  @Override MarketDataRequirements requirements(FxRateId id, MarketDataConfig marketDataConfig); @Override MarketDataBox<FxRate> build(
      FxRateId id,
      MarketDataConfig marketDataConfig,
      ScenarioMarketData marketData,
      ReferenceData refData); @Override Class<FxRateId> getMarketDataIdType();  }### Answer:
@Test public void requirements() { FxRateMarketDataFunction function = new FxRateMarketDataFunction(); MarketDataRequirements requirements = function.requirements(RATE_ID, config()); assertThat(requirements).isEqualTo(MarketDataRequirements.of(QUOTE_ID)); }
@Test public void requirementsInverse() { FxRateMarketDataFunction function = new FxRateMarketDataFunction(); MarketDataRequirements requirements = function.requirements(FxRateId.of(CURRENCY_PAIR.inverse()), config()); assertThat(requirements).isEqualTo(MarketDataRequirements.of(QUOTE_ID)); }
@Test public void requirementsMissingConfig() { FxRateMarketDataFunction function = new FxRateMarketDataFunction(); assertThatIllegalArgumentException() .isThrownBy(() -> function.requirements(RATE_ID, MarketDataConfig.empty())) .withMessageMatching("No configuration found .*FxRateConfig"); }
@Test public void requirementsNoConfigForPair() { FxRateMarketDataFunction function = new FxRateMarketDataFunction(); CurrencyPair gbpUsd = CurrencyPair.of(Currency.GBP, Currency.USD); assertThat(function.requirements(FxRateId.of(gbpUsd), config())).isEqualTo(MarketDataRequirements.empty()); }