Package interfaceFeature.xbean.multInterfaces.purchaseOrder

Examples of interfaceFeature.xbean.multInterfaces.purchaseOrder.PurchaseOrderDocument


    public void test()
    {


        PurchaseOrderDocument poDoc = null;

        poDoc = PurchaseOrderDocument.Factory.newInstance();
        PurchaseOrderType po = poDoc.addNewPurchaseOrder();
        int LEN = 20;

        Items.Item[] it = new Items.Item[LEN];
        for (int i = 0; i < LEN; i++)
        {
            it[i] = Items.Item.Factory.newInstance();
            it[i].setUSPrice(new BigDecimal("" + i));
        }
        Items items = Items.Factory.newInstance();
        items.setItemArray(it);
        po.setItems(items);

        StringBuffer sb = new StringBuffer();
        sb.append("<pur:purchaseOrder xmlns:pur=\"http://xbean.interface_feature/multInterfaces/PurchaseOrder\">");

        sb.append("<pur:items>");

        StringBuffer sbContent = new StringBuffer();
        for (int i = 0; i < LEN; i++)
            sbContent.append("<pur:item><pur:USPrice>" + i + "</pur:USPrice></pur:item>");

        int pos = sb.length();
        sb.append("</pur:items></pur:purchaseOrder>");

        String sExpected = sb.substring(0, pos) + sbContent.toString() + sb.substring(pos, sb.length());
        assertEquals(sExpected, poDoc.xmlText());


        assertEquals(0, poDoc.getMinPrice());
        int price = 10;

        poDoc.setMinPrice((double) price);

        sbContent = new StringBuffer();
        for (int i = 0; i < LEN; i++)
            if (i < price)
                sbContent.append("<pur:item><pur:USPrice>" + price + "</pur:USPrice></pur:item>");
            else
                sbContent.append("<pur:item><pur:USPrice>" + i + "</pur:USPrice></pur:item>");
        sExpected = sb.substring(0, pos) + sbContent.toString() + sb.substring(pos, sb.length());
        assertEquals(sExpected, poDoc.xmlText());

        assertEquals(price, poDoc.getMinPrice());

        int expTotal = (price - 1) * price + (price + 1 + LEN) * (LEN - price) / 2;
        assertEquals(expTotal, poDoc.getTotal());

        XmlObject item = poDoc.getCheapestItem();

        Item expected = it[0];
        expected.setUSPrice(new BigDecimal(30d));
        //       assertEquals(expected, item );
    }
View Full Code Here


    public void test()
    {


        PurchaseOrderDocument poDoc = null;

        poDoc = PurchaseOrderDocument.Factory.newInstance();
        PurchaseOrderType po = poDoc.addNewPurchaseOrder();
        int LEN = 20;

        Items.Item[] it = new Items.Item[LEN];
        for (int i = 0; i < LEN; i++)
        {
            it[i] = Items.Item.Factory.newInstance();
            it[i].setUSPrice(new BigDecimal("" + i));
        }
        Items items = Items.Factory.newInstance();
        items.setItemArray(it);
        po.setItems(items);

        StringBuffer sb = new StringBuffer();
        sb.append("<pur:purchaseOrder xmlns:pur=\"http://xbean.interface_feature/multInterfaces/PurchaseOrder\">");

        sb.append("<pur:items>");

        StringBuffer sbContent = new StringBuffer();
        for (int i = 0; i < LEN; i++)
            sbContent.append("<pur:item><pur:USPrice>" + i + "</pur:USPrice></pur:item>");

        int pos = sb.length();
        sb.append("</pur:items></pur:purchaseOrder>");

        String sExpected = sb.subSequence(0, pos) + sbContent.toString() + sb.subSequence(pos, sb.length());
        assertEquals(sExpected, poDoc.xmlText());


        assertEquals(0, poDoc.getMinPrice());
        int price = 10;

        poDoc.setMinPrice((double) price);

        sbContent = new StringBuffer();
        for (int i = 0; i < LEN; i++)
            if (i < price)
                sbContent.append("<pur:item><pur:USPrice>" + price + "</pur:USPrice></pur:item>");
            else
                sbContent.append("<pur:item><pur:USPrice>" + i + "</pur:USPrice></pur:item>");
        sExpected = sb.subSequence(0, pos) + sbContent.toString() + sb.subSequence(pos, sb.length());
        assertEquals(sExpected, poDoc.xmlText());

        assertEquals(price, poDoc.getMinPrice());

        int expTotal = (price - 1) * price + (price + 1 + LEN) * (LEN - price) / 2;
        assertEquals(expTotal, poDoc.getTotal());

        XmlObject item = poDoc.getCheapestItem();

        Item expected = it[0];
        expected.setUSPrice(new BigDecimal(30d));
        //       assertEquals(expected, item );
    }
View Full Code Here

{
    public static int getTotal(XmlObject xo)
    {

        int sum = 0;
        PurchaseOrderDocument poDoc = (PurchaseOrderDocument) xo;
        Item[] items = poDoc.getPurchaseOrder().getItems().getItemArray();

        for (int i = 0; i < items.length; i++)
            sum += items[i].getUSPrice().intValue();
        return sum;
    }
View Full Code Here

        return sum;
    }

    public static int getMinPrice(XmlObject xo)
    {
        PurchaseOrderDocument poDoc = (PurchaseOrderDocument) xo;
        Item[] items = poDoc.getPurchaseOrder().getItems().getItemArray();

        int min = Integer.MAX_VALUE;
        for (int i = 0; i < items.length; i++)
        {
            int tmp = items[i].getUSPrice().intValue();
View Full Code Here

        return min;
    }

    public static XmlObject getCheapestItem(XmlObject xo)
    {
        PurchaseOrderDocument poDoc = (PurchaseOrderDocument) xo;
        Item[] items = poDoc.getPurchaseOrder().getItems().getItemArray();

        int min = Integer.MAX_VALUE;
        XmlObject item = null;

        for (int i = 0; i < items.length; i++)
View Full Code Here

        return item;
    }

    public static void setMinPrice(XmlObject xo, double min_price)
    {
        PurchaseOrderDocument poDoc = (PurchaseOrderDocument) xo;
        Item[] items = poDoc.getPurchaseOrder().getItems().getItemArray();

        BigDecimal newPrice = new BigDecimal(min_price);

        for (int i = 0; i < items.length; i++)
        {
View Full Code Here

TOP

Related Classes of interfaceFeature.xbean.multInterfaces.purchaseOrder.PurchaseOrderDocument

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.