Package com.wesabe.api.accounts.entities

Examples of com.wesabe.api.accounts.entities.Account


      assertFalse(firstAccount.hashCode() == otherAccount.hashCode());
    }
   
    @Test
    public void itIsEqualToAnotherAccountWithTheSameFields() throws Exception {
      final Account firstAccount = new Account();
      final Account otherAccount = new Account();
     
      inject(Account.class, firstAccount, "id", Integer.valueOf(300));
      inject(Account.class, firstAccount, "guid", "0123456789");
     
      inject(Account.class, otherAccount, "id", Integer.valueOf(300));
      inject(Account.class, otherAccount, "guid", "0123456789");
     
      assertTrue(firstAccount.equals(otherAccount));
      assertTrue(firstAccount.hashCode() == otherAccount.hashCode());
    }
View Full Code Here


    @Override
    @Before
    public void setup() throws Exception {
      super.setup();
     
      this.checking = new Account("Checking", USD);
     
      this.hierarchy = builder.build(
        ImmutableList.of(
          spent("400.00").from(checking).at("Whole Foods").on("food", "groceries").build(),
          spent("500.00").from(checking).at("Credit Card Payment").on("transfer", "creditcard").build(),
View Full Code Here

    private Tag restaurants = new Tag("restaurants");
    private Tag friends = new Tag("friends");
   
    @Before
    public void setup() {
      final Account checking = new Account("Checking", USD);
      final Txaction paidRent = new Txaction(checking, decimal("-1500.00"), date(2009, 1, 18));
      final Txaction boughtLunch = new Txaction(checking, decimal("-12.34"), new DateTime(2009, 1, 18, 23, 0, 0, 0));
      final Txaction deletedLunch = new Txaction(checking, decimal("-12.33"), new DateTime(2009, 1, 18, 23, 0, 0, 0));
      final Collection<Txaction> txactions = ImmutableList.of(paidRent, boughtLunch, deletedLunch);
     
View Full Code Here

 
  public static class Requesting_An_Account_Balance_With_Mismatched_Ids extends Setup {
    @Before
    public void setup() {
      super.setup();
      when(accountBalance.getAccount()).thenReturn(new Account());
      expectAccountBalance(accountBalance);
    }
View Full Code Here

  @GET
  public XmlsonObject show(@Context WesabeUser user,
      @Context Locale locale,
      @PathParam("accountId") IntegerParam accountId) {
   
    final Account account = accountDAO.findAccount(user.getAccountKey(), accountId.getValue());
    if (account == null) {
      throw new WebApplicationException(Status.NOT_FOUND);
    }
   
    return present(account, locale);
View Full Code Here

      @PathParam("accountId") IntegerParam accountId,
      @FormParam("name") String name,
      @FormParam("currency") CurrencyParam currency,
      @FormParam("archived") BooleanParam archived) {
   
    final Account account = accountDAO.findAccount(user.getAccountKey(), accountId.getValue());
    boolean shouldUpdate = false;
   
    if (account == null) {
      throw new WebApplicationException(Status.NOT_FOUND);
    }
   
    if (name != null) {
      account.setName(name);
      shouldUpdate = true;
    }
   
    if (currency != null) {
      account.setCurrency(currency.getValue());
      shouldUpdate = true;
    }
   
    if (archived != null) {
      if ((archived.getValue() && account.isArchived()) || (!archived.getValue() && account.isActive())) {
        // already in the target state
      } else if (archived.getValue() && account.isActive()) {
        account.setStatus(AccountStatus.ARCHIVED);
        shouldUpdate = true;
      } else if (!archived.getValue() && account.isArchived()) {
        account.setStatus(AccountStatus.ACTIVE);
        shouldUpdate = true;
      } else {
        throw new WebApplicationException(
            Response
              .status(Status.BAD_REQUEST)
              .entity("Cannot change archived status of an account with status of " + account.getStatus())
              .build()
        );
      }
    }
   
View Full Code Here

  @Path("enable-balance")
    public XmlsonObject enable(@Context WesabeUser user,
      @Context Locale locale,
      @PathParam("accountId") IntegerParam accountId) {
   
    final Account account = accountDAO.findAccount(user.getAccountKey(), accountId.getValue());
   
    if (account == null) {
      throw new WebApplicationException(Status.NOT_FOUND);
    }
   
    account.enableBalance();
    save(account);
   
    return present(account, locale);
  }
View Full Code Here

  @Path("disable-balance")
  public XmlsonObject disable(@Context WesabeUser user,
      @Context Locale locale,
      @PathParam("accountId") IntegerParam accountId) {
   
    final Account account = accountDAO.findAccount(user.getAccountKey(), accountId.getValue());
   
    if (account == null) {
      throw new WebApplicationException(Status.NOT_FOUND);
    }
   
    try {
      account.disableBalance();
      save(account);
    } catch (InvalidStateException ex) {
      throw new WebApplicationException(
          Response.status(Status.CONFLICT)
            .entity("Could not disable balance for account")
View Full Code Here

  public XmlsonObject show(@Context WesabeUser user,
      @Context Locale locale,
      @PathParam("accountId") IntegerParam accountId,
      @PathParam("balanceId") IntegerParam balanceId) {
   
    final Account account = accountDAO.findAccount(user.getAccountKey(), accountId.getValue());
    final AccountBalance accountBalance = accountBalanceDAO.findAccountBalance(user.getAccountKey(), balanceId.getValue());
   
    if (accountBalance == null || account == null || !account.equals(accountBalance.getAccount())) {
      throw new WebApplicationException(Status.NOT_FOUND);
    }
   
    return accountBalancePresenter.present(accountBalance, locale);
  }
View Full Code Here

  public XmlsonArray list(@Context WesabeUser user,
      @Context Locale locale,
      @PathParam("accountId") IntegerParam accountId) {
   
    final XmlsonArray result = new XmlsonArray("account-balances");
    final Account account = accountDAO.findAccount(user.getAccountKey(), accountId.getValue());

    if (account.hasBalance()) {
      for (AccountBalance accountBalance : account.getAccountBalances()) {
        result.add(presenter.present(accountBalance, locale));
      }
    }
   
    return result;
View Full Code Here

TOP

Related Classes of com.wesabe.api.accounts.entities.Account

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.