public void test_should_find_the_most_actual_rate_for_every_currency() {
    Currency c1 = CurrencyBuilder.withDb(db).name("USD").title("Dollar").symbol("$").create();
    Currency c2 = CurrencyBuilder.withDb(db).name("EUR").title("Euro").symbol("€").create();
    Currency c3 =
        CurrencyBuilder.withDb(db).name("SGD").title("Singapore Dollar").symbol("S$").create();

    RateBuilder.withDb(db).from(c1).to(c2).at(DateTime.date(2012, 1, 17)).rate(0.78592f).create();
    RateBuilder.withDb(db).from(c1).to(c2).at(DateTime.date(2012, 1, 18)).rate(0.78635f).create();

    RateBuilder.withDb(db).from(c1).to(c3).at(DateTime.date(2012, 1, 15)).rate(0.111f).create();

    RateBuilder.withDb(db).from(c2).to(c3).at(DateTime.date(2012, 1, 16)).rate(0.222f).create();
    RateBuilder.withDb(db).from(c2).to(c3).at(DateTime.date(2012, 1, 14)).rate(0.333f).create();

    ExchangeRateProvider m = db.getLatestRates();

    ExchangeRate rate = m.getRate(c1, c2);
    assertRate(DateTime.date(2012, 1, 18), 0.78635f, rate);

    rate = m.getRate(c2, c1);
    assertRate(DateTime.date(2012, 1, 18), 1.0f / 0.78635f, rate);

    rate = m.getRate(c1, c3);
    assertRate(DateTime.date(2012, 1, 15), 0.111f, rate);

    rate = m.getRate(c2, c3);
    assertRate(DateTime.date(2012, 1, 16), 0.222f, rate);

    rate = m.getRate(c3, c2);
    assertRate(DateTime.date(2012, 1, 16), 1.0f / 0.222f, rate);
  }
 public void test_should_return_error_if_rate_is_not_found() {
   ExchangeRateProvider m = db.getLatestRates();
   ExchangeRate rate = m.getRate(c1, c2);
   assertTrue(ExchangeRate.NA == rate);
 }