From daece5d52c949b9969758252c9a4b6673b880bac Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Fri, 28 Jun 2013 17:38:38 -0500 Subject: [PATCH] IDEMPIERE-206 / Fitnesse fixes: - Sync sample test cases with latest changes - Use configurable port on ZkSuite - Fix context problem on Login and RunProcess - Fix jasper checking on RunProcess (same bug on webservices) - Implement context variable parsing on Util - Change log of post event on core to inform error when a fitnesse posting fails - Improve error on posting material receipt requiring order line --- .../TestCashPosOrder/content.txt | 15 +++--- .../TestCreateReference/content.txt | 4 +- .../TestInitialClientSetup/content.txt | 36 +++++++------ .../TestPostInternalInventory/content.txt | 54 ++++++++++--------- .../FitNesseRoot/RecentChanges/content.txt | 10 ++-- .../ZkSuite/ZkGardenAdminLogin/content.txt | 2 +- .../ZkSuite/ZkSystemAdminLogin/content.txt | 2 +- .../src/org/compiere/acct/Doc_InOut.java | 2 +- .../org/compiere/process/DocumentEngine.java | 7 +++ .../META-INF/MANIFEST.MF | 1 + .../org/idempiere/fitnesse/fixture/Login.java | 5 +- .../fitnesse/fixture/RunProcess.java | 13 ++++- .../org/idempiere/fitnesse/fixture/Util.java | 32 ++++++----- .../org/idempiere/adinterface/Process.java | 10 +++- 14 files changed, 119 insertions(+), 74 deletions(-) diff --git a/fitnesse/FitNesseRoot/IdempiereSuite/TestCashPosOrder/content.txt b/fitnesse/FitNesseRoot/IdempiereSuite/TestCashPosOrder/content.txt index cfc4f468b0..a46f1c1336 100644 --- a/fitnesse/FitNesseRoot/IdempiereSuite/TestCashPosOrder/content.txt +++ b/fitnesse/FitNesseRoot/IdempiereSuite/TestCashPosOrder/content.txt @@ -65,15 +65,15 @@ Check the inventory level after the document |@ExpectedInventoryLevelAfter@|@SQL=SELECT SUM(s.qtyonhand) FROM m_storage s, m_locator l, m_warehouse w WHERE s.m_product_id=133 AND s.m_locator_id = l.m_locator_id AND l.m_warehouse_id=w.m_warehouse_id AND w.m_warehouse_id=103| -Check the bp balance after the document +Check the bp balance after the document (with the new cash payment is applied immediately so there must not be variance on the bp balance) !|Assert Record| |*Table* |C_bpartner | |*Where* |c_bpartner_id=120 | |*Read* | | |actuallifetimevalue|@SQL=SELECT @C_bpartner.actuallifetimevalue@ + @c_order.grandtotal@ FROM DUAL| -|so_creditused |@SQL=SELECT @C_bpartner.so_creditused@ + @c_order.grandtotal@ FROM DUAL | -|totalopenbalance |@SQL=SELECT @C_bpartner.totalopenbalance@ + @c_order.grandtotal@ FROM DUAL | +|so_creditused |@SQL=SELECT @C_bpartner.so_creditused@ FROM DUAL | +|totalopenbalance |@SQL=SELECT @C_bpartner.totalopenbalance@ FROM DUAL | Check existance of shipment @@ -123,17 +123,14 @@ Check existance of invoice |qtyinvoiced | | |linenetamt | | -Check existance of cash journal line +Check existance of cash payment (now on payment table) !|Read Record| -|*Table* |C_CashLine | +|*Table* |C_Payment | |C_Invoice_id|@C_Invoice.C_Invoice_id@| |*Read* | | -|line | | -|c_cash_id | | -|line | | +|documentno | | |description | | |amount | | -|isgenerated | | |processed | | diff --git a/fitnesse/FitNesseRoot/IdempiereSuite/TestCreateReference/content.txt b/fitnesse/FitNesseRoot/IdempiereSuite/TestCreateReference/content.txt index 0de14861a5..1bdaa8b574 100644 --- a/fitnesse/FitNesseRoot/IdempiereSuite/TestCreateReference/content.txt +++ b/fitnesse/FitNesseRoot/IdempiereSuite/TestCreateReference/content.txt @@ -1,4 +1,4 @@ -This test tries to create a reference in the database, intentionally the !-ValidationType-! is left to a wrong value (Y) to make it fail. +This test tries to create a reference in the database, intentionally the !-ValidationType-! is set to a wrong value (Y) to make it fail. !include TestLoginSystem @@ -7,4 +7,4 @@ This test tries to create a reference in the database, intentionally the !-Valid |Name |Fitnesse Test| |ValidationType|Y | |invalidcolumn|Y | -|*Save* | | +|*Save*Error* |java.lang.Exception: Cannot set value of column| diff --git a/fitnesse/FitNesseRoot/IdempiereSuite/TestInitialClientSetup/content.txt b/fitnesse/FitNesseRoot/IdempiereSuite/TestInitialClientSetup/content.txt index 320b83ed9e..381f04285c 100644 --- a/fitnesse/FitNesseRoot/IdempiereSuite/TestInitialClientSetup/content.txt +++ b/fitnesse/FitNesseRoot/IdempiereSuite/TestInitialClientSetup/content.txt @@ -2,19 +2,23 @@ This test creates a new tenant in the database. !include TestLoginSystem -!|Run Process| -|*ProcessValue* |InitialClientSetup | -|ClientName |Prueba | -|OrgName |Prueba | -|AdminUserName |PruebaAdmin | -|NormalUserName |PruebaUser | -|C_Currency_ID |230 | -|C_Country_ID |156 | -|CityName |Bogotá | -|IsUseBPDimension |Y | -|IsUseProductDimension |Y | -|IsUseProjectDimension |Y | -|IsUseCampaignDimension |N | -|IsUseSalesRegionDimension|N | -|CoAFile |/home/carlos/hgAdempiere/adempiere361/data/import/AccountingUS.csv| -|*Run* | | +!|Set Variable | +|@random_string@|@random_string(,,6)| + + +!|Run Process | +|*ProcessValue* |InitialClientSetup | +|ClientName |TestClient @random_string@ | +|OrgName |TestOrg @random_string@ | +|AdminUserName |@random_string@Admin | +|NormalUserName |@random_string@User | +|C_Currency_ID |230 | +|C_Country_ID |156 | +|CityName |Bogotá | +|IsUseBPDimension |Y | +|IsUseProductDimension |Y | +|IsUseProjectDimension |Y | +|IsUseCampaignDimension |N | +|IsUseSalesRegionDimension|N | +|CoAFile |${fitnesse_home}/../org.adempiere.server-feature/data/import/AccountingUS.csv| +|*Run* | | diff --git a/fitnesse/FitNesseRoot/IdempiereSuite/TestPostInternalInventory/content.txt b/fitnesse/FitNesseRoot/IdempiereSuite/TestPostInternalInventory/content.txt index cc9d42f948..e1c24b150c 100644 --- a/fitnesse/FitNesseRoot/IdempiereSuite/TestPostInternalInventory/content.txt +++ b/fitnesse/FitNesseRoot/IdempiereSuite/TestPostInternalInventory/content.txt @@ -4,43 +4,49 @@ https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2713724&group_id=17 !include -c TestLoginGardenAdmin +!|Set Variable | +|@InventoryLevelBefore@ |@SQL=select sum(qtyonhand) from m_storage where m_product_id=141 and m_locator_id=101| +|@ExpectedInventoryLevelAfter@|@SQL=SELECT @InventoryLevelBefore@-2 FROM dual | + Create the internal use document -!|Create Record| -|*Table*|M_Inventory | +!|Create Record | +|*Table* |M_Inventory | |ad_org_id |11 | -|c_doctype_id |144 | +|c_doctype_id |200000 | |m_warehouse_id|103 | -|movementdate |2009-03-26 00:00:00.0| -|*Save*| | +|movementdate |2013-06-26 00:00:00.0| +|*Save* | | Create internal use line -!|Create Record| -|*Table*|M_InventoryLine | -|M_Inventory_ID|@M_Inventory.M_Inventory_ID@ | -|ad_org_id |@M_Inventory.AD_Org_ID@ | -|m_locator_id |101 | -|m_product_id |141 | -|c_charge_id |101 | -|qtyinternaluse|@SQL=select sum(qtyonhand) from m_storage where m_product_id=141 and m_locator_id=101 and m_attributesetinstance_id=0| -|qtybook|@SQL=select sum(qtyonhand) from m_storage where m_product_id=141 and m_locator_id=101 and m_attributesetinstance_id=0| -|*Save*| | +!|Create Record | +|*Table* |M_InventoryLine | +|M_Inventory_ID|@M_Inventory.M_Inventory_ID@| +|ad_org_id |@M_Inventory.AD_Org_ID@ | +|m_locator_id |101 | +|m_product_id |141 | +|c_charge_id |101 | +|qtyinternaluse|2 | +|*Save* | | Complete the internal use -!|Run Process| -|*ProcessValue*|M_Inventory Process | +!|Run Process | +|*ProcessValue*|M_Inventory Process | |*RecordID* |@M_Inventory.M_Inventory_ID@| -|*DocAction* |CO | -|*Run*| | +|*DocAction* |CO | +|*Run* | | + +!|Assert Variable | +|@ExpectedInventoryLevelAfter@|@SQL=select sum(qtyonhand) from m_storage where m_product_id=141 and m_locator_id=101| Post -!|Set DocAction| -|*Table* |M_Inventory| -|M_Inventory_ID|@M_Inventory.M_Inventory_ID@ | -|docAction |PO | -|*Save*| | +!|Set DocAction | +|*Table* |M_Inventory | +|M_Inventory_ID|@M_Inventory.M_Inventory_ID@| +|docAction |PO | +|*Save* | | Check the postings \ No newline at end of file diff --git a/fitnesse/FitNesseRoot/RecentChanges/content.txt b/fitnesse/FitNesseRoot/RecentChanges/content.txt index ea72a69fd5..60b5d36182 100644 --- a/fitnesse/FitNesseRoot/RecentChanges/content.txt +++ b/fitnesse/FitNesseRoot/RecentChanges/content.txt @@ -1,3 +1,9 @@ +|IdempiereSuite.TestInitialClientSetup||17:03:35 vie, jun 28, 2013| +|IdempiereSuite.TestPostInternalInventory||15:31:05 vie, jun 28, 2013| +|IdempiereSuite.TestCreateReference||14:44:52 vie, jun 28, 2013| +|IdempiereSuite.TestCashPosOrder||14:42:20 vie, jun 28, 2013| +|ZkSuite.ZkGardenAdminLogin||13:02:13 vie, jun 28, 2013| +|ZkSuite.ZkSystemAdminLogin||13:00:38 vie, jun 28, 2013| |||12:04:00 jue, dic 20, 2012| |FitLibraryWeb||01:41:13 Thu, Dec 13, 2012| |FitLibrary||01:40:51 Thu, Dec 13, 2012| @@ -9,13 +15,9 @@ |CommonTests.CreateProductPrice||01:29:57 mar, abr 03, 2012| |AvgCostSuite.BasicTest||01:18:34 mar, abr 03, 2012| |CommonTests.CreatePurchaseOrder||01:13:34 mar, abr 03, 2012| -|IdempiereSuite.TestPostInternalInventory||24:21:25 mar, abr 03, 2012| -|IdempiereSuite.TestInitialClientSetup||24:20:45 mar, abr 03, 2012| -|IdempiereSuite.TestCreateReference||24:20:15 mar, abr 03, 2012| |IdempiereSuite.TestLoginSystem||24:20:05 mar, abr 03, 2012| |IdempiereSuite.TestCreateBusinessPartner||24:19:40 mar, abr 03, 2012| |IdempiereSuite.TestCompletePayment||24:19:18 mar, abr 03, 2012| -|IdempiereSuite.TestCashPosOrder||24:18:46 mar, abr 03, 2012| |IdempiereSuite||24:17:17 mar, abr 03, 2012| |IdempiereSuite.TestLoginGardenAdmin||24:17:07 mar, abr 03, 2012| |IdempiereSuite.QuickTest||24:16:36 mar, abr 03, 2012| diff --git a/fitnesse/FitNesseRoot/ZkSuite/ZkGardenAdminLogin/content.txt b/fitnesse/FitNesseRoot/ZkSuite/ZkGardenAdminLogin/content.txt index c546b2b34c..0e1f985afe 100644 --- a/fitnesse/FitNesseRoot/ZkSuite/ZkGardenAdminLogin/content.txt +++ b/fitnesse/FitNesseRoot/ZkSuite/ZkGardenAdminLogin/content.txt @@ -4,7 +4,7 @@ '''start firefox,chrome or phantomjs''' |''start spider with''|firefox| |''shutdown browser automatically''|false| -|''get url''|http://localhost:8080/webui/index.zul| +|''get url''|http://localhost:${ADEMPIERE_WEB_PORT}/webui/index.zul| |''wait response''| diff --git a/fitnesse/FitNesseRoot/ZkSuite/ZkSystemAdminLogin/content.txt b/fitnesse/FitNesseRoot/ZkSuite/ZkSystemAdminLogin/content.txt index df13eeb65e..6b1cf7a3db 100644 --- a/fitnesse/FitNesseRoot/ZkSuite/ZkSystemAdminLogin/content.txt +++ b/fitnesse/FitNesseRoot/ZkSuite/ZkSystemAdminLogin/content.txt @@ -3,7 +3,7 @@ '''start firefox,chrome or phantomjs''' |''start spider with''|firefox| |''shutdown browser automatically''|false| -|''get url''|http://localhost:8080/webui/index.zul| +|''get url''|http://localhost:${ADEMPIERE_WEB_PORT}/webui/index.zul| |''wait response''| diff --git a/org.adempiere.base/src/org/compiere/acct/Doc_InOut.java b/org.adempiere.base/src/org/compiere/acct/Doc_InOut.java index f74460caf1..436a7712c4 100644 --- a/org.adempiere.base/src/org/compiere/acct/Doc_InOut.java +++ b/org.adempiere.base/src/org/compiere/acct/Doc_InOut.java @@ -419,7 +419,7 @@ public class Doc_InOut extends Doc } else { - p_Error = "Resubmit - No Costs for " + product.getName(); + p_Error = "Resubmit - No Costs for " + product.getName() + " (required order line)"; log.log(Level.WARNING, p_Error); return null; } diff --git a/org.adempiere.base/src/org/compiere/process/DocumentEngine.java b/org.adempiere.base/src/org/compiere/process/DocumentEngine.java index c85de31b8c..4a5fe8aeee 100644 --- a/org.adempiere.base/src/org/compiere/process/DocumentEngine.java +++ b/org.adempiere.base/src/org/compiere/process/DocumentEngine.java @@ -48,6 +48,7 @@ import org.compiere.model.PO; import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.Env; +import org.compiere.util.Util; import org.eevolution.model.I_DD_Order; import org.eevolution.model.I_HR_Process; import org.eevolution.model.I_PP_Cost_Collector; @@ -489,6 +490,12 @@ public class DocumentEngine implements DocAction return false; String error = DocumentEngine.postImmediate(Env.getCtx(), m_document.getAD_Client_ID(), m_document.get_Table_ID(), m_document.get_ID(), true, m_document.get_TrxName()); + if (ACTION_Post.equals(m_action)) { + // forced post via process - throw exception to inform the caller about the error + if (! Util.isEmpty(error)) { + throw new AdempiereException(error); + } + } return (error == null); } // postIt diff --git a/org.idempiere.fitnesse.fixture/META-INF/MANIFEST.MF b/org.idempiere.fitnesse.fixture/META-INF/MANIFEST.MF index 371b96d92a..415c557310 100644 --- a/org.idempiere.fitnesse.fixture/META-INF/MANIFEST.MF +++ b/org.idempiere.fitnesse.fixture/META-INF/MANIFEST.MF @@ -52,6 +52,7 @@ Import-Package: fit, fitnesse.wikitext.widgets, fitnesseMain, fitnesseMain.ant, + org.adempiere.util, org.compiere, org.compiere.model, org.compiere.process, diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/Login.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/Login.java index 93a3887aad..86a7bcfb0a 100644 --- a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/Login.java +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/Login.java @@ -26,6 +26,8 @@ package org.idempiere.fitnesse.fixture; +import java.util.Properties; + import org.compiere.model.MSession; import org.compiere.model.MUser; import org.compiere.util.Env; @@ -54,6 +56,7 @@ public class Login extends TableFixture { if (adempiereInstance == null) { adempiereInstance = Static_iDempiereInstance.getInstance(); } + Properties ctx = adempiereInstance.getAdempiereService().getCtx(); boolean isErrorExpected = "*Login*Error*".equalsIgnoreCase(getText(rows-1, 0)); String msgerror = getText(rows-1, 1); for (int i = 0; i < rows; i++) { @@ -116,7 +119,7 @@ public class Login extends TableFixture { else { String msg = modelLogin(); if (msg == null || msg.length() == 0) { - MSession.get (Env.getCtx(), true);// Start Session + MSession.get (ctx, true);// Start Session if (isErrorExpected) { wrong(rows-1, 0); wrong(rows-1, 1); diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/RunProcess.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/RunProcess.java index 53da5cd38d..dc2f9b6e9f 100644 --- a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/RunProcess.java +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/RunProcess.java @@ -33,6 +33,7 @@ import java.util.HashMap; import java.util.Properties; import java.util.logging.Level; +import org.adempiere.util.ProcessUtil; import org.compiere.model.Lookup; import org.compiere.model.MPInstance; import org.compiere.model.MPInstanceLog; @@ -172,7 +173,14 @@ public class RunProcess extends TableFixture { if (recordID >0) pi.setRecord_ID(recordID); boolean processOK = false; - boolean jasperreport = (process != null && process.getClassname()!=null && process.getClassname().indexOf( "net.sf.compilo.report.ReportStarter" ) >=0 ); + boolean jasperreport = + (process != null + && (process.getJasperReport() != null + || (process.getClassname() != null + && process.getClassname().indexOf(ProcessUtil.JASPER_STARTER_CLASS) >= 0 + ) + ) + ); // Start if (process.isWorkflow()) { @@ -191,6 +199,7 @@ public class RunProcess extends TableFixture { if (table != null) { PO po = table.getPO(recordID, null); if (!docAction.equals(po.get_Value("DocStatus"))) { + getCell(i, 1).addToBody("
Expected " + docAction + "
Received " + po.get_Value("DocStatus")); boolean ok = Util.evaluateError(Msg.parseTranslation(ctx, pi.getSummary()), msgerror1, isErrorExpected); if (ok) { right(getCell(i, 1)); @@ -306,7 +315,7 @@ public class RunProcess extends TableFixture { if (pil.getP_Number() != null) getCell(i, 1).addToBody(pil.getP_Number() + " \t"); if (pil.getP_Msg() != null) - getCell(i, 1).addToBody(Msg.parseTranslation(Env.getCtx(), pil.getP_Msg()).replaceAll("\\n", "
")); + getCell(i, 1).addToBody(Msg.parseTranslation(adempiereInstance.getAdempiereService().getCtx(), pil.getP_Msg()).replaceAll("\\n", "
")); } } } diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/Util.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/Util.java index e20edecab2..eb6b46f419 100644 --- a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/Util.java +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/Util.java @@ -125,18 +125,6 @@ public class Util { parse.addToBody("
" + newval); if (log.isLoggable(Level.CONFIG)) log.config("Cell value " + cell_value + " evaluated to " + newval); return newval; - } else if (cell_value.startsWith("@") && cell_value.endsWith("@")) { - int posdot = cell_value.indexOf("."); - if (posdot >= 0) { - cell_value = cell_value.toLowerCase(); - } - String newval = Env.getContext(ctx, windowNo, cell_value.substring(1, cell_value.length()-1)); - if (newval == null) - return cell_value; - if (parse != null) - parse.addToBody("
" + newval); - if (log.isLoggable(Level.CONFIG)) log.config("Cell value " + cell_value + " evaluated to " + newval); - return newval; } else if ((cell_value.toLowerCase().startsWith("@random_number(") || cell_value.toLowerCase().startsWith("@random_string(")) && cell_value.endsWith(")")) { // allow @RANDOM_NUMBER(PREFIX,SUFFIX,LENGTH,DECIMALS)@ in column value @@ -198,6 +186,26 @@ public class Util { parse.addToBody("
" + newval); if (log.isLoggable(Level.CONFIG)) log.config("Cell value " + cell_value + " evaluated to " + newval); return newval; + } else if (cell_value.startsWith("@") && cell_value.endsWith("@")) { + int posdot = cell_value.indexOf("."); + if (posdot >= 0) { + cell_value = cell_value.toLowerCase(); + } + String newval = Env.getContext(ctx, windowNo, cell_value.substring(1, cell_value.length()-1)); + if (newval == null) + return cell_value; + if (parse != null) + parse.addToBody("
" + newval); + if (log.isLoggable(Level.CONFIG)) log.config("Cell value " + cell_value + " evaluated to " + newval); + return newval; + } else if (cell_value.matches(".*@.*@.*")) { + String newval = Env.parseContext(ctx, windowNo, cell_value, false, false); + if (newval == null || newval.length() == 0) + return cell_value; + if (parse != null) + parse.addToBody("
" + newval); + if (log.isLoggable(Level.CONFIG)) log.config("Cell value " + cell_value + " evaluated to " + newval); + return newval; } else if (cell_value.startsWith("\\@")) { cell_value = cell_value.substring(1); } diff --git a/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/Process.java b/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/Process.java index e90ff8659d..619ee054ad 100644 --- a/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/Process.java +++ b/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/Process.java @@ -14,6 +14,7 @@ import javax.xml.namespace.QName; import net.sf.compilo.report.ReportProcessor; import net.sf.jasperreports.engine.JasperPrint; +import org.adempiere.util.ProcessUtil; import org.compiere.model.Lookup; import org.compiere.model.MLookup; import org.compiere.model.MLookupFactory; @@ -288,7 +289,14 @@ public class Process { } boolean processOK = false; - boolean jasperreport = (process != null && process.getClassname()!=null && process.getClassname().indexOf( "net.sf.compilo.report.ReportStarter" ) >=0 ); + boolean jasperreport = + (process != null + && (process.getJasperReport() != null + || (process.getClassname() != null + && process.getClassname().indexOf(ProcessUtil.JASPER_STARTER_CLASS) >= 0 + ) + ) + ); if (jasperreport) {