本文整理汇总了Java中com.piggymetrics.statistics.domain.ExchangeRatesContainer.setRates方法的典型用法代码示例。如果您正苦于以下问题:Java ExchangeRatesContainer.setRates方法的具体用法?Java ExchangeRatesContainer.setRates怎么用?Java ExchangeRatesContainer.setRates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.piggymetrics.statistics.domain.ExchangeRatesContainer
的用法示例。
在下文中一共展示了ExchangeRatesContainer.setRates方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldReturnCurrentRatesWhenContainerIsEmptySoFar
import com.piggymetrics.statistics.domain.ExchangeRatesContainer; //导入方法依赖的package包/类
@Test
public void shouldReturnCurrentRatesWhenContainerIsEmptySoFar() {
ExchangeRatesContainer container = new ExchangeRatesContainer();
container.setRates(ImmutableMap.of(
Currency.EUR.name(), new BigDecimal("0.8"),
Currency.RUB.name(), new BigDecimal("80")
));
when(client.getRates(Currency.getBase())).thenReturn(container);
Map<Currency, BigDecimal> result = ratesService.getCurrentRates();
verify(client, times(1)).getRates(Currency.getBase());
assertEquals(container.getRates().get(Currency.EUR.name()), result.get(Currency.EUR));
assertEquals(container.getRates().get(Currency.RUB.name()), result.get(Currency.RUB));
assertEquals(BigDecimal.ONE, result.get(Currency.USD));
}
示例2: shouldNotRequestRatesWhenTodaysContainerAlreadyExists
import com.piggymetrics.statistics.domain.ExchangeRatesContainer; //导入方法依赖的package包/类
@Test
public void shouldNotRequestRatesWhenTodaysContainerAlreadyExists() {
ExchangeRatesContainer container = new ExchangeRatesContainer();
container.setRates(ImmutableMap.of(
Currency.EUR.name(), new BigDecimal("0.8"),
Currency.RUB.name(), new BigDecimal("80")
));
when(client.getRates(Currency.getBase())).thenReturn(container);
// initialize container
ratesService.getCurrentRates();
// use existing container
ratesService.getCurrentRates();
verify(client, times(1)).getRates(Currency.getBase());
}
示例3: shouldConvertCurrency
import com.piggymetrics.statistics.domain.ExchangeRatesContainer; //导入方法依赖的package包/类
@Test
public void shouldConvertCurrency() {
ExchangeRatesContainer container = new ExchangeRatesContainer();
container.setRates(ImmutableMap.of(
Currency.EUR.name(), new BigDecimal("0.8"),
Currency.RUB.name(), new BigDecimal("80")
));
when(client.getRates(Currency.getBase())).thenReturn(container);
final BigDecimal amount = new BigDecimal(100);
final BigDecimal expectedConvertionResult = new BigDecimal("1.25");
BigDecimal result = ratesService.convert(Currency.RUB, Currency.USD, amount);
assertTrue(expectedConvertionResult.compareTo(result) == 0);
}