本文整理汇总了Java中com.piggymetrics.statistics.domain.ExchangeRatesContainer类的典型用法代码示例。如果您正苦于以下问题:Java ExchangeRatesContainer类的具体用法?Java ExchangeRatesContainer怎么用?Java ExchangeRatesContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExchangeRatesContainer类属于com.piggymetrics.statistics.domain包,在下文中一共展示了ExchangeRatesContainer类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例4: shouldRetrieveExchangeRates
import com.piggymetrics.statistics.domain.ExchangeRatesContainer; //导入依赖的package包/类
@Test
public void shouldRetrieveExchangeRates() {
ExchangeRatesContainer container = client.getRates(Currency.getBase());
assertEquals(container.getDate(), LocalDate.now());
assertEquals(container.getBase(), Currency.getBase());
assertNotNull(container.getRates().get(Currency.EUR.name()));
assertNotNull(container.getRates().get(Currency.RUB.name()));
}
示例5: getRates
import com.piggymetrics.statistics.domain.ExchangeRatesContainer; //导入依赖的package包/类
@RequestMapping(method = RequestMethod.GET, value = "/latest")
ExchangeRatesContainer getRates(@RequestParam("base") Currency base);