use of org.javamoney.moneta.function.MonetarySummaryStatistics in project jsr354-ri-bp by JavaMoney.
the class ExchangeRateMonetarySummaryStatisticsTest method createSummary.
private MonetarySummaryStatistics createSummary(CurrencyUnit currencyUnit) {
MonetarySummaryStatistics summary = new ExchangeRateMonetarySummaryStatistics(currencyUnit, provider);
summary.accept(Money.of(10, currencyUnit));
summary.accept(Money.of(90, currencyUnit));
summary.accept(Money.of(110, currencyUnit));
return summary;
}
use of org.javamoney.moneta.function.MonetarySummaryStatistics in project jsr354-ri-bp by JavaMoney.
the class ExchangeRateMonetarySummaryStatisticsTest method shouldConvertWhenIsDifferentCurrency.
@Test
public void shouldConvertWhenIsDifferentCurrency() {
MonetarySummaryStatistics summary = new ExchangeRateMonetarySummaryStatistics(BRAZILIAN_REAL, provider);
summary.accept(Money.of(10, DOLLAR));
assertEquals(BRAZILIAN_REAL, summary.getCurrencyUnit());
assertEquals(1L, summary.getCount());
assertNotSame(0L, summary.getMin().getNumber().longValue());
assertNotSame(0L, summary.getMax().getNumber().longValue());
assertNotSame(0L, summary.getSum().getNumber().longValue());
assertNotSame(0L, summary.getAverage().getNumber().longValue());
}
use of org.javamoney.moneta.function.MonetarySummaryStatistics in project jsr354-ri-bp by JavaMoney.
the class ExchangeRateMonetarySummaryStatisticsTest method combineImplSummaryTest.
@Test
public void combineImplSummaryTest() {
MonetarySummaryStatistics summaryA = createSummary(BRAZILIAN_REAL);
MonetarySummaryStatistics summaryB = createSummaryDefault(DOLLAR);
MonetarySummaryStatistics result = summaryA.combine(summaryB);
assertEquals(BRAZILIAN_REAL, result.getCurrencyUnit());
assertEquals(6L, result.getCount());
assertNotNull(result.getMin());
assertNotSame(110L, result.getMax().getNumber().longValue());
assertNotSame(210L, result.getSum().getNumber().longValue());
assertNotSame(70L, result.getAverage().getNumber().longValue());
}
use of org.javamoney.moneta.function.MonetarySummaryStatistics in project jsr354-ri-bp by JavaMoney.
the class ExchangeRateMonetarySummaryStatisticsTest method toTest.
@Test
public void toTest() {
MonetarySummaryStatistics summary = createSummary(BRAZILIAN_REAL);
MonetarySummaryStatistics summaryDollar = summary.to(DOLLAR);
assertEquals(DOLLAR, summaryDollar.getCurrencyUnit());
assertEquals(3L, summaryDollar.getCount());
assertNotSame(0L, summaryDollar.getMin().getNumber().longValue());
assertNotSame(0L, summaryDollar.getMax().getNumber().longValue());
assertNotSame(0L, summaryDollar.getSum().getNumber().longValue());
assertNotSame(0L, summaryDollar.getAverage().getNumber().longValue());
}
Aggregations