FXMatrix implements Serializable { public double getFxRate(final Currency ccy1, final Currency ccy2) { if (ccy1.equals(ccy2)) { return 1; } final Integer index1 = _currencies.get(ccy1); final Integer index2 = _currencies.get(ccy2); ArgumentChecker.isTrue(index1 != null, "{} not found in FX matrix", ccy1); ArgumentChecker.isTrue(index2 != null, "{} not found in FX matrix", ccy2); return _fxRates[index1][index2]; } FXMatrix();  FXMatrix(final Currency ccy);  FXMatrix(final Currency ccy1, final Currency ccy2, final double fxRate);  FXMatrix(final Map<Currency, Integer> currencies, final double[][] fxRates);  FXMatrix(final FXMatrix fxMatrix); void addCurrency(final Currency ccyToAdd, final Currency ccyReference, final double fxRate); double getFxRate(final Currency ccy1, final Currency ccy2); boolean containsPair(final Currency ccy1, final Currency ccy2); CurrencyAmount convert(final MultipleCurrencyAmount amount, final Currency ccy); void updateRates(final Currency ccyToUpdate, final Currency ccyReference, final double fxRate); Map<Currency, Integer> getCurrencies(); double[][] getRates(); int getNumberOfCurrencies(); @Override String toString(); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test public void onePairSecondConstructor() { final FXMatrix fxMatrix = new FXMatrix(EUR, USD, EUR_USD); assertEquals("FXMatrix - first pair", EUR_USD, fxMatrix.getFxRate(EUR, USD), TOLERANCE_RATE); assertEquals("FXMatrix - first pair", 1.0 / EUR_USD, fxMatrix.getFxRate(USD, EUR), TOLERANCE_RATE); assertEquals("FXMatrix - first pair", 1.0, fxMatrix.getFxRate(USD, USD), TOLERANCE_RATE); assertEquals("FXMatrix - first pair", 1.0, fxMatrix.getFxRate(EUR, EUR), TOLERANCE_RATE); }