Search in sources :

Example 1 with MonetarySummaryStatistics

use of org.javamoney.moneta.function.MonetarySummaryStatistics in project jsr354-ri by JavaMoney.

the class ConversionAggregatorTest method groupBySummarizingMonetaryTest.

@Test
public void groupBySummarizingMonetaryTest() {
    GroupMonetarySummaryStatistics group = currenciesToSummary().collect(groupBySummarizingMonetary());
    Map<CurrencyUnit, MonetarySummaryStatistics> mapSummary = group.get();
    assertEquals(mapSummary.keySet().size(), 3);
}
Also used : MonetarySummaryStatistics(org.javamoney.moneta.function.MonetarySummaryStatistics) GroupMonetarySummaryStatistics(org.javamoney.moneta.function.GroupMonetarySummaryStatistics) CurrencyUnit(javax.money.CurrencyUnit) GroupMonetarySummaryStatistics(org.javamoney.moneta.function.GroupMonetarySummaryStatistics) Test(org.testng.annotations.Test)

Example 2 with MonetarySummaryStatistics

use of org.javamoney.moneta.function.MonetarySummaryStatistics in project jsr354-ri 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 : MonetarySummaryStatistics(org.javamoney.moneta.function.MonetarySummaryStatistics) DefaultMonetarySummaryStatistics(org.javamoney.moneta.function.DefaultMonetarySummaryStatistics) BeforeTest(org.testng.annotations.BeforeTest) Test(org.testng.annotations.Test)

Example 3 with MonetarySummaryStatistics

use of org.javamoney.moneta.function.MonetarySummaryStatistics in project jsr354-ri by JavaMoney.

the class ExchangeRateMonetarySummaryStatisticsTest method createSummaryDefault.

private MonetarySummaryStatistics createSummaryDefault(CurrencyUnit currencyUnit) {
    MonetarySummaryStatistics summary = DefaultMonetarySummaryStatistics.of(currencyUnit);
    summary.accept(Money.of(10, currencyUnit));
    summary.accept(Money.of(90, currencyUnit));
    summary.accept(Money.of(110, currencyUnit));
    return summary;
}
Also used : MonetarySummaryStatistics(org.javamoney.moneta.function.MonetarySummaryStatistics) DefaultMonetarySummaryStatistics(org.javamoney.moneta.function.DefaultMonetarySummaryStatistics)

Example 4 with MonetarySummaryStatistics

use of org.javamoney.moneta.function.MonetarySummaryStatistics in project jsr354-ri 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 : MonetarySummaryStatistics(org.javamoney.moneta.function.MonetarySummaryStatistics) DefaultMonetarySummaryStatistics(org.javamoney.moneta.function.DefaultMonetarySummaryStatistics) BeforeTest(org.testng.annotations.BeforeTest) Test(org.testng.annotations.Test)

Example 5 with MonetarySummaryStatistics

use of org.javamoney.moneta.function.MonetarySummaryStatistics in project jsr354-ri-bp by JavaMoney.

the class ExchangeRateMonetarySummaryStatisticsTest method createSummaryDefault.

private MonetarySummaryStatistics createSummaryDefault(CurrencyUnit currencyUnit) {
    MonetarySummaryStatistics summary = DefaultMonetarySummaryStatistics.of(currencyUnit);
    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)

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