Package com.wesabe.api.util.money

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


  public static final Money twoEuros = new Money(decimal("2.00"), EUR);
  public static final Money oneKroner = new Money(decimal("1.00"), NOK); // eat it, DHH
  public static final Money sixKroners = new Money(decimal("6.00"), NOK);
 
  public static Money money(String amount, Currency currency) {
    return new Money(new BigDecimal(amount), currency);
  }
View Full Code Here


  public static class One_Dollar_Converted_Into_Euros {
    @Test
    public void shouldBeWhateverTheExchangeRateIs() throws Exception {
      CurrencyExchangeRateMap exchangeRates = new CurrencyExchangeRateMap();
      exchangeRates.addExchangeRate(USD, EUR, now(), decimal("0.79"));
      Money oneDollar = new Money(decimal("1.00"), USD);
      Money wayLessInEuros = new Money(decimal("0.79"), EUR);
      Money actualValue = oneDollar.convert(exchangeRates, EUR, now());
      assertEquals(wayLessInEuros, actualValue);
    }
View Full Code Here

    @Test
    public void shouldRoundDownIfLessThanHalf() throws Exception {
      CurrencyExchangeRateMap exchangeRates = new CurrencyExchangeRateMap();
      exchangeRates.addExchangeRate(USD, EUR, now(), decimal("0.794"));
      Money oneDollar = new Money(decimal("1.00"), USD);
      Money wayLessInEuros = new Money(decimal("0.79"), EUR);
      Money actualValue = oneDollar.convert(exchangeRates, EUR, now());
      assertEquals(wayLessInEuros, actualValue);
    }
View Full Code Here

    @Test
    public void shouldRoundUpIfHalf() throws Exception {
      CurrencyExchangeRateMap exchangeRates = new CurrencyExchangeRateMap();
      exchangeRates.addExchangeRate(USD, EUR, now(), decimal("0.795"));
      Money oneDollar = new Money(decimal("1.00"), USD);
      Money wayLessInEuros = new Money(decimal("0.80"), EUR);
      Money actualValue = oneDollar.convert(exchangeRates, EUR, now());
      assertEquals(wayLessInEuros, actualValue);
    }
View Full Code Here

    @Test
    public void shouldRoundUpIfMoreThanHalf() throws Exception {
      CurrencyExchangeRateMap exchangeRates = new CurrencyExchangeRateMap();
      exchangeRates.addExchangeRate(USD, EUR, now(), decimal("0.797"));
      Money oneDollar = new Money(decimal("1.00"), USD);
      Money wayLessInEuros = new Money(decimal("0.80"), EUR);
      Money actualValue = oneDollar.convert(exchangeRates, EUR, now());
      assertEquals(wayLessInEuros, actualValue);
    }
View Full Code Here

    }
   
    @Test
    public void itCanBeConstructedWithAnAccountAndAMoneyWithMatchingCurrencies() {
      Account account = new Account("Checking", USD);
      Money balance = money("10.00", USD);
      new AccountBalance(account, balance, new DateTime());
    }
View Full Code Here

    }
   
    @Test(expected=CurrencyMismatchException.class)
    public void itCannotBeConstructedWithAnAccountWhoseCurrencyMismatchesTheMoneyBalance() {
      Account account = new Account("Checking", USD);
      Money mismatchedBalance = money("10.00", GBP);
      new AccountBalance(account, mismatchedBalance, new DateTime());
    }
View Full Code Here

 
  public static class Any_Money {
   
    @Test
    public void itAllowsGettingTheValue() {
      Money two = new Money(decimal("2.00"), USD);
      assertEquals(decimal("2.00"), two.getValue());
    }
View Full Code Here

  public static class Zero_Dollars {

    @Test
    public void shouldBeZero() throws Exception {
      Money zeroDollars = new Money(decimal("0.00"), USD);
      assertTrue(zeroDollars.isZero());
    }
View Full Code Here

      assertTrue(zeroDollars.isZero());
    }

    @Test
    public void shouldHaveASignOfZero() throws Exception {
      Money zeroDollars = new Money(decimal("0.00"), USD);
      assertEquals(0, zeroDollars.signum());
    }
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.