package org.xmx0632.deliciousfruit.erp; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import org.junit.Ignore; import org.junit.Test; import org.xmx0632.deliciousfruit.erp.bo.ErpOrder; import org.xmx0632.deliciousfruit.erp.bo.ErpOrderCard; import org.xmx0632.deliciousfruit.erp.bo.ErpOrderCash; import org.xmx0632.deliciousfruit.erp.bo.ErpOrderProduct; @Ignore public class ErpApiServiceOrderTest extends BaseErpApiServiceTest { @Test public void testOrderCard_not_exist_card() throws Exception { ErpOrderCard orderCard = new ErpOrderCard(); orderCard.setERPID("MO00999"); orderCard.setDecOldValue("12"); orderCard.setDecValue("6"); orderCard.setErpOrder("MO0001"); orderCard.setStrCardNo("MO000000000001"); String expected = "ErpOrderCard [ERPID=MO00999, erpOrder=MO0001, decValue=6, decOldValue=12, strCardNo=MO000000000001]"; assertEquals(expected, orderCard.toString()); // req:{"action":"Input","data":[{"decOldValue":"12","decValue":"6","ERPID":"MO00999","erpOrder":"MO0001","strCardNo":"MO000000000001"}],"key":"893b47c4ddd65d435e7111b0e0c35e56","password":"shyst","timestamp":1362399877,"type":"OrderCard","username":"user"} // resp:{"result":0,"data":{"arrID":["MO00999"],"message":"input the records success"}} boolean success = service.orderCard(orderCard); assertTrue(success); } @Test public void testOrderCard_exist_card() throws Exception { ErpOrderCard orderCard = new ErpOrderCard(); orderCard.setERPID("MO000001"); orderCard.setDecOldValue("12"); orderCard.setDecValue("6"); orderCard.setErpOrder("MO0001"); orderCard.setStrCardNo("00000000"); String expected = "ErpOrderCard [ERPID=MO000001, erpOrder=MO0001, decValue=6, decOldValue=12, strCardNo=00000000]"; assertEquals(expected, orderCard.toString()); // req:{"action":"Input","data":[{"decOldValue":"12","decValue":"6","ERPID":"MO000001","erpOrder":"MO0001","strCardNo":"00000000"}],"key":"860e45456e8247105fa04115390bd8d8","password":"shyst","timestamp":1362400354,"type":"OrderCard","username":"user"} // resp:{"result":0,"data":{"arrID":["MO000001"],"message":"input the records success"}} boolean success = service.orderCard(orderCard); assertTrue(success); } @Test public void testOrderCash() throws Exception { ErpOrderCash orderCash = new ErpOrderCash(); orderCash.setERPID("WEB100254"); orderCash.setDecValue("10"); orderCash.setErpOrder("WEB100254"); orderCash.setStrCardNo("11111111"); String expected = "ErpOrderCash [ERPID=WEB100254, erpOrder=WEB100254, decValue=10, strCardNo=11111111]"; assertEquals(expected, orderCash.toString()); // req:{"action":"Input","data":[{"decValue":"10","ERPID":"WEB100254","erpOrder":"WEB100254","strCardNo":"11111111"}],"key":"4e79cedb8cf4baf5177ea1c3e658a059","password":"shyst","timestamp":1362483119,"type":"OrderCash","username":"user"} // resp:{"result":0,"data":{"arrID":["WEB100254"],"message":"input the records success"}} boolean success = service.orderCash(orderCash); assertTrue(success); } @Test public void testOrderProduct() throws Exception { ErpOrderProduct orderProduct = new ErpOrderProduct(); orderProduct.setDecAmount("2"); orderProduct.setDecUnitValue("1"); orderProduct.setDecValue("6"); orderProduct.setERPID("MO000008"); orderProduct.setErpOrder("WEB100254"); orderProduct.setStrProductNumber("ZZ000001"); String expected = "ErpOrderProduct [ERPID=MO000008, erpOrder=WEB100254, strProductNumber=ZZ000001, decAmount=2, decUnitValue=1, decValue=6, strCodeNo=, strProductName=]"; assertEquals(expected, orderProduct.toString()); // req:{"action":"Input","data":[{"decAmount":"2","decUnitValue":"1","decValue":"6","ERPID":"MO000001","erpOrder":"WEB100254","strCodeNo":"","strProductName":"","strProductNumber":"ZZ000001"}],"key":"34702f5559c4a0b6f45979e6193f722a","password":"shyst","timestamp":1362404393,"type":"OrderProduct","username":"user"} // resp:{"result":0,"data":{"arrID":["MO000001"],"message":"input the records success"}} boolean success = service.orderProduct(orderProduct); assertTrue(success); } @Test public void testOrder() { ErpOrder order = new ErpOrder(); order.setDatDate("2013-02-01"); order.setDatWishDate("2013-02-05"); order.setDecAdvAmount("10"); order.setDecBillAmount("15"); order.setDecCardValue("0"); order.setDecCashValue("0"); order.setDecCoin("0"); order.setDecFullMinus("4"); order.setDecNeedPay("1"); order.setDecTotalFee("11"); order.setDecTransportFee("2"); order.setDecValue("3"); order.setErpCustomer("WEB000014"); order.setERPID("XD13030412345"); order.setIntCouponValue("0"); order.setIntOrderStatus("2"); order.setIntPoint("6"); order.setIntPointValue("3"); order.setIntTransportStatus("1"); order.setStrAddress("addr1"); order.setStrArea("area"); order.setStrCity("city"); order.setStrCustomerName("MoCustomer1"); order.setStrFirstname("1stName"); order.setStrInvoiceContent("发票1"); order.setStrInvoiceTitle("food"); order.setStrMobilePhone("13800138000"); order.setStrPaymentType("3"); order.setStrPhone("057112345678"); order.setStrProvince("shanghai"); order.setStrTransportType("0"); order.setStrWishTime("12:30"); String expected = "ErpOrder [Space= , strCustomerName=MoCustomer1, strTransportType=0, decAdvAmount=10, decBillAmount=15, decNeedPay=1, decTotalFee=11, intPointValue=3, intOrderStatus=2, intTransportStatus=1, erpCustomer=WEB000014, strFirstname=1stName, strPhone=057112345678, strMobilePhone=13800138000, strProvince=shanghai, strCity=city, strAddress=addr1, strArea=area, strPaymentType=3, datWishDate=2013-02-05, strWishTime=12:30, decValue=3, decTransportFee=2, intPoint=6, decCoin=0, intCouponValue=0, decCardValue=0, decCashValue=0, decFullMinus=4, strInvoiceTitle=food, strInvoiceContent=发票1, ERPID=XD13030412345, datDate=2013-02-01]"; assertEquals(expected, order.toString()); // req:{"action":"Input","data":[{"decValue":"10","ERPID":"WEB100254","erpOrder":"WEB100254","strCardNo":"11111111"}],"key":"4e79cedb8cf4baf5177ea1c3e658a059","password":"shyst","timestamp":1362483119,"type":"OrderCash","username":"user"} // resp:{"result":0,"data":{"arrID":["WEB100254"],"message":"input the records success"}} boolean success = service.order(order); assertTrue(success); } }