Search in sources :

Example 11 with MonetarySummaryStatistics

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;
}
Also used : ExchangeRateMonetarySummaryStatistics(org.javamoney.moneta.convert.ExchangeRateMonetarySummaryStatistics) MonetarySummaryStatistics(org.javamoney.moneta.function.MonetarySummaryStatistics) DefaultMonetarySummaryStatistics(org.javamoney.moneta.function.DefaultMonetarySummaryStatistics) ExchangeRateMonetarySummaryStatistics(org.javamoney.moneta.convert.ExchangeRateMonetarySummaryStatistics)

Example 12 with MonetarySummaryStatistics

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());
}
Also used : ExchangeRateMonetarySummaryStatistics(org.javamoney.moneta.convert.ExchangeRateMonetarySummaryStatistics) MonetarySummaryStatistics(org.javamoney.moneta.function.MonetarySummaryStatistics) DefaultMonetarySummaryStatistics(org.javamoney.moneta.function.DefaultMonetarySummaryStatistics) ExchangeRateMonetarySummaryStatistics(org.javamoney.moneta.convert.ExchangeRateMonetarySummaryStatistics) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 13 with MonetarySummaryStatistics

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());
}
Also used : ExchangeRateMonetarySummaryStatistics(org.javamoney.moneta.convert.ExchangeRateMonetarySummaryStatistics) MonetarySummaryStatistics(org.javamoney.moneta.function.MonetarySummaryStatistics) DefaultMonetarySummaryStatistics(org.javamoney.moneta.function.DefaultMonetarySummaryStatistics) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 14 with MonetarySummaryStatistics

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());
}
Also used : ExchangeRateMonetarySummaryStatistics(org.javamoney.moneta.convert.ExchangeRateMonetarySummaryStatistics) MonetarySummaryStatistics(org.javamoney.moneta.function.MonetarySummaryStatistics) DefaultMonetarySummaryStatistics(org.javamoney.moneta.function.DefaultMonetarySummaryStatistics) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

MonetarySummaryStatistics (org.javamoney.moneta.function.MonetarySummaryStatistics)14 DefaultMonetarySummaryStatistics (org.javamoney.moneta.function.DefaultMonetarySummaryStatistics)12 Test (org.testng.annotations.Test)10 BeforeTest (org.testng.annotations.BeforeTest)8 ExchangeRateMonetarySummaryStatistics (org.javamoney.moneta.convert.ExchangeRateMonetarySummaryStatistics)6 GroupMonetarySummaryStatistics (org.javamoney.moneta.function.GroupMonetarySummaryStatistics)2 CurrencyUnit (javax.money.CurrencyUnit)1