package org.xmx0632.deliciousfruit.erp; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; import org.junit.Ignore; import org.junit.Test; import org.xmx0632.deliciousfruit.erp.bo.ErpCard; import org.xmx0632.deliciousfruit.erp.bo.ErpCash; import org.xmx0632.deliciousfruit.erp.bo.ErpCustomer; import org.xmx0632.deliciousfruit.erp.bo.ErpOrder; import org.xmx0632.deliciousfruit.erp.bo.ErpOrderCard; import org.xmx0632.deliciousfruit.erp.bo.ErpProduct; import org.xmx0632.deliciousfruit.erp.bo.ErpPromotion; @Ignore public class ErpApiServiceGetTest extends BaseErpApiServiceTest { @Test public void testGetCustomer() { ErpCustomer customer = service.getCustomerBy("WEB000014"); assertNotNull(customer); // req:{"action":"Read","data":{"id":"WEB000014"},"key":"7088ff3f39a5ccee05f7140b02a19329","password":"shyst","timestamp":1362469151,"type":"Customer","username":"user"} // resp:{"result":0,"data":{"Type":"Customer","pkColumn":"ERPID","Data":[{"ERPID":"WEB000014","strRealName":"","strEmail":"kakakakanana@126.com","datBirthday":null,"intGender":"0","strMobilePhone":"","strPhone":"","intPoint":null,"decCoin":null,"strCustomerName":"kakakakanana","intStatus":null,"datRegisterDate":null,"strPassword":null,"strOldID":null}]}} // {"Type":"Customer","pkColumn":"ERPID","Data":[{"ERPID":"WEB000014","strRealName":"","strEmail":"kakakakanana@126.com","datBirthday":null,"intGender":"0","strMobilePhone":"","strPhone":"","intPoint":null,"decCoin":null,"strCustomerName":"kakakakanana","intStatus":null,"datRegisterDate":null,"strPassword":null,"strOldID":null}]} String expected = "ErpCustomer [strCustomerName=kakakakanana, intStatus=null, ERPID=WEB000014, strRealName=, strEmail=kakakakanana@126.com, datBirthday=null, intGender=0, strMobilePhone=, strPhone=, intPoint=null, decCoin=null]"; assertEquals(expected, customer.toString()); } @Test public void testGetPromotion() { ErpPromotion promotion = service.getPromotionBy("WEB000009"); assertNotNull(promotion); // req:{"action":"Read","data":{"id":"WEB000009"},"key":"8f900eea60d2d0dfc682ba7d8d08dad0","password":"shyst","timestamp":1362469482,"type":"Promotion","username":"user"} // resp:{"result":0,"data":{"Type":"Promotion","pkColumn":"ERPID","Data":[{"ERPID":"WEB000009","strPromotionName":"单品赠送","decFreeValue":0,"decChangeValue":0,"decFullValue":0,"decMinusValue":0,"datStartDate":"1983-01-01 00:00:00","datEndDate":"2033-01-01 00:00:00","intStatus":"1"}]}} // {"Type":"Promotion","pkColumn":"ERPID","Data":[{"ERPID":"WEB000009","strPromotionName":"\u5355\u54c1\u8d60\u9001","decFreeValue":0,"decChangeValue":0,"decFullValue":0,"decMinusValue":0,"datStartDate":"1983-01-01 00:00:00","datEndDate":"2033-01-01 00:00:00","intStatus":"1"}]} String expected = "ErpPromotion [ERPID=WEB000009, strPromotionName=单品赠送, decFreeValue=0, decChangeValue=0, decFullValue=0, decMinusValue=0, datStartDate=1983-01-01 00:00:00, datEndDate=2033-01-01 00:00:00, intStatus=1]"; assertEquals(expected, promotion.toString()); } @Test public void testGetCard() { ErpCard card = service.getCardBy("PD12000018000111"); assertNotNull(card); // req:{"action":"Read","data":{"id":"PD12000018000111"},"key":"d683a5519620bd055c5b4b3ce64de619","password":"shyst","timestamp":1362469413,"type":"Card","username":"user"} // resp:{"result":0,"data":{"Type":"Card","pkColumn":"strCardNo","Data":[{"strCardNo":"PD12000018000111","strPassword":"5f158ede88a67605c4a024d6f4cc9824","decCardValue":0,"decValue":0,"datExpireDate":"2013-07-25 00:00:00","intStatus":"0"}]}} // {"Type":"Card","pkColumn":"strCardNo","Data":[{"strCardNo":"PD12000018000111","strPassword":"5f158ede88a67605c4a024d6f4cc9824","decCardValue":0,"decValue":0,"datExpireDate":"2013-07-25 00:00:00","intStatus":"0"}]} String expected = "ErpCard [strCardNo=PD12000018000111, strPassword=5f158ede88a67605c4a024d6f4cc9824, decCardValue=0, decValue=0, datExpireDate=2013-07-25 00:00:00, intStatus=0]"; assertEquals(expected, card.toString()); } @Test public void testGetCash() { ErpCash cash = service.getCashBy("XJQ201301001"); assertNotNull(cash); // req:{"action":"Read","data":{"id":"XJQ201301001"},"key":"b8f71f781828ef9230e5250194379f87","password":"shyst","timestamp":1362468804,"type":"Cash","username":"user"} // resp:{"result":0,"data":{"Type":"Cash","pkColumn":"strCashNo","Data":[{"strCashNo":"XJQ201301001","decValue":20,"intUseStatus":"1","datExpireDate":"2013-05-18 00:00:00"}]}} // {"Type":"Cash","pkColumn":"strCashNo","Data":[{"strCashNo":"XJQ201301001","decValue":20,"intUseStatus":"1","datExpireDate":"2013-05-18 00:00:00"}]} String expected = "ErpCash [strCashNo=XJQ201301001, decValue=20, intUseStatus=1, datExpireDate=2013-05-18 00:00:00]"; assertEquals(expected, cash.toString()); } @Test public void testGetProduct() { ErpProduct product = service.getProductBy("ZZ000001"); assertNotNull(product); // req:{"action":"Read","data":{"id":"ZZ000001"},"key":"58c8a8629661013b71cd1254234d0497","password":"shyst","timestamp":1362469542,"type":"Product","username":"user"} // resp:{"result":0,"data":{"Type":"Product","pkColumn":"strProductNumber","Data":[{"strProductNumber":"ZZ000001","strOldNumber":null,"strProductName":"力德肯","intStatus":null,"strSpecification":null,"strPlace":null,"strLowOrder":1,"strHighOrder":100000,"strUnit":null,"txtKeywords":null,"strImportCategory":null,"strHomeTimes":null,"strExp":0,"decBargainValue":0,"decValue":0}]}} // {"Type":"Product","pkColumn":"strProductNumber","Data":[{"strProductNumber":"ZZ000001","strOldNumber":null,"strProductName":"力德肯","intStatus":null,"strSpecification":null,"strPlace":null,"strLowOrder":1,"strHighOrder":100000,"strUnit":null,"txtKeywords":null,"strImportCategory":null,"strHomeTimes":null,"strExp":0,"decBargainValue":0,"decValue":0}]} String expected = "ErpProduct [strProductNumber=ZZ000001, strOldNumber=null, strProductName=力德肯, intStatus=null, strSpecification=null, strPlace=null, strLowOrder=1, strHighOrder=100000, strUnit=null, txtKeywords=null, strImportCategory=null, strHomeTimes=null, strExp=0, decBargainValue=0, decValue=0]"; assertEquals(expected, product.toString()); } @Test public void testGetOrder() { ErpOrder product = service.getOrderBy("XD1302260009"); assertNotNull(product); // 销售开单 // req:{"action":"Read","data":{"id":"XD1302260009"},"key":"6e2c38e0fdea71efbe514731a4dac673","password":"shyst","timestamp":1362469559,"type":"Order","username":"user"} // resp:{"result":0,"data":{"Type":"Order","pkColumn":"ERPID","Data":[{"ERPID":"XD1302260009","datDate":"2013-02-26 15:15:33","erpCustomer":"1302260002","strFirstname":"","strPhone":"","strMobilePhone":"","strProvince":"","strCity":"","strAddress":"长宁区金钟路","strArea":"","datWishDate":null,"strWishTime":null,"decValue":336,"decTransportFee":0,"intPoint":0,"decCoin":0,"intCouponValue":0,"decCardValue":286,"decCashValue":0,"decFullMinus":50,"strInvoiceTitle":"","strInvoiceContent":null,"intPointValue":0,"intOrderStatus":"2","intTransportStatus":"1","strTransportType":null}]}} // {"Type":"Order","pkColumn":"ERPID","Data":[{"ERPID":"XD1302260009","datDate":"2013-02-26 15:15:33","erpCustomer":"1302260002","strFirstname":"","strPhone":"","strMobilePhone":"","strProvince":"","strCity":"","strAddress":"长宁区金钟路","strArea":"","datWishDate":null,"strWishTime":null,"decValue":336,"decTransportFee":0,"intPoint":0,"decCoin":0,"intCouponValue":0,"decCardValue":286,"decCashValue":0,"decFullMinus":50,"strInvoiceTitle":"","strInvoiceContent":null,"intPointValue":0,"intOrderStatus":"2","intTransportStatus":"1","strTransportType":null}]} String expected = "ErpOrder [Space= , strCustomerName=null, strTransportType=0, decAdvAmount=null, decBillAmount=null, decNeedPay=null, decTotalFee=null, intPointValue=0, intOrderStatus=2, intTransportStatus=1, erpCustomer=1302260002, strFirstname=, strPhone=, strMobilePhone=, strProvince=, strCity=, strAddress=长宁区金钟路, strArea=, strPaymentType=null, datWishDate=null, strWishTime=null, decValue=336, decTransportFee=0, intPoint=0, decCoin=0, intCouponValue=0, decCardValue=286, decCashValue=0, decFullMinus=50, strInvoiceTitle=, strInvoiceContent=null, ERPID=XD1302260009, datDate=2013-02-26 15:15:33]"; assertEquals(expected, product.toString()); } @Test public void testGetOrderCard() { fail("ERP not implemented"); ErpOrderCard orderCard = service.getOrderCardBy("XD1302260009"); assertNotNull(orderCard); String expected = "ErpOrderCard [Space=null, strCustomerName=null, strTransportType=null, decAdvAmount=null, decBillAmount=null, decNeedPay=null, decTotalFee=null, intPointValue=0, intOrderStatus=2, intTransportStatus=1, erpCustomer=1302260002, strFirstname=, strPhone=, strMobilePhone=, strProvince=, strCity=, strAddress=长宁区金钟路, strArea=, strPaymentType=null, datWishDate=null, strWishTime=null, decValue=336, decTransportFee=0, intPoint=0, decCoin=0, intCouponValue=0, decCardValue=286, decCashValue=0, decFullMinus=50, strInvoiceTitle=, strInvoiceContent=null, ERPID=XD1302260009, datDate=2013-02-26 15:15:33]"; assertEquals(expected, orderCard.toString()); } @Test public void testGetAddress() { fail("ERP not implemented"); } }