Package com.easypo.XmlPurchaseOrderDocumentBean

Examples of com.easypo.XmlPurchaseOrderDocumentBean.PurchaseOrder


    }

    public void testXBeanSerialization() throws Exception
    {
        XmlPurchaseOrderDocumentBean doc = XmlPurchaseOrderDocumentBean.Factory.newInstance();
        PurchaseOrder order = doc.addNewPurchaseOrder();
        order.addNewCustomer().setName("David Bau");
        order.getCustomer().setAddress("Gladwyne, PA");
        XmlLineItemBean li;
        li = order.addNewLineItem();
        li.setDescription("Burnham's Celestial Handbook, Vol 1");
        li.setPrice(new BigDecimal("21.79"));
        li.setQuantity(BigInteger.valueOf(2));
        li.setPerUnitOunces(new BigDecimal("5"));
        li = order.addNewLineItem();
        li.setDescription("Burnham's Celestial Handbook, Vol 2");
        li.setPrice(new BigDecimal("19.89"));
        li.setQuantity(BigInteger.valueOf(2));
        li.setPerUnitOunces(new BigDecimal("5"));
        li = order.addNewLineItem();
        li.setDescription("Burnham's Celestial Handbook, Vol 3");
        li.setPrice(new BigDecimal("19.89"));
        li.setQuantity(BigInteger.valueOf(1));
        li.setPerUnitOunces(new BigDecimal("5"));
        XmlShipperBean sh = order.addNewShipper();
        sh.setName("UPS");
        sh.setPerOunceRate(new BigDecimal("0.74"));

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(out);
        oos.writeObject(doc.getPurchaseOrder().getLineItemArray(1));
        oos.writeObject(doc);
        oos.writeObject(doc.getPurchaseOrder().getLineItemArray(2));
        oos.close();

        byte[] byteArray = out.toByteArray();
        ByteArrayInputStream in = new ByteArrayInputStream(byteArray);
        ObjectInputStream ois = new ObjectInputStream(in);
        XmlLineItemBean newli1 = (XmlLineItemBean)ois.readObject();
        XmlPurchaseOrderDocumentBean newdoc = (XmlPurchaseOrderDocumentBean)ois.readObject();
        XmlLineItemBean newli2 = (XmlLineItemBean)ois.readObject();
        ois.close();

        PurchaseOrder neworder = newdoc.getPurchaseOrder();

        Assert.assertEquals(newli1, neworder.getLineItemArray(1));
        Assert.assertEquals(newli2, neworder.getLineItemArray(2));

        Assert.assertEquals("David Bau", neworder.getCustomer().getName());
        Assert.assertEquals("Gladwyne, PA", neworder.getCustomer().getAddress());
        Assert.assertEquals(3, neworder.sizeOfLineItemArray());

        Assert.assertEquals("Burnham's Celestial Handbook, Vol 1", neworder.getLineItemArray(0).getDescription());
        Assert.assertEquals(new BigDecimal("21.79"), neworder.getLineItemArray(0).getPrice());
        Assert.assertEquals(new BigInteger("2"), neworder.getLineItemArray(0).getQuantity());
        Assert.assertEquals(new BigDecimal("5"), neworder.getLineItemArray(0).getPerUnitOunces());

        Assert.assertEquals("Burnham's Celestial Handbook, Vol 2", neworder.getLineItemArray(1).getDescription());
        Assert.assertEquals(new BigDecimal("19.89"), neworder.getLineItemArray(1).getPrice());
        Assert.assertEquals(new BigInteger("2"), neworder.getLineItemArray(1).getQuantity());
        Assert.assertEquals(new BigDecimal("5"), neworder.getLineItemArray(1).getPerUnitOunces());

        Assert.assertEquals("Burnham's Celestial Handbook, Vol 3", neworder.getLineItemArray(2).getDescription());
        Assert.assertEquals(new BigDecimal("19.89"), neworder.getLineItemArray(2).getPrice());
        Assert.assertEquals(new BigInteger("1"), neworder.getLineItemArray(2).getQuantity());
        Assert.assertEquals(new BigDecimal("5"), neworder.getLineItemArray(2).getPerUnitOunces());

        Assert.assertEquals(true, neworder.isSetShipper());
        Assert.assertEquals("UPS", neworder.getShipper().getName());
        Assert.assertEquals(new BigDecimal("0.74"), neworder.getShipper().getPerOunceRate());
    }
View Full Code Here


    {
        XmlObject x = findObject();

        if (x instanceof PurchaseOrder)
        {
            PurchaseOrder o = (PurchaseOrder) x;
            o.setDate( Calendar.getInstance() );
        }
        else if (x instanceof XmlCustomerBean)
        {
            XmlCustomerBean o = (XmlCustomerBean) x;
            o.setName( "Bob" );
           
            if (rnd( 2 ) == 0)
                o.setAge( 23 );
           
            if (rnd( 2 ) == 0)
                o.setMoo( 24 );
           
            if (rnd( 2 ) == 0)
                o.setPoo( 200 );
        }
        else if (x instanceof XmlLineItemBean)
        {
            XmlLineItemBean o = (XmlLineItemBean) x;
            o.setPerUnitOunces( new BigDecimal( 122.44 ) );
            o.setPrice( new BigDecimal( 555.33 ) );
            o.setQuantity( BigInteger.valueOf( 111 ) );
        }
        else if (x instanceof XmlShipperBean)
        {
            XmlShipperBean o = (XmlShipperBean) x;
            o.setPerOunceRate( new BigDecimal( 3.14159 ) );
            o.setName( "Eric" );
        }
    }
View Full Code Here

    public void testCreatePo() throws Exception
    {
        XmlPurchaseOrderDocumentBean doc =
            XmlPurchaseOrderDocumentBean.Factory.newInstance();
       
        PurchaseOrder order = doc.addNewPurchaseOrder();
        order.addNewCustomer().setName("David Bau");
        order.getCustomer().setAddress("Gladwyne, PA");
        XmlLineItemBean li;
        li = order.addNewLineItem();
        li.setDescription("Burnham's Celestial Handbook, Vol 1");
        li.setPrice(new BigDecimal("21.79"));
        li.setQuantity(BigInteger.valueOf(2));
        li.setPerUnitOunces(new BigDecimal("5"));
        li = order.addNewLineItem();
        li.setDescription("Burnham's Celestial Handbook, Vol 2");
        li.setPrice(new BigDecimal("19.89"));
        li.setQuantity(BigInteger.valueOf(2));
        li.setPerUnitOunces(new BigDecimal("5"));
        li = order.addNewLineItem();
        li.setDescription("Burnham's Celestial Handbook, Vol 3");
        li.setPrice(new BigDecimal("19.89"));
        li.setQuantity(BigInteger.valueOf(1));
        li.setPerUnitOunces(new BigDecimal("5"));
        XmlShipperBean sh = order.addNewShipper();
        sh.setName("UPS");
        sh.setPerOunceRate(new BigDecimal("0.74"));

//        System.out.println(doc.xmlText());

        Assert.assertEquals("David Bau", order.getCustomer().getName());
        Assert.assertEquals("Gladwyne, PA", order.getCustomer().getAddress());
        Assert.assertEquals(3, order.sizeOfLineItemArray());

        Assert.assertEquals("Burnham's Celestial Handbook, Vol 1", order.getLineItemArray(0).getDescription());
        Assert.assertEquals(new BigDecimal("21.79"), order.getLineItemArray(0).getPrice());
        Assert.assertEquals(new BigInteger("2"), order.getLineItemArray(0).getQuantity());
        Assert.assertEquals(new BigDecimal("5"), order.getLineItemArray(0).getPerUnitOunces());

        Assert.assertEquals("Burnham's Celestial Handbook, Vol 2", order.getLineItemArray(1).getDescription());
        Assert.assertEquals(new BigDecimal("19.89"), order.getLineItemArray(1).getPrice());
        Assert.assertEquals(new BigInteger("2"), order.getLineItemArray(1).getQuantity());
        Assert.assertEquals(new BigDecimal("5"), order.getLineItemArray(1).getPerUnitOunces());

        Assert.assertEquals("Burnham's Celestial Handbook, Vol 3", order.getLineItemArray(2).getDescription());
        Assert.assertEquals(new BigDecimal("19.89"), order.getLineItemArray(2).getPrice());
        Assert.assertEquals(new BigInteger("1"), order.getLineItemArray(2).getQuantity());
        Assert.assertEquals(new BigDecimal("5"), order.getLineItemArray(2).getPerUnitOunces());

        Assert.assertEquals(true, order.isSetShipper());
        Assert.assertEquals("UPS", order.getShipper().getName());
        Assert.assertEquals(new BigDecimal("0.74"), order.getShipper().getPerOunceRate());
    }
View Full Code Here

    public void testEasyPo() throws Exception
    {
        XmlPurchaseOrderDocumentBean doc = (XmlPurchaseOrderDocumentBean)
            XmlObject.Factory.parse(TestEnv.xbeanCase("store/easypo1.xml"));
        Assert.assertEquals(false, doc.isNil());
        PurchaseOrder order = doc.getPurchaseOrder();
        Assert.assertEquals("David Bau", order.getCustomer().getName());
        Assert.assertEquals("Gladwyne, PA", order.getCustomer().getAddress());
        Assert.assertEquals(3, order.sizeOfLineItemArray());

        Assert.assertEquals("Burnham's Celestial Handbook, Vol 1", order.getLineItemArray(0).getDescription());
        Assert.assertEquals(new BigDecimal("21.79"), order.getLineItemArray(0).getPrice());
        Assert.assertEquals(new BigInteger("2"), order.getLineItemArray(0).getQuantity());
        Assert.assertEquals(new BigDecimal("5"), order.getLineItemArray(0).getPerUnitOunces());

        Assert.assertEquals("Burnham's Celestial Handbook, Vol 2", order.getLineItemArray(1).getDescription());
        Assert.assertEquals(new BigDecimal("19.89"), order.getLineItemArray(1).getPrice());
        Assert.assertEquals(new BigInteger("2"), order.getLineItemArray(1).getQuantity());
        Assert.assertEquals(new BigDecimal("5"), order.getLineItemArray(1).getPerUnitOunces());

        Assert.assertEquals("Burnham's Celestial Handbook, Vol 3", order.getLineItemArray(2).getDescription());
        Assert.assertEquals(new BigDecimal("19.89"), order.getLineItemArray(2).getPrice());
        Assert.assertEquals(new BigInteger("1"), order.getLineItemArray(2).getQuantity());
        Assert.assertEquals(new BigDecimal("5"), order.getLineItemArray(2).getPerUnitOunces());

        Assert.assertEquals(true, order.isSetShipper());
        Assert.assertEquals("UPS", order.getShipper().getName());
        Assert.assertEquals(new BigDecimal("0.74"), order.getShipper().getPerOunceRate());

        Assert.assertEquals(3, order.sizeOfLineItemArray());
    }
View Full Code Here

    public void testCreatePo() throws Exception
    {
        XmlPurchaseOrderDocumentBean doc =
            XmlPurchaseOrderDocumentBean.Factory.newInstance();
       
        PurchaseOrder order = doc.addNewPurchaseOrder();
        order.addNewCustomer().setName("David Bau");
        order.getCustomer().setAddress("Gladwyne, PA");
        XmlLineItemBean li;
        li = order.addNewLineItem();
        li.setDescription("Burnham's Celestial Handbook, Vol 1");
        li.setPrice(new BigDecimal("21.79"));
        li.setQuantity(BigInteger.valueOf(2));
        li.setPerUnitOunces(new BigDecimal("5"));
        li = order.addNewLineItem();
        li.setDescription("Burnham's Celestial Handbook, Vol 2");
        li.setPrice(new BigDecimal("19.89"));
        li.setQuantity(BigInteger.valueOf(2));
        li.setPerUnitOunces(new BigDecimal("5"));
        li = order.addNewLineItem();
        li.setDescription("Burnham's Celestial Handbook, Vol 3");
        li.setPrice(new BigDecimal("19.89"));
        li.setQuantity(BigInteger.valueOf(1));
        li.setPerUnitOunces(new BigDecimal("5"));
        XmlShipperBean sh = order.addNewShipper();
        sh.setName("UPS");
        sh.setPerOunceRate(new BigDecimal("0.74"));

//        System.out.println(doc.xmlText());

        Assert.assertEquals("David Bau", order.getCustomer().getName());
        Assert.assertEquals("Gladwyne, PA", order.getCustomer().getAddress());
        Assert.assertEquals(3, order.sizeOfLineItemArray());

        Assert.assertEquals("Burnham's Celestial Handbook, Vol 1", order.getLineItemArray(0).getDescription());
        Assert.assertEquals(new BigDecimal("21.79"), order.getLineItemArray(0).getPrice());
        Assert.assertEquals(new BigInteger("2"), order.getLineItemArray(0).getQuantity());
        Assert.assertEquals(new BigDecimal("5"), order.getLineItemArray(0).getPerUnitOunces());

        Assert.assertEquals("Burnham's Celestial Handbook, Vol 2", order.getLineItemArray(1).getDescription());
        Assert.assertEquals(new BigDecimal("19.89"), order.getLineItemArray(1).getPrice());
        Assert.assertEquals(new BigInteger("2"), order.getLineItemArray(1).getQuantity());
        Assert.assertEquals(new BigDecimal("5"), order.getLineItemArray(1).getPerUnitOunces());

        Assert.assertEquals("Burnham's Celestial Handbook, Vol 3", order.getLineItemArray(2).getDescription());
        Assert.assertEquals(new BigDecimal("19.89"), order.getLineItemArray(2).getPrice());
        Assert.assertEquals(new BigInteger("1"), order.getLineItemArray(2).getQuantity());
        Assert.assertEquals(new BigDecimal("5"), order.getLineItemArray(2).getPerUnitOunces());

        Assert.assertEquals(true, order.isSetShipper());
        Assert.assertEquals("UPS", order.getShipper().getName());
        Assert.assertEquals(new BigDecimal("0.74"), order.getShipper().getPerOunceRate());
    }
View Full Code Here

    public void testEasyPo() throws Exception
    {
        XmlPurchaseOrderDocumentBean doc = (XmlPurchaseOrderDocumentBean)
            XmlObject.Factory.parse(TestEnv.xbeanCase("store/easypo1.xml"));
        Assert.assertEquals(false, doc.isNil());
        PurchaseOrder order = doc.getPurchaseOrder();
        Assert.assertEquals("David Bau", order.getCustomer().getName());
        Assert.assertEquals("Gladwyne, PA", order.getCustomer().getAddress());
        Assert.assertEquals(3, order.sizeOfLineItemArray());

        Assert.assertEquals("Burnham's Celestial Handbook, Vol 1", order.getLineItemArray(0).getDescription());
        Assert.assertEquals(new BigDecimal("21.79"), order.getLineItemArray(0).getPrice());
        Assert.assertEquals(new BigInteger("2"), order.getLineItemArray(0).getQuantity());
        Assert.assertEquals(new BigDecimal("5"), order.getLineItemArray(0).getPerUnitOunces());

        Assert.assertEquals("Burnham's Celestial Handbook, Vol 2", order.getLineItemArray(1).getDescription());
        Assert.assertEquals(new BigDecimal("19.89"), order.getLineItemArray(1).getPrice());
        Assert.assertEquals(new BigInteger("2"), order.getLineItemArray(1).getQuantity());
        Assert.assertEquals(new BigDecimal("5"), order.getLineItemArray(1).getPerUnitOunces());

        Assert.assertEquals("Burnham's Celestial Handbook, Vol 3", order.getLineItemArray(2).getDescription());
        Assert.assertEquals(new BigDecimal("19.89"), order.getLineItemArray(2).getPrice());
        Assert.assertEquals(new BigInteger("1"), order.getLineItemArray(2).getQuantity());
        Assert.assertEquals(new BigDecimal("5"), order.getLineItemArray(2).getPerUnitOunces());

        Assert.assertEquals(true, order.isSetShipper());
        Assert.assertEquals("UPS", order.getShipper().getName());
        Assert.assertEquals(new BigDecimal("0.74"), order.getShipper().getPerOunceRate());

        Assert.assertEquals(3, order.sizeOfLineItemArray());
    }
View Full Code Here

    }

    public void testXBeanSerialization() throws Exception
    {
        XmlPurchaseOrderDocumentBean doc = XmlPurchaseOrderDocumentBean.Factory.newInstance();
        PurchaseOrder order = doc.addNewPurchaseOrder();
        order.addNewCustomer().setName("David Bau");
        order.getCustomer().setAddress("Gladwyne, PA");
        XmlLineItemBean li;
        li = order.addNewLineItem();
        li.setDescription("Burnham's Celestial Handbook, Vol 1");
        li.setPrice(new BigDecimal("21.79"));
        li.setQuantity(BigInteger.valueOf(2));
        li.setPerUnitOunces(new BigDecimal("5"));
        li = order.addNewLineItem();
        li.setDescription("Burnham's Celestial Handbook, Vol 2");
        li.setPrice(new BigDecimal("19.89"));
        li.setQuantity(BigInteger.valueOf(2));
        li.setPerUnitOunces(new BigDecimal("5"));
        li = order.addNewLineItem();
        li.setDescription("Burnham's Celestial Handbook, Vol 3");
        li.setPrice(new BigDecimal("19.89"));
        li.setQuantity(BigInteger.valueOf(1));
        li.setPerUnitOunces(new BigDecimal("5"));
        XmlShipperBean sh = order.addNewShipper();
        sh.setName("UPS");
        sh.setPerOunceRate(new BigDecimal("0.74"));

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(out);
        oos.writeObject(doc.getPurchaseOrder().getLineItemArray(1));
        oos.writeObject(doc);
        oos.writeObject(doc.getPurchaseOrder().getLineItemArray(2));
        oos.close();

        byte[] byteArray = out.toByteArray();
        ByteArrayInputStream in = new ByteArrayInputStream(byteArray);
        ObjectInputStream ois = new ObjectInputStream(in);
        XmlLineItemBean newli1 = (XmlLineItemBean)ois.readObject();
        XmlPurchaseOrderDocumentBean newdoc = (XmlPurchaseOrderDocumentBean)ois.readObject();
        XmlLineItemBean newli2 = (XmlLineItemBean)ois.readObject();
        ois.close();

        PurchaseOrder neworder = newdoc.getPurchaseOrder();

        Assert.assertEquals(newli1, neworder.getLineItemArray(1));
        Assert.assertEquals(newli2, neworder.getLineItemArray(2));

        Assert.assertEquals("David Bau", neworder.getCustomer().getName());
        Assert.assertEquals("Gladwyne, PA", neworder.getCustomer().getAddress());
        Assert.assertEquals(3, neworder.sizeOfLineItemArray());

        Assert.assertEquals("Burnham's Celestial Handbook, Vol 1", neworder.getLineItemArray(0).getDescription());
        Assert.assertEquals(new BigDecimal("21.79"), neworder.getLineItemArray(0).getPrice());
        Assert.assertEquals(new BigInteger("2"), neworder.getLineItemArray(0).getQuantity());
        Assert.assertEquals(new BigDecimal("5"), neworder.getLineItemArray(0).getPerUnitOunces());

        Assert.assertEquals("Burnham's Celestial Handbook, Vol 2", neworder.getLineItemArray(1).getDescription());
        Assert.assertEquals(new BigDecimal("19.89"), neworder.getLineItemArray(1).getPrice());
        Assert.assertEquals(new BigInteger("2"), neworder.getLineItemArray(1).getQuantity());
        Assert.assertEquals(new BigDecimal("5"), neworder.getLineItemArray(1).getPerUnitOunces());

        Assert.assertEquals("Burnham's Celestial Handbook, Vol 3", neworder.getLineItemArray(2).getDescription());
        Assert.assertEquals(new BigDecimal("19.89"), neworder.getLineItemArray(2).getPrice());
        Assert.assertEquals(new BigInteger("1"), neworder.getLineItemArray(2).getQuantity());
        Assert.assertEquals(new BigDecimal("5"), neworder.getLineItemArray(2).getPerUnitOunces());

        Assert.assertEquals(true, neworder.isSetShipper());
        Assert.assertEquals("UPS", neworder.getShipper().getName());
        Assert.assertEquals(new BigDecimal("0.74"), neworder.getShipper().getPerOunceRate());
    }
View Full Code Here

    {
        XmlObject x = findObject();

        if (x instanceof PurchaseOrder)
        {
            PurchaseOrder o = (PurchaseOrder) x;
            o.setDate( Calendar.getInstance() );
        }
        else if (x instanceof XmlCustomerBean)
        {
            XmlCustomerBean o = (XmlCustomerBean) x;
            o.setName( "Bob" );
           
            if (rnd( 2 ) == 0)
                o.setAge( 23 );
           
            if (rnd( 2 ) == 0)
                o.setMoo( 24 );
           
            if (rnd( 2 ) == 0)
                o.setPoo( 200 );
        }
        else if (x instanceof XmlLineItemBean)
        {
            XmlLineItemBean o = (XmlLineItemBean) x;
            o.setPerUnitOunces( new BigDecimal( 122.44 ) );
            o.setPrice( new BigDecimal( 555.33 ) );
            o.setQuantity( BigInteger.valueOf( 111 ) );
        }
        else if (x instanceof XmlShipperBean)
        {
            XmlShipperBean o = (XmlShipperBean) x;
            o.setPerOunceRate( new BigDecimal( 3.14159 ) );
            o.setName( "Eric" );
        }
    }
View Full Code Here

TOP

Related Classes of com.easypo.XmlPurchaseOrderDocumentBean.PurchaseOrder

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.