SOAP-Lite

 view release on metacpan or  search on metacpan

t/05-customxml.t  view on Meta::CPAN

#!/usr/bin/env perl

BEGIN {
  unless(grep /blib/, @INC) {
    chdir 't' if -d 't';
    unshift @INC, '../lib' if -d '../lib';
  }
}

use strict;
use Test;

use SOAP::Lite;

plan tests => 40;

my($a, $s, $r, $serialized, $deserialized);

$deserialized = SOAP::Custom::XML::Deserializer
  -> deserialize(join '', <DATA>);

ok(ref $deserialized);

$r = $deserialized->valueof('/Envelope/Body');

ok(ref $r);

my @portfolios = $r->Report->Request->Composition->PortfolioDistribution;

ok(@portfolios == 6);

foreach my $portfolio (@portfolios) {
  # test attributes
  print $portfolio->type, " ", $portfolio->date, "\n";
  ok($portfolio->type && $portfolio->date);
  foreach my $row ($portfolio->Row) {
    # test elements
    print "  ", $row->Element, " ", $row->Value, "\n";
    ok($row->Element && $row->Value);
  }
}

__DATA__
<?xml version="1.0" encoding="UTF-8"?>
<Envelope version="1.1">
  <Header />
  <Body>
    <Report>
      <Header>
        <ClientRef />
        <FundCusip>61744J366</FundCusip>
        <SepAcctDesc />
      </Header>
      <Request>
        <Errors>
          <Error>Returned no data for request: PortfolioDistribution</Error>
          <Error>Returned no data for request: PortfolioDistribution</Error>
          <Error>Returned no data for request: PortfolioDistribution</Error>
          <Error>Returned no data for request: PortfolioDistribution</Error>
          <Error>Could not retrieve PortfolioDistribution</Error>
          <Error>Could not retrieve PortfolioDistribution</Error>
          <Error>Could not retrieve PortfolioDistribution</Error>
          <Error>Could not retrieve PortfolioDistribution</Error>
        </Errors>
        <Composition>
          <PortfolioDistribution type="CE" date="09/30/2000" />
          <PortfolioDistribution type="GB" date="09/30/2000" />
          <PortfolioDistribution type="ST" date="09/30/2000">
            <Row>
              <Element>Common Stocks</Element>
              <Value>0.9991</Value>
            </Row>
            <Row>
              <Element>Other</Element>
              <Value>0.0021</Value>
            </Row>
            <Row>
              <Element>Cash &amp; Cash Equivalents</Element>
              <Value>-0.0012</Value>
            </Row>
          </PortfolioDistribution>
          <PortfolioDistribution type="TT" date="09/30/2000">
            <Row>
              <Element>General Electric Company</Element>
              <Value>0.0458</Value>
            </Row>
            <Row>
              <Element>Cisco Systems Inc</Element>
              <Value>0.033</Value>
            </Row>
            <Row>
              <Element>Microsoft Corporation</Element>
              <Value>0.0263</Value>
            </Row>
            <Row>
              <Element>Exxon Mobil Corp.</Element>
              <Value>0.0263</Value>
            </Row>
            <Row>
              <Element>Pfizer, Inc.</Element>
              <Value>0.0231</Value>
            </Row>
            <Row>
              <Element>Intel Corporation</Element>

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.734 second using v1.00-cache-2.02-grep-82fe00e-cpan-cec75d87357c )