Package com.wesabe.api.util.money

Examples of com.wesabe.api.util.money.Money


    @Test
    public void shouldThrowACurrencyMismatchException() throws Exception {
      boolean exceptionThrown = false;
      String exceptionMessage = null;
     
      Money oneDollar = new Money(decimal("1.00"), USD);
      Money oneEuro = new Money(decimal("1.00"), EUR);
     
      try {
        oneDollar.add(oneEuro);
      } catch (CurrencyMismatchException e) {
        exceptionThrown = true;
View Full Code Here


    @Test
    public void shouldThrowACurrencyMismatchException() throws Exception {
      boolean exceptionThrown = false;
      String exceptionMessage = null;
     
      Money oneDollar = new Money(decimal("1.00"), USD);
      Money oneEuro = new Money(decimal("1.00"), EUR);
     
      try {
        oneDollar.subtract(oneEuro);
      } catch (CurrencyMismatchException e) {
        exceptionThrown = true;
View Full Code Here

  }
 
  public static class One_Dollar_Times_Two {
    @Test
    public void itIsTwoDollars() throws Exception {
      Money oneDollar = new Money(decimal("1.00"), USD);
      Money twoDollars = new Money(decimal("2.00"), USD);
      assertEquals(twoDollars, oneDollar.multiply(2));
    }
View Full Code Here

  }
 
  public static class Two_Dollars_Times_Negative_One {
    @Test
    public void itIsNegativeTwoDollars() throws Exception {
      Money twoDollars = new Money(decimal("2.00"), USD);
      Money negativeTwoDollars = new Money(decimal("-2.00"), USD);
      assertEquals(negativeTwoDollars, twoDollars.multiply(-1));
    }
View Full Code Here

  }
 
  public static class Ten_Dollars_Times_Zero {
    @Test
    public void itIsZeroDollars() throws Exception {
      Money tenDollars = new Money(decimal("10.00"), USD);
      Money zeroDollars = new Money(decimal("0.00"), USD);
      assertEquals(zeroDollars, tenDollars.multiply(0));
    }
View Full Code Here

  public static class One_Dollar_As_A_String {
    @SuppressWarnings("deprecation")
    @Test
    public void shouldRenderInTheDefaultLocale() throws Exception {
      Money oneDollar = new Money(decimal("1.00"), USD);
      assertEquals(oneDollar.toString(Locale.getDefault()), oneDollar.toString());
    }
View Full Code Here

      assertEquals(oneDollar.toString(Locale.getDefault()), oneDollar.toString());
    }

    @Test
    public void shouldRenderInAnArbitraryLocale() throws Exception {
      Money oneDollar = new Money(decimal("1.00"), USD);
      assertEquals("1,00 $US", oneDollar.toString(Locale.FRANCE));
    }
View Full Code Here

      assertEquals("1,00 $US", oneDollar.toString(Locale.FRANCE));
    }
   
    @Test
    public void shouldRenderAsAMachineReadableString() throws Exception {
      Money oneDollar = new Money(decimal("1.00"), USD);
      assertEquals("1.00", oneDollar.toPlainString());
    }
View Full Code Here

  public static class One_Dollar_Converted_Into_Dollars {
    @Test
    public void shouldBeOneDollar() throws Exception {
      CurrencyExchangeRateMap exchangeRates = new CurrencyExchangeRateMap();
      Money oneDollar = new Money(decimal("1.00"), USD);
      assertEquals(oneDollar, oneDollar.convert(exchangeRates, USD, now()));
    }
View Full Code Here

public class MonetarySummaryWithSplits extends MonetarySummary {
 
  public static MonetarySummaryWithSplits summarize(Collection<Money> amounts, Currency currency, Multimap<Tag, Money> splits) {
    int spendingCount = 0, earningsCount = 0;
    Money spendingSum = Money.zero(currency), earningsSum = Money.zero(currency);
   
    for (Money amount : amounts) {
      if (amount.signum() > 0) {
        earningsCount++;
        earningsSum = earningsSum.add(amount);
      } else if (amount.signum() < 0) {
        spendingCount++;
        spendingSum = spendingSum.add(amount.abs());
      }
    }
   
    final ImmutableMap.Builder<Tag, MonetarySummary> splitSummaries = ImmutableMap.builder();
    for (Tag tag : splits.keySet()) {
View Full Code Here

TOP

Related Classes of com.wesabe.api.util.money.Money

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.