Package com.wesabe.xmlson

Examples of com.wesabe.xmlson.XmlsonArray


    }
   
    @Test
    public void itHasTheIntervalForEachSummary() throws Exception {
      final XmlsonObject representation = presenter.present(ImmutableMap.of(interval, summary), Locale.CANADA_FRENCH);
      final XmlsonArray summaries = (XmlsonArray) representation.get("summaries");
      final XmlsonObject summary = (XmlsonObject) summaries.getMembers().get(0);
      final XmlsonObject interval = (XmlsonObject) summary.get("interval");
     
      assertThat(interval.getString("start")).isEqualTo("20060701");
      assertThat(interval.getString("end")).isEqualTo("20060801");
    }
View Full Code Here


    }
   
    @Test
    public void itHasTheSplitSummariesForEachSummary() throws Exception {
      final XmlsonObject representation = presenter.present(ImmutableMap.of(interval, summary), Locale.CANADA_FRENCH);
      final XmlsonArray summaries = (XmlsonArray) representation.get("summaries");
      final XmlsonObject summary = (XmlsonObject) summaries.getMembers().get(0);
     
      final XmlsonArray splits = (XmlsonArray) summary.get("splits");
     
     
     
      final XmlsonObject foodSummary = (XmlsonObject) splits.getMembers().get(0);
     
      final XmlsonObject tag = (XmlsonObject) foodSummary.get("tag");
      assertThat(tag.getString("name")).isEqualTo("food");
     
      final XmlsonObject spending = (XmlsonObject) foodSummary.get("spending");
View Full Code Here

       
    @Test
    public void itHasAnEmptyArrayOfTags() throws Exception {
      final XmlsonObject representation = presenter.present(txaction, Locale.UK);
     
      final XmlsonArray tags = (XmlsonArray) representation.get("tags");
      assertThat(tags.getMembers().size(), is(0));
    }
View Full Code Here

   
    @Test
    public void itHasAnAttachment() throws Exception {
      final XmlsonObject representation = presenter.present(txaction, Locale.UK);
     
      final XmlsonArray attachments = (XmlsonArray) representation.get("attachments");
      assertThat(attachments.getMembers().size(), is(1));
     
      final XmlsonObject attachment = (XmlsonObject) attachments.getMembers().get(0);
      assertThat(attachment, is(attachmentRepresentation));
     
      verify(attachmentPresenter).present(this.attachment);
    }
View Full Code Here

    @Test
    public void itHasAnArrayOfTaggedAmounts() throws Exception {
      final XmlsonObject representation = presenter.present(txaction, Locale.UK);

      final XmlsonArray tags = (XmlsonArray) representation.get("tags");
      assertThat(tags.getMembers().size(), is(1));

      final XmlsonObject tag = (XmlsonObject) tags.getMembers().get(0);
      assertThat(tag, is(taggedAmountRepresentation));

      verify(taggedAmountPresenter).present(this.taggedAmount, Locale.UK);
    }
View Full Code Here

    @Test
    public void itHasAnEmptyArrayOfTags() throws Exception {
      final XmlsonObject envelope = presenter.present(txaction, Locale.UK);
      final XmlsonObject representation = (XmlsonObject) envelope.get("transfer");
     
      final XmlsonArray tags = (XmlsonArray) representation.get("tags");
      assertThat(tags.getMembers().size(), is(0));
    }
View Full Code Here

   
    @Test
    public void itHasTwoTopNodes() throws Exception {
      final XmlsonObject representation = presenter.present(hierarchy, Locale.CANADA_FRENCH);
     
      final XmlsonArray nodes = (XmlsonArray) representation.get("nodes");
     
      assertThat(nodes.getMembers()).hasSize(2);
    }
View Full Code Here

   
    @Test
    public void itHasATopNodeForFoodWithChildren() throws Exception {
      final XmlsonObject representation = presenter.present(hierarchy, Locale.CANADA_FRENCH);
     
      final XmlsonArray nodes = (XmlsonArray) representation.get("nodes");
      int checkedNodes = 0;
     
      for (XmlsonMember member : nodes.getMembers()) {
        final XmlsonObject node = (XmlsonObject) member;
        if (((XmlsonObject) node.get("tag")).getString("name").equals("food")) {
          final XmlsonObject sum = (XmlsonObject) node.get("sum");
         
          assertThat(sum.getString("display")).isEqualTo("50,00 $ US");
View Full Code Here

   
    @Test
    public void itHasTheGroupsAccountsAsReferences() throws Exception {
      final XmlsonObject representation = presenter.present(group, USD, Locale.KOREA);
     
      final XmlsonArray accounts = (XmlsonArray) representation.get("accounts");
      assertThat(accounts.getMembers().size(), is(1));
     
      final XmlsonObject account = (XmlsonObject) accounts.getMembers().get(0);
      assertThat(account.getString("uri"), is("/accounts/20"));
    }
View Full Code Here

    this.investmentPositionPresenter = investmentPositionPresenter;
  }

  public XmlsonObject present(InvestmentAccount account, Locale locale) {
    final XmlsonObject result = super.present(account, locale);
    final XmlsonArray positions = new XmlsonArray("investment-positions");
    for (InvestmentPosition position : account.getCurrentInvestmentPositions()) {
      positions.add(investmentPositionPresenter.present(position, locale));
    }
    result.add(positions);
   
    result.add(moneyPresenter.present("market-value", account.getMarketValue(), locale));
   
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.