### Question:
FxRateScenarioArray implements ScenarioArray<FxRate>, ImmutableBean, Serializable { public double fxRate(Currency baseCurrency, Currency counterCurrency, int scenarioIndex) { if (baseCurrency.equals(pair.getBase()) && counterCurrency.equals(pair.getCounter())) { return rates.get(scenarioIndex); } if (counterCurrency.equals(pair.getBase()) && baseCurrency.equals(pair.getCounter())) { return 1d / rates.get(scenarioIndex); } throw new IllegalArgumentException("Unknown rate: " + baseCurrency + "/" + counterCurrency); } private  FxRateScenarioArray(
      CurrencyPair pair,
      DoubleArray rates); static FxRateScenarioArray of(CurrencyPair currencyPair, DoubleArray rates); static FxRateScenarioArray of(Currency base, Currency counter, DoubleArray rates); @Override int getScenarioCount(); @Override FxRate get(int scenarioIndex); @Override Stream<FxRate> stream(); double fxRate(Currency baseCurrency, Currency counterCurrency, int scenarioIndex); DoubleArray convert(DoubleArray amounts, Currency fromCurrency, Currency toCurrency); FxRateScenarioArray crossRates(FxRateScenarioArray other); static FxRateScenarioArray.Meta meta(); @Override FxRateScenarioArray.Meta metaBean(); CurrencyPair getPair(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void fxRate() { FxRateScenarioArray rates = FxRateScenarioArray.of(CurrencyPair.of(Currency.EUR, Currency.USD), DoubleArray.of(1.07, 1.08, 1.09)); assertThat(rates.fxRate(Currency.EUR, Currency.USD, 0)).isEqualTo(1.07); assertThat(rates.fxRate(Currency.EUR, Currency.USD, 1)).isEqualTo(1.08); assertThat(rates.fxRate(Currency.EUR, Currency.USD, 2)).isEqualTo(1.09); assertThat(rates.fxRate(Currency.USD, Currency.EUR, 0)).isEqualTo(1 / 1.07); assertThat(rates.fxRate(Currency.USD, Currency.EUR, 1)).isEqualTo(1 / 1.08); assertThat(rates.fxRate(Currency.USD, Currency.EUR, 2)).isEqualTo(1 / 1.09); }