Search in sources :

Example 1 with CurrencyConversionApi

use of org.killbill.billing.currency.api.CurrencyConversionApi in project killbill by killbill.

the class TestInvoiceModuleNoDB method installCurrencyConversionApi.

private void installCurrencyConversionApi() {
    final CurrencyConversionApi currencyConversionApi = Mockito.mock(CurrencyConversionApi.class);
    final CurrencyConversion currencyConversion = Mockito.mock(CurrencyConversion.class);
    final Set<Rate> rates = new HashSet<Rate>();
    rates.add(new Rate() {

        @Override
        public Currency getBaseCurrency() {
            return Currency.USD;
        }

        @Override
        public Currency getCurrency() {
            return Currency.BRL;
        }

        @Override
        public BigDecimal getValue() {
            return new BigDecimal("0.4234");
        }

        @Override
        public DateTime getConversionDate() {
            return new DateTime(DateTimeZone.UTC);
        }
    });
    Mockito.when(currencyConversion.getRates()).thenReturn(rates);
    try {
        Mockito.when(currencyConversionApi.getCurrencyConversion(Mockito.<Currency>any(), Mockito.<DateTime>any())).thenReturn(currencyConversion);
    } catch (CurrencyConversionException e) {
        throw new RuntimeException(e);
    }
    bind(CurrencyConversionApi.class).toInstance(currencyConversionApi);
}
Also used : Rate(org.killbill.billing.currency.api.Rate) CurrencyConversionApi(org.killbill.billing.currency.api.CurrencyConversionApi) Currency(org.killbill.billing.catalog.api.Currency) CurrencyConversion(org.killbill.billing.currency.api.CurrencyConversion) CurrencyConversionException(org.killbill.billing.currency.api.CurrencyConversionException) BigDecimal(java.math.BigDecimal) DateTime(org.joda.time.DateTime) HashSet(java.util.HashSet)

Aggregations

BigDecimal (java.math.BigDecimal)1 HashSet (java.util.HashSet)1 DateTime (org.joda.time.DateTime)1 Currency (org.killbill.billing.catalog.api.Currency)1 CurrencyConversion (org.killbill.billing.currency.api.CurrencyConversion)1 CurrencyConversionApi (org.killbill.billing.currency.api.CurrencyConversionApi)1 CurrencyConversionException (org.killbill.billing.currency.api.CurrencyConversionException)1 Rate (org.killbill.billing.currency.api.Rate)1