Package com.wesabe.xmlson

Examples of com.wesabe.xmlson.XmlsonArray


   
    @Test
    public void itHasAnArrayOfAccounts() throws Exception {
      final XmlsonObject representation = presenter.present(accounts, USD, Locale.PRC);
     
      final XmlsonArray accounts = (XmlsonArray) representation.get("accounts");
      assertThat(accounts.getMembers().size(), is(1));
     
      final XmlsonObject account = (XmlsonObject) accounts.getMembers().get(0);
      assertThat(account.getName(), is("account"));
     
      verify(accountPresenter).present(this.account, Locale.PRC);
    }
View Full Code Here


   
    @Test
    public void itHasAnArrayOfGroups() throws Exception {
      final XmlsonObject representation = presenter.present(accounts, USD, Locale.PRC);
     
      final XmlsonArray groups = (XmlsonArray) representation.get("account-groups");
      assertThat(groups.getMembers().size(), is(1));
     
      final XmlsonObject group = (XmlsonObject) groups.getMembers().get(0);
      assertThat(group.getName(), is("group"));
     
      verify(accountGroupPresenter).present(this.group, USD, Locale.PRC);
    }
View Full Code Here

  public XmlsonObject present(TxactionList txactions, Locale locale) {
    final XmlsonObject root = new XmlsonObject("transaction-list");

    root.add(new XmlsonObject("count").addProperty("total", txactions.getTotalCount()));

    final XmlsonArray list = new XmlsonArray("transactions");
    for (TxactionListItem item : txactions) {
      final XmlsonObject txaction = txactionPresenter.present(item.getTxaction(), locale);
      if (item.getBalance() != null) {
        txaction.add(moneyPresenter.present("balance", item.getBalance(), locale));
      }
      list.add(txaction);
    }
    root.add(list);

    return root;
  }
View Full Code Here

  @GET
  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.xmlson.XmlsonArray

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.