From c0d9c39f0d7ffe54daa66220c9555cf6e7e9e360 Mon Sep 17 00:00:00 2001 From: Juliana Corredor Date: Mon, 22 Apr 2013 12:11:51 -0500 Subject: [PATCH 1/6] IDEMPIERE-851 fitnesse improvements --- .../oracle/201304181900_IDEMPIERE-851.sql | 14 ++ .../postgresql/201304181900_IDEMPIERE-851.sql | 13 ++ .../fitnesse/fixture/AssertRecord.java | 91 +++++--- .../fitnesse/fixture/CreateRecord.java | 47 +++- .../fitnesse/fixture/DeleteRecord.java | 182 ++++++++++++++++ .../org/idempiere/fitnesse/fixture/Login.java | 34 ++- .../fitnesse/fixture/ReadRecord.java | 51 +++-- .../fitnesse/fixture/RunProcess.java | 91 ++++++-- .../fitnesse/fixture/UpdateRecord.java | 200 ++++++++++++++++++ .../org/idempiere/fitnesse/fixture/Util.java | 26 +++ .../idempiere/fitrecorder/FitRecorder.java | 173 +++++++++++++-- 11 files changed, 832 insertions(+), 90 deletions(-) create mode 100644 migration/i1.0a-release/oracle/201304181900_IDEMPIERE-851.sql create mode 100644 migration/i1.0a-release/postgresql/201304181900_IDEMPIERE-851.sql create mode 100644 org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/DeleteRecord.java create mode 100644 org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/UpdateRecord.java diff --git a/migration/i1.0a-release/oracle/201304181900_IDEMPIERE-851.sql b/migration/i1.0a-release/oracle/201304181900_IDEMPIERE-851.sql new file mode 100644 index 0000000000..cf1bca355f --- /dev/null +++ b/migration/i1.0a-release/oracle/201304181900_IDEMPIERE-851.sql @@ -0,0 +1,14 @@ +-- Apr 18, 2013 6:40:49 PM COT +-- IDEMPIERE-851 fitnesse improvements +UPDATE AD_Column SET IsAllowLogging='N',Updated=TO_DATE('2013-04-18 18:40:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=5903 +; + +-- Apr 18, 2013 6:42:14 PM COT +-- IDEMPIERE-851 fitnesse improvements +UPDATE AD_Column SET IsAllowLogging='N',Updated=TO_DATE('2013-04-18 18:42:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=11353 +; + + +SELECT register_migration_script('2010304181900_IDEMPIERE-851.sql') FROM dual +; + diff --git a/migration/i1.0a-release/postgresql/201304181900_IDEMPIERE-851.sql b/migration/i1.0a-release/postgresql/201304181900_IDEMPIERE-851.sql new file mode 100644 index 0000000000..e7da56f8ca --- /dev/null +++ b/migration/i1.0a-release/postgresql/201304181900_IDEMPIERE-851.sql @@ -0,0 +1,13 @@ +-- Apr 18, 2013 6:40:49 PM COT +-- IDEMPIERE-851 fitnesse improvements +UPDATE AD_Column SET IsAllowLogging='N',Updated=TO_TIMESTAMP('2013-04-18 18:40:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=5903 +; + +-- Apr 18, 2013 6:42:14 PM COT +-- IDEMPIERE-851 fitnesse improvements +UPDATE AD_Column SET IsAllowLogging='N',Updated=TO_TIMESTAMP('2013-04-18 18:42:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=11353 +; + + +SELECT register_migration_script('2010304181900_IDEMPIERE-851.sql') FROM dual +; diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/AssertRecord.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/AssertRecord.java index 4cf37ea271..9c89476c58 100644 --- a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/AssertRecord.java +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/AssertRecord.java @@ -66,7 +66,8 @@ public class AssertRecord extends TableFixture { MTable table = null; POInfo poinfo = null; boolean alreadyread = false; - String whereclause = new String(""); + StringBuilder whereclause = new StringBuilder(""); + boolean error=false; for (int i = 0; i < rows; i++) { String cell_title = getText(i, 0); String cell_value = getText(i, 1); @@ -89,8 +90,10 @@ public class AssertRecord extends TableFixture { exception(getCell(i, 1), new Exception("*Where* must be defined in second row")); return; } - whereclause = cell_value; - } else if (cell_title.equalsIgnoreCase("*Read*")) { + whereclause.append(cell_value); + } else if (cell_title.equalsIgnoreCase("*Read*") || cell_title.equalsIgnoreCase("*Read*Error*") ) + { + error= "*Read*Error*".equalsIgnoreCase(cell_title); if (! tableOK) { getCell(i, 1).addToBody("Table " + tableName + " does not exist"); wrong(i, 1); @@ -110,21 +113,45 @@ public class AssertRecord extends TableFixture { rs = pstmt.executeQuery(); if (rs.next()) { gpo = table.getPO(rs, null); + if(error){ + wrong(i,1); + return; + } + } else { getCell(i, 1).addToBody("No record found: " + sql); - wrong(i, 1); - return; + boolean value=Util.evaluateError("No record found: ",cell_value,error); + if(value){ + right(i,1); + return; + }else{ + wrong(i,1); + return; + } + } if (rs.next()) { getCell(i, 1).addToBody("More than one record found: " + sql); - wrong(i, 1); - return; + boolean value=Util.evaluateError("More than one record found: ",cell_value,error); + if(value){ + right(i,1); + return; + }else{ + wrong(i,1); + return; + } } } catch (SQLException e) - { - exception(getCell(i, 1), e); - return; + { + boolean value=Util.evaluateError(e.getMessage(),cell_value,error); + if(value){ + right(getCell(i, 1)); + return; + }else{ + exception(getCell(i, 1), e); + return; + } } finally { @@ -133,7 +160,9 @@ public class AssertRecord extends TableFixture { pstmt = null; } right(i, 1); - getCell(i, 1).addToBody(gpo.toString()); + if (gpo != null) { + getCell(i, 1).addToBody(gpo.toString()); + } alreadyread = true; } else { // columns @@ -142,30 +171,32 @@ public class AssertRecord extends TableFixture { // not read yet - add value to where clause String value_evaluated = Util.evaluate(ctx, windowNo, cell_value, getCell(i, 1)); if (whereclause.length() > 0) - whereclause = whereclause + " AND "; - whereclause = whereclause + cell_title + "=" + value_evaluated; + whereclause.append(" AND "); + whereclause.append(cell_title).append("=").append(value_evaluated); } else { // already read, compare the value of db with the context variable or formula String title_evaluated = ""; - Object result = gpo.get_Value(cell_title); - if (result != null) { - getCell(i, 0).addToBody("
" + result.toString()); - title_evaluated = result.toString(); - } - - String value_evaluated = cell_value; - if (cell_value.startsWith("@")) { - value_evaluated = Util.evaluate(ctx, windowNo, cell_value, getCell(i, 1)); - } - - if (title_evaluated.equals(value_evaluated)) { - right(i, 1); - } else { - wrong(i, 1); + if (gpo != null) { + Object result = gpo.get_Value(cell_title); + if (result != null) { + getCell(i, 0).addToBody("
" + result.toString()); + title_evaluated = result.toString(); + } + + String value_evaluated = cell_value; + if (cell_value.startsWith("@")) { + value_evaluated = Util.evaluate(ctx, windowNo,cell_value, getCell(i, 1)); + } + + if (title_evaluated.equals(value_evaluated)) { + right(i, 1); + } else { + wrong(i, 1); + } } } } - } + }//end while } // set the variables at the end // read - set context variables @@ -177,5 +208,5 @@ public class AssertRecord extends TableFixture { } } // doStaticTable - + } // AdempiereReadRecord diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/CreateRecord.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/CreateRecord.java index 2f6268d58a..a77e82e0a8 100644 --- a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/CreateRecord.java +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/CreateRecord.java @@ -64,11 +64,13 @@ public class CreateRecord extends TableFixture { String columnName = null; boolean tableOK = false; boolean columnsOK = true; + boolean error="*Save*Error*".equalsIgnoreCase(getText(rows-1, 0)); MTable table = null; POInfo poinfo = null; + for (int i = 0; i < rows; i++) { String cell_title = getText(i, 0); - String cell_value = getText(i, 1); + String cell_value = getText(i, 1); if (cell_title.equalsIgnoreCase("*Table*")) { if (i > 0) { exception(getCell(i, 1), new Exception("*Table* must be defined in first row")); @@ -78,22 +80,31 @@ public class CreateRecord extends TableFixture { // TODO : trx // TODO : verify if the record already exists table = MTable.get(ctx, tableName); - if (table == null || table.get_ID() <= 0) { - wrong(i, 1); + if (table == null || table.get_ID() <= 0) { + boolean value=Util.evaluateError("Table " + tableName + " does not exist", cell_value, error); + if(value) + right(i,1); + else + wrong(i,1); tableOK = false; } else { tableOK = true; gpo = table.getPO(0, null); } poinfo = POInfo.getPOInfo(ctx, table!=null ? table.getAD_Table_ID() : 0); - } else if (cell_title.equalsIgnoreCase("*Save*")) { + } else if (cell_title.equalsIgnoreCase("*Save*") || cell_title.equalsIgnoreCase("*Save*Error*")) { if (i != rows-1) { exception(getCell(i, 1), new Exception("*Save* must be called in last row")); return; } + if (! tableOK) { getCell(i, 1).addToBody("Table " + tableName + " does not exist"); - wrong(i, 1); + boolean value=Util.evaluateError("Table " + tableName + " does not exist", cell_value, error); + if(value) + right(i,1); + else + wrong(i,1); } else { if (columnsOK) { if (!gpo.save()) { @@ -107,9 +118,17 @@ public class CreateRecord extends TableFixture { msg.append("Error: " + vnp.getName()); } getCell(i, 1).addToBody(msg.toString()); - wrong(i, 1); + boolean value=Util.evaluateError(msg.toString(),cell_value,error); + if(value) + right(i,1); + else + wrong(i,1); } else { - right(i, 1); + if(error){ + wrong(i,1); + }else{ + right(i, 1); + } getCell(i, 1).addToBody(gpo.toString()); for (int idx = 0; idx < poinfo.getColumnCount(); idx++) { String colname = poinfo.getColumnName(idx); @@ -126,7 +145,7 @@ public class CreateRecord extends TableFixture { columnName = cell_title; int idxcol = gpo.get_ColumnIndex(columnName); if (idxcol < 0) { - wrong(i, 0); + wrong(i,1); // column does not exist in dictionary - anyways try custom column in case it exists in table gpo.set_CustomColumnReturningBoolean(columnName, cell_value); } else { @@ -175,11 +194,19 @@ public class CreateRecord extends TableFixture { try { if (!gpo.set_ValueOfColumnReturningBoolean(columnName, value)) { columnsOK = false; + boolean value1=Util.evaluateError("Cannot set value of column",cell_value,error); + if(value1) + right(getCell(i, 1)); + else exception(getCell(i, 1), new Exception("Cannot set value of column")); } } catch (Exception e) { - columnsOK = false; - exception(getCell(i, 1), e); + columnsOK = false; + boolean value1=Util.evaluateError("Cannot set value of column",cell_value,error); + if(value1) + right(getCell(i, 1)); + else + exception(getCell(i, 1), e); } } } diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/DeleteRecord.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/DeleteRecord.java new file mode 100644 index 0000000000..734a58376e --- /dev/null +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/DeleteRecord.java @@ -0,0 +1,182 @@ +/********************************************************************** +* This file is part of Adempiere ERP Bazaar * +* http://www.adempiere.org * +* * +* * +* Copyright (C) Contributors * +* * +* This program is free software; you can redistribute it and/or * +* modify it under the terms of the GNU General Public License * +* as published by the Free Software Foundation; either version 2 * +* of the License, or (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * +* MA 02110-1301, USA. * +* * +***********************************************************************/ + +package org.idempiere.fitnesse.fixture; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.Properties; + +import org.compiere.model.MTable; +import org.compiere.model.PO; +import org.compiere.util.DB; +import org.idempiere.fitnesse.fixture.Instance; +import org.idempiere.fitnesse.fixture.Static_iDempiereInstance; +import org.idempiere.fitnesse.fixture.Util; + +import fitnesse.fixtures.TableFixture; + + + +/** + * @author juliana + * + */ +public class DeleteRecord extends TableFixture { + + /* (non-Javadoc) + * @see fitnesse.fixtures.TableFixture#doStaticTable(int) + */ + + private volatile static Instance adempiereInstance = null; + + + @Override + protected void doStaticTable(int rows) { + adempiereInstance = Static_iDempiereInstance.getInstance(); + + if (adempiereInstance.getAdempiereService() == null + || !adempiereInstance.getAdempiereService().isLoggedIn()) { + wrong(rows - 1, 1); + getCell(rows - 1, 1).addToBody("not logged in"); + return; + } + Properties ctx = adempiereInstance.getAdempiereService().getCtx(); + int windowNo = adempiereInstance.getAdempiereService().getWindowNo(); + + PO gpo = null; + String tableName = new String(""); + boolean tableOK = false; + MTable table = null; + + boolean alreadyread = false; + StringBuilder whereclause = new StringBuilder(""); + boolean error = false; + String msgerror=null; + + for (int i = 0; i < rows; i++) { + String cell_title = getText(i, 0); + String cell_value = getText(i, 1); + if (cell_title.equalsIgnoreCase("*Table*")) { + if (i > 0) { + exception(getCell(i, 1), new Exception("*Table* must be defined in first row")); + return; + } + tableName = cell_value; + table = MTable.get(ctx, tableName); + if (table == null || table.get_ID() <= 0) { + wrong(i, 1); + tableOK = false; + } else { + tableOK = true; + } + + } else if (cell_title.equalsIgnoreCase("*Where*")) { + if (i != 1) { + exception(getCell(i, 1), new Exception("*Where* must be defined in second row")); + return; + } + whereclause.append(cell_value); + } else if (cell_title.equalsIgnoreCase("*Delete*") || cell_title.equalsIgnoreCase("*Delete*Error*")) { + error = "*Delete*Error*".equalsIgnoreCase(cell_title); + msgerror=cell_value; + if (!tableOK) { + getCell(i, 1).addToBody("Table " + tableName + " does not exist"); + wrong(i, 1); + return; + } + if (whereclause.length() == 0) { + getCell(i, 1).addToBody("No where clause"); + wrong(i, 1); + return; + } + String sql = "SELECT * FROM " + tableName + " WHERE "+ whereclause; + PreparedStatement pstmt = null; + ResultSet rs = null; + try { + pstmt = DB.prepareStatement(sql, null); + rs = pstmt.executeQuery(); + if (rs.next()) { + gpo = table.getPO(rs, null); + } else { + getCell(i, 1).addToBody("No record found: " + sql); + boolean value = Util.evaluateError("No record found: ",cell_value, error); + if (value) { + right(i, 1); + return; + } else { + wrong(i, 1); + return; + } + + } + if (rs.next()) { + getCell(i, 1).addToBody("More than one record found: " + sql); + boolean value = Util.evaluateError("More than one record found: ", cell_value,error); + if (value) { + right(i, 1); + return; + } else { + wrong(i, 1); + return; + } + } + + if (gpo != null) { + gpo.deleteEx(true); + } + + } catch (Exception e) { + boolean value = Util.evaluateError(e.getMessage(),msgerror, error); + if (value) { + right(getCell(i, 1)); + return; + } else { + exception(getCell(i, 1), e); + return; + } + } finally { + DB.close(rs, pstmt); + rs = null; + pstmt = null; + } + right(i, 1); + alreadyread = true; + } else { + // columns + if (tableOK) { + String value_evaluated = Util.evaluate(ctx, windowNo,cell_value, getCell(i, 1)); + if (!alreadyread) { + // not read yet - add value to where clause + if (whereclause.length() > 0) + whereclause.append(" AND "); + whereclause.append(cell_title).append("=").append(value_evaluated); + } + } + } + }//end while + + } + +} 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 b99424a0ca..42e58caae1 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 @@ -54,6 +54,8 @@ public class Login extends TableFixture { if (adempiereInstance == null) { adempiereInstance = Static_iDempiereInstance.getInstance(); } + boolean error="*Login*Error*".equalsIgnoreCase(getText(rows-1, 0)); + String msgerror=getText(rows-1, 1); for (int i = 0; i < rows; i++) { String cell_title = getText(i, 0); String cell_value = getText(i, 1); @@ -92,7 +94,7 @@ public class Login extends TableFixture { exception(getCell(i, 1), e); continue; } - } else if (cell_title.equalsIgnoreCase("*Login*")) { + } else if (cell_title.equalsIgnoreCase("*Login*") || cell_title.equalsIgnoreCase("*Login*Error*")) { if (i != rows-1) { exception(getCell(i, 1), new Exception("*Login* must be called in last row")); return; @@ -104,17 +106,35 @@ public class Login extends TableFixture { || m_password == null || m_password.length() == 0 || m_role_id < 0 || m_client_id < 0) { - exception(getCell(rows-1, 1), new Exception("Incomplete data to login, needed User|Password|AD_Role_ID|AD_Client_ID")); + + boolean value=Util.evaluateError("Incomplete data to login, needed User|Password|AD_Role_ID|AD_Client_ID", msgerror, error); + if(value) + right(i,1); + else + exception(getCell(rows-1, 1), new Exception("Incomplete data to login, needed User|Password|AD_Role_ID|AD_Client_ID")); } else { String msg = modelLogin(); if (msg == null || msg.length() == 0) { - MSession.get (Env.getCtx(), true); // Start Session - right(rows-1, 0); - right(rows-1, 1); + MSession.get (Env.getCtx(), true);// Start Session + if(error){ + wrong(rows-1, 0); + wrong(rows-1, 1); + }else{ + right(rows-1, 0); + right(rows-1, 1); + } } else { - wrong(rows-1, 0); - exception(getCell(rows-1, 1), new Exception(msg)); + + boolean value=Util.evaluateError(msg, msgerror, error); + if(value){ + right(rows-1, 0); + } + else{ + wrong(rows-1, 0); + exception(getCell(rows-1, 1), new Exception(msg)); + } + } } diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/ReadRecord.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/ReadRecord.java index 7f5dd615ce..9f6cb3d36a 100644 --- a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/ReadRecord.java +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/ReadRecord.java @@ -67,6 +67,7 @@ public class ReadRecord extends TableFixture { POInfo poinfo = null; boolean alreadyread = false; String whereclause = new String(""); + boolean error=false; for (int i = 0; i < rows; i++) { String cell_title = getText(i, 0); String cell_value = getText(i, 1); @@ -88,14 +89,15 @@ public class ReadRecord extends TableFixture { if (i != 1) { exception(getCell(i, 1), new Exception("*Where* must be defined in second row")); return; - } + } whereclause = cell_value; - } else if (cell_title.equalsIgnoreCase("*Read*")) { + } else if (cell_title.equalsIgnoreCase("*Read*") || cell_title.equalsIgnoreCase("*Read*Error*")) { if (! tableOK) { getCell(i, 1).addToBody("Table " + tableName + " does not exist"); wrong(i, 1); return; } + error="*Read*Error*".equalsIgnoreCase(cell_title); if (whereclause.length() == 0) { getCell(i, 1).addToBody("No where clause"); wrong(i, 1); @@ -110,21 +112,42 @@ public class ReadRecord extends TableFixture { rs = pstmt.executeQuery(); if (rs.next()) { gpo = table.getPO(rs, null); + if(error){ + wrong(i,1); + } } else { getCell(i, 1).addToBody("No record found: " + sql); - wrong(i, 1); - return; + boolean value=Util.evaluateError("No record found: ",cell_value,error); + if(value){ + right(i,1); + return; + }else{ + wrong(i,1); + return; + } } if (rs.next()) { getCell(i, 1).addToBody("More than one record found: " + sql); - wrong(i, 1); - return; + boolean value=Util.evaluateError("More than one record found: ",cell_value,error); + if(value){ + right(i,1); + return; + }else{ + wrong(i,1); + return; + } } } catch (SQLException e) { - exception(getCell(i, 1), e); - return; + boolean value=Util.evaluateError(e.getMessage(),cell_value,error); + if(value){ + right(getCell(i, 1)); + return; + }else{ + exception(getCell(i, 1), e); + return; + } } finally { @@ -133,7 +156,9 @@ public class ReadRecord extends TableFixture { pstmt = null; } right(i, 1); - getCell(i, 1).addToBody(gpo.toString()); + if (gpo != null) { + getCell(i, 1).addToBody(gpo.toString()); + } // read - set context variables for (int idx = 0; idx < poinfo.getColumnCount(); idx++) { String colname = poinfo.getColumnName(idx); @@ -153,9 +178,11 @@ public class ReadRecord extends TableFixture { whereclause = whereclause + cell_title + "=" + value_evaluated; } else { // already read, show the value of context variable - Object result = gpo.get_Value(cell_title); - if (result != null) - getCell(i, 1).addToBody(result.toString()); + if (gpo != null) { + Object result = gpo.get_Value(cell_title); + if (result != null) + getCell(i, 1).addToBody(result.toString()); + } } } } 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 da2b2567fd..7fe5239453 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 @@ -83,6 +83,8 @@ public class RunProcess extends TableFixture { HashMap fmap = new HashMap(); int recordID = 0; String docAction = null; + boolean error="*Run*Error*".equalsIgnoreCase(getText(rows-1, 0)); + String msgerror1=getText(rows-1, 1); for (int i = 0; i < rows; i++) { String cell_title = getText(i, 0); String cell_value = getText(i, 1); @@ -93,9 +95,14 @@ public class RunProcess extends TableFixture { } String processValue = cell_value; int processID = MProcess.getProcess_ID(processValue, null); - if (processID <= 0) { - exception(getCell(i, 1), new Exception("Process with Value=" + processValue + " doesn't exist")); - return; + if (processID <= 0 ) { + boolean value=Util.evaluateError(msgerror1,"Process with Value=" + processValue + " doesn't exist", error); + if(value){ + right(getCell(i, 1)); + }else{ + exception(getCell(i, 1), new Exception("Process with Value=" + processValue + " doesn't exist")); + return; + } } process = new MProcess(ctx, processID, null); } else if (cell_title.equalsIgnoreCase("*ProcessID*")) { @@ -106,10 +113,15 @@ public class RunProcess extends TableFixture { int processID = getInt(i, 1); process = new MProcess(ctx, processID, null); if (process == null || process.get_ID() <= 0) { - exception(getCell(i, 1), new Exception("Process with ID=" + processID + " doesn't exist")); - return; + boolean value=Util.evaluateError(msgerror1,"Process with ID=" + processID + " doesn't exist", error); + if(value){ + right(getCell(i, 1)); + }else{ + exception(getCell(i, 1), new Exception("Process with ID=" + processID + " doesn't exist")); + return; + } } - } else if (cell_title.equalsIgnoreCase("*Run*")) { + } else if (cell_title.equalsIgnoreCase("*Run*") || cell_title.equalsIgnoreCase("*Run*Error*") ) { if (i != rows-1) { exception(getCell(i, 1), new Exception("*Run* must be called in last row")); return; @@ -118,8 +130,14 @@ public class RunProcess extends TableFixture { pInstance = new MPInstance (process, 0); MPInstancePara[] iParams = pInstance.getParameters(); String errorMsg = setParams(process, iParams, fmap); - if (errorMsg != null) - exception(getCell(i, 1), new Exception(errorMsg)); + if (errorMsg != null){ + boolean value=Util.evaluateError(msgerror1,errorMsg, error); + if(value){ + + }else{ + exception(getCell(i, 1), new Exception(errorMsg)); + } + } if (recordID > 0) pInstance.setRecord_ID( recordID); pInstance.saveEx(); @@ -141,6 +159,7 @@ public class RunProcess extends TableFixture { po.set_ValueOfColumn("DocAction", docAction); po.saveEx(); } + } } } @@ -157,6 +176,7 @@ public class RunProcess extends TableFixture { // Start if (process.isWorkflow()) { + boolean value=Util.evaluateError(msgerror1,pi.getSummary(), error); try { int AD_Workflow_ID = process.getAD_Workflow_ID(); @@ -166,12 +186,43 @@ public class RunProcess extends TableFixture { { getCell(i, 1).addToBody(Msg.parseTranslation(ctx, pi.getSummary())); addLogInfo(pInstance, i); - right(getCell(i, 1)); + + if (wf.getWorkflowType().equals(MWorkflow.WORKFLOWTYPE_DocumentProcess)) { + MTable table = MTable.get(ctx, wf.getAD_Table_ID()); + if (table != null) { + PO po = table.getPO(recordID, null); + if(!docAction.equals(po.get_Value("DocStatus"))){ + if(value){ + right(getCell(i, 1)); + }else{ + wrong(getCell(i, 1)); + } + } + else { + if (value) { + right(getCell(i, 1)); + } else { + wrong(getCell(i, 1)); + } + } + } + } + else{ + if(value){ + right(getCell(i, 1)); + }else{ + wrong(getCell(i, 1)); + } + } } } catch(Exception ex) { - exception(getCell(i, 1), ex); + if(value){ + right(getCell(i, 1)); + }else{ + exception(getCell(i, 1), ex); + } } //started = wfProcess != null; } @@ -192,14 +243,24 @@ public class RunProcess extends TableFixture { } if (!processOK || pi.isError()) { - exception(getCell(i, 1), new Exception(pi.getSummary())); - processOK = false; + boolean value=Util.evaluateError(msgerror1,pi.getSummary(), error); + if(value){ + right(getCell(i, 1)); + processOK = true; + }else{ + exception(getCell(i, 1), new Exception(pi.getSummary())); + processOK = false; + } } else { - getCell(i, 1).addToBody(Msg.parseTranslation(ctx, pi.getSummary())); - addLogInfo(pInstance, i); - right(getCell(i, 1)); + if(error){ + wrong(getCell(i, 1)); + }else{ + getCell(i, 1).addToBody(Msg.parseTranslation(ctx, pi.getSummary())); + addLogInfo(pInstance, i); + right(getCell(i, 1)); + } } } diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/UpdateRecord.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/UpdateRecord.java new file mode 100644 index 0000000000..b3a492d847 --- /dev/null +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/UpdateRecord.java @@ -0,0 +1,200 @@ +/********************************************************************** +* This file is part of Adempiere ERP Bazaar * +* http://www.adempiere.org * +* * +* * +* Copyright (C) Contributors * +* * +* This program is free software; you can redistribute it and/or * +* modify it under the terms of the GNU General Public License * +* as published by the Free Software Foundation; either version 2 * +* of the License, or (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * +* MA 02110-1301, USA. * +* * +***********************************************************************/ + +package org.idempiere.fitnesse.fixture; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Properties; + +import org.compiere.model.MTable; +import org.compiere.model.PO; +import org.compiere.util.DB; + +import fitnesse.fixtures.TableFixture; + +/** + * + * iDempiere Update Record fixture for use with fitnesse framework testing + * @author juliana + * + */ +public class UpdateRecord extends TableFixture { + + /* (non-Javadoc) + * @see fitnesse.fixtures.TableFixture#doStaticTable(int) + */ + + private volatile static Instance adempiereInstance = null; + + @Override + protected void doStaticTable(int rows) { + + if (adempiereInstance == null) { + adempiereInstance = Static_iDempiereInstance.getInstance(); + } + if (adempiereInstance.getAdempiereService() == null + || !adempiereInstance.getAdempiereService().isLoggedIn()) { + wrong(rows - 1, 1); + getCell(rows - 1, 1).addToBody("not logged in"); + return; + } + Properties ctx = adempiereInstance.getAdempiereService().getCtx(); + int windowNo = adempiereInstance.getAdempiereService().getWindowNo(); + + PO gpo = null; + String tableName = new String(""); + boolean tableOK = false; + MTable table = null; + + boolean alreadyread = false; + StringBuilder whereclause = new StringBuilder(""); + boolean error = false; + String msgerror=null; + for (int i = 0; i < rows; i++) { + String cell_title = getText(i, 0); + String cell_value = getText(i, 1); + if (cell_title.equalsIgnoreCase("*Table*")) { + if (i > 0) { + exception(getCell(i, 1), new Exception("*Table* must be defined in first row")); + return; + } + tableName = cell_value; + table = MTable.get(ctx, tableName); + if (table == null || table.get_ID() <= 0) { + wrong(i, 1); + tableOK = false; + } else { + tableOK = true; + } + + } else if (cell_title.equalsIgnoreCase("*Where*")) { + if (i != 1) { + exception(getCell(i, 1), new Exception("*Where* must be defined in second row")); + return; + } + whereclause.append(cell_value); + } else if (cell_title.equalsIgnoreCase("*Update*") || cell_title.equalsIgnoreCase("*Update*Error*")) { + error = "*Update*Error*".equalsIgnoreCase(cell_title); + msgerror=cell_value; + if (!tableOK) { + getCell(i, 1).addToBody("Table " + tableName + " does not exist"); + wrong(i, 1); + return; + } + if (whereclause.length() == 0) { + getCell(i, 1).addToBody("No where clause"); + wrong(i, 1); + return; + } + String sql = "SELECT * FROM " + tableName + " WHERE "+ whereclause; + PreparedStatement pstmt = null; + ResultSet rs = null; + try { + pstmt = DB.prepareStatement(sql, null); + rs = pstmt.executeQuery(); + if (rs.next()) { + gpo = table.getPO(rs, null); + } else { + getCell(i, 1).addToBody("No record found: " + sql); + boolean value = Util.evaluateError("No record found: ",cell_value, error); + if (value) { + right(i, 1); + return; + } else { + wrong(i, 1); + return; + } + + } + if (rs.next()) { + getCell(i, 1).addToBody("More than one record found: " + sql); + boolean value = Util.evaluateError("More than one record found: ", cell_value,error); + if (value) { + right(i, 1); + return; + } else { + wrong(i, 1); + return; + } + } + } catch (SQLException e) { + boolean value = Util.evaluateError(e.getMessage(),cell_value, error); + if (value) { + right(getCell(i, 1)); + return; + } else { + exception(getCell(i, 1), e); + return; + } + } finally { + DB.close(rs, pstmt); + rs = null; + pstmt = null; + } + right(i, 1); + if (gpo != null) { + getCell(i, 1).addToBody(gpo.toString()); + } + alreadyread = true; + } else { + // columns + if (tableOK) { + String value_evaluated = Util.evaluate(ctx, windowNo,cell_value, getCell(i, 1)); + if (!alreadyread) { + // not read yet - add value to where clause + if (whereclause.length() > 0) + whereclause.append(" AND "); + whereclause.append(cell_title).append("=").append(value_evaluated); + } else { + if(gpo != null){ + if(gpo.set_ValueOfColumnReturningBoolean(cell_title, cell_value)){ + if(error){ + wrong(getCell(i, 1)); + }else{ + right(getCell(i, 1)); + + } + } + + try { + gpo.saveEx(); + } catch (Exception e) { + boolean value = Util.evaluateError(e.getMessage(),msgerror, error); + if (value) + right(getCell(i, 1)); + else + exception(getCell(i, 1),e); + } + + } + } + } + } + }//end while + + } + +} 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 c3712c5d76..f92082b156 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 @@ -250,4 +250,30 @@ public class Util { return evaluate(ctx, windowNo, expr, null); } + + public static boolean evaluateError(String error, String cell,boolean isError) { + boolean evaluate = false; + + if(error == null) + error=""; + if (cell == null) + cell=""; + + if (isError) { + if (cell.length() > 0) { + if (error.contains(cell)) { + evaluate = true; + } else { + evaluate = false; + } + + } else { + evaluate = true; + } + } else { + evaluate = false; + } + return evaluate; + } + } // AdempiereUtil diff --git a/org.idempiere.fitrecorder/src/org/idempiere/fitrecorder/FitRecorder.java b/org.idempiere.fitrecorder/src/org/idempiere/fitrecorder/FitRecorder.java index 1de13aa38a..04d8564227 100644 --- a/org.idempiere.fitrecorder/src/org/idempiere/fitrecorder/FitRecorder.java +++ b/org.idempiere.fitrecorder/src/org/idempiere/fitrecorder/FitRecorder.java @@ -183,7 +183,7 @@ public class FitRecorder implements ModelValidator { // Ignore records created within a workflow process if (po.get_TrxName().startsWith("WFP_")) return null; - + writeFile("\n"); writeFile("\n"); writeFile("CREATE RECORD"); @@ -205,8 +205,7 @@ public class FitRecorder implements ModelValidator { || colName.equals("AD_Client_ID") || colName.equals(table.getTableName() + "_ID") || colName.equals(PO.getUUIDColumnName(table.getTableName())) - || column.getAD_Reference_ID() == DisplayType.Button - ) + || column.getAD_Reference_ID() == DisplayType.Button) continue; if (po.isActive() && colName.equals("IsActive")) continue; @@ -228,10 +227,11 @@ public class FitRecorder implements ModelValidator { writeFile("\n"); } - - if (po instanceof MPInstance) { - if (type == TYPE_AFTER_CHANGE) { - + + if(type == TYPE_AFTER_CHANGE) + { + if (po instanceof MPInstance) + { MProcess pro = MProcess.get(Env.getCtx(), po.get_ValueAsInt("AD_Process_ID")); MPInstance pint = (MPInstance)po; writeFile("\n"); @@ -294,18 +294,160 @@ public class FitRecorder implements ModelValidator { writeFile("|*Run*|"); writeFile("\n"); - } - } - - if (po instanceof MSession) { - if (type == TYPE_AFTER_CHANGE) { + }else if(po instanceof MSession) + { MSession session = (MSession) po; if (session.isProcessed()) { closefile(); } + } else { + + if (dontLogTables.contains(po.get_TableName().toUpperCase())) + return null; + + // Ignore records created within a process + if (po.get_TrxName().startsWith("SvrProcess_")) + return null; + + // Ignore records created within a workflow process + if (po.get_TrxName().startsWith("WFP_")) + return null; + + MTable table = MTable.get(Env.getCtx(), po.get_Table_ID()); + + MColumn[] columns = table.getColumns(true); + StringBuilder where = new StringBuilder(); + StringBuilder set = new StringBuilder(); + boolean key=false; + for (int i = 0; i < columns.length; i++) + { + MColumn column = columns[i]; + String colName = column.getColumnName(); + String value=null; + if (DisplayType.isLookup(column.getAD_Reference_ID()) && DisplayType.List != column.getAD_Reference_ID()) { + value = resolveValue(po, table, column); + }else{ + value=po.get_ValueAsString(colName); + } + if (column.isAllowLogging()) + { + if (column.isKey()) + { + if (!key) { + where.append("| *Where* | "); + where.append(colName + " = " + value+ " | "); + key=true; + } else { + where.append(" | " + colName + " | "); + where.append(value + " | "); + } + } + if (po.is_ValueChanged(colName)) { + if (colName.equals("Created") + || colName.equals("CreatedBy") + || colName.equals("Updated") + || colName.equals("UpdatedBy") + || colName.equals("AD_Client_ID") + || colName.equals(table.getTableName()+ "_ID") + || colName.equals(PO.getUUIDColumnName(table.getTableName())) + || column.getAD_Reference_ID() == DisplayType.Button) + continue; + + if (po.isActive() && colName.equals("IsActive")) + continue; + + if (value != null && value.length() > 0) { + set.append("\n"); + set.append("| " + colName + " | "); + set.append(value + "|"); + } + + } + } + + }// end while columns + + if (where.length() > 0 && set.length() > 0) { + writeFile("\n"); + writeFile("\n"); + writeFile("UPDATE RECORD"); + writeFile("\n"); + writeFile("!"); + writeFile("| Update Record |"); + writeFile("\n"); + writeFile("| *Table* | "); + writeFile(po.get_TableName() + " |"); + writeFile("\n"); + writeFile(where.toString()); + writeFile("\n"); + writeFile("| *Update* |"); + writeFile(set.toString()); + } } + } + + if(type == TYPE_AFTER_DELETE) + { + if (dontLogTables.contains(po.get_TableName().toUpperCase())) + return null; + + // Ignore records created within a process + if (po.get_TrxName().startsWith("SvrProcess_")) + return null; + + // Ignore records created within a workflow process + if (po.get_TrxName().startsWith("WFP_")) + return null; + + writeFile("\n"); + writeFile("\n"); + writeFile("DELETE RECORD"); + writeFile("\n"); + writeFile("!"); + writeFile("| Delete Record |"); + writeFile("\n"); + writeFile("| *Table* | "); + writeFile(po.get_TableName() + " |"); + writeFile("\n"); + + MTable table = MTable.get(Env.getCtx(), po.get_Table_ID()); + MColumn[] columns = table.getColumns(true); + boolean key=false; + + for (int i = 0; i < columns.length; i++) + { + MColumn column = columns[i]; + String colName = column.getColumnName(); + String value=null; + if (DisplayType.isLookup(column.getAD_Reference_ID()) && DisplayType.List != column.getAD_Reference_ID()) { + value = resolveValue(po, table, column); + }else{ + value=po.get_ValueAsString(colName); + } + + if (column.isAllowLogging()) + { + if (column.isKey()) + { + if (!key) { + writeFile("| *Where* | "); + writeFile(colName + " = " + value+ " | "); + key=true; + } else { + writeFile(" | " + colName + " | "); + writeFile(value + " | "); + } + } + } + }//while columns + + writeFile("\n"); + writeFile("| *Delete* |"); + } + } catch (Exception e) { + if (log.isLoggable(Level.INFO)) log.info(e.getLocalizedMessage()); return e.getLocalizedMessage(); } return null; @@ -375,7 +517,7 @@ public class FitRecorder implements ModelValidator { } else { value = po.get_ValueAsString(column.getColumnName()); } - + return value; } @@ -401,7 +543,7 @@ public class FitRecorder implements ModelValidator { if (action.equals("CO")) { // run process String processValue = DB.getSQLValueString(po.get_TrxName(), - "SELECT p.Value FROM AD_Process p JOIN AD_Workflow w ON (p.AD_Workflow_ID=w.AD_Workflow_ID) WHERE w.AD_Table_ID=?", po.get_Table_ID()); + "SELECT p.Value FROM AD_Process p JOIN AD_Workflow w ON (p.AD_Workflow_ID=w.AD_Workflow_ID) WHERE w.AD_Table_ID=?", po.get_Table_ID()); writeFile("RUN PROCESS"); writeFile("\n"); writeFile("!"); @@ -498,8 +640,7 @@ public class FitRecorder implements ModelValidator { writeFile("|Login|"); writeFile("\n"); writeFile("|User|"); - if (MSysConfig.getBooleanValue(MSysConfig.USE_EMAIL_FOR_LOGIN, - false)) + if (MSysConfig.getBooleanValue(MSysConfig.USE_EMAIL_FOR_LOGIN,false)) writeFile(user.getEMail() + "|"); else if (user.getLDAPUser() != null) writeFile(user.getLDAPUser() + "|"); From 4a33f4434ebebbeb5882003491e315684663d021 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 22 Apr 2013 14:51:29 -0500 Subject: [PATCH 2/6] IDEMPIERE-851 fitnesse improvements / Peer Review --- .../fitnesse/fixture/AssertRecord.java | 46 ++++---- .../fitnesse/fixture/CreateRecord.java | 38 +++--- .../fitnesse/fixture/DeleteRecord.java | 48 +++----- .../org/idempiere/fitnesse/fixture/Login.java | 25 ++-- .../fitnesse/fixture/ReadRecord.java | 41 +++---- .../fitnesse/fixture/RunProcess.java | 109 +++++++++--------- .../fitnesse/fixture/UpdateRecord.java | 50 ++++---- .../org/idempiere/fitnesse/fixture/Util.java | 18 +-- .../idempiere/fitrecorder/FitRecorder.java | 25 ++-- 9 files changed, 186 insertions(+), 214 deletions(-) diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/AssertRecord.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/AssertRecord.java index 9c89476c58..56c7ed33b2 100644 --- a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/AssertRecord.java +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/AssertRecord.java @@ -67,7 +67,7 @@ public class AssertRecord extends TableFixture { POInfo poinfo = null; boolean alreadyread = false; StringBuilder whereclause = new StringBuilder(""); - boolean error=false; + boolean isErrorExpected = false; for (int i = 0; i < rows; i++) { String cell_title = getText(i, 0); String cell_value = getText(i, 1); @@ -93,7 +93,7 @@ public class AssertRecord extends TableFixture { whereclause.append(cell_value); } else if (cell_title.equalsIgnoreCase("*Read*") || cell_title.equalsIgnoreCase("*Read*Error*") ) { - error= "*Read*Error*".equalsIgnoreCase(cell_title); + isErrorExpected = "*Read*Error*".equalsIgnoreCase(cell_title); if (! tableOK) { getCell(i, 1).addToBody("Table " + tableName + " does not exist"); wrong(i, 1); @@ -113,45 +113,41 @@ public class AssertRecord extends TableFixture { rs = pstmt.executeQuery(); if (rs.next()) { gpo = table.getPO(rs, null); - if(error){ + if (isErrorExpected) { wrong(i,1); return; } - + } else { getCell(i, 1).addToBody("No record found: " + sql); - boolean value=Util.evaluateError("No record found: ",cell_value,error); - if(value){ + boolean ok = Util.evaluateError("No record found: ", cell_value, isErrorExpected); + if (ok) { right(i,1); - return; - }else{ + } else { wrong(i,1); - return; } - + return; } if (rs.next()) { getCell(i, 1).addToBody("More than one record found: " + sql); - boolean value=Util.evaluateError("More than one record found: ",cell_value,error); - if(value){ + boolean ok = Util.evaluateError("More than one record found: ", cell_value, isErrorExpected); + if (ok) { right(i,1); - return; - }else{ + } else { wrong(i,1); - return; - } + } + return; } } catch (SQLException e) - { - boolean value=Util.evaluateError(e.getMessage(),cell_value,error); - if(value){ + { + boolean ok = Util.evaluateError(e.getMessage(), cell_value, isErrorExpected); + if (ok) { right(getCell(i, 1)); - return; - }else{ + } else { exception(getCell(i, 1), e); - return; - } + } + return; } finally { @@ -162,7 +158,7 @@ public class AssertRecord extends TableFixture { right(i, 1); if (gpo != null) { getCell(i, 1).addToBody(gpo.toString()); - } + } alreadyread = true; } else { // columns @@ -196,7 +192,7 @@ public class AssertRecord extends TableFixture { } } } - }//end while + } } // set the variables at the end // read - set context variables diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/CreateRecord.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/CreateRecord.java index a77e82e0a8..f1a34b5201 100644 --- a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/CreateRecord.java +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/CreateRecord.java @@ -64,13 +64,13 @@ public class CreateRecord extends TableFixture { String columnName = null; boolean tableOK = false; boolean columnsOK = true; - boolean error="*Save*Error*".equalsIgnoreCase(getText(rows-1, 0)); + boolean isErrorExpected = "*Save*Error*".equalsIgnoreCase(getText(rows-1, 0)); MTable table = null; POInfo poinfo = null; - + for (int i = 0; i < rows; i++) { String cell_title = getText(i, 0); - String cell_value = getText(i, 1); + String cell_value = getText(i, 1); if (cell_title.equalsIgnoreCase("*Table*")) { if (i > 0) { exception(getCell(i, 1), new Exception("*Table* must be defined in first row")); @@ -80,9 +80,9 @@ public class CreateRecord extends TableFixture { // TODO : trx // TODO : verify if the record already exists table = MTable.get(ctx, tableName); - if (table == null || table.get_ID() <= 0) { - boolean value=Util.evaluateError("Table " + tableName + " does not exist", cell_value, error); - if(value) + if (table == null || table.get_ID() <= 0) { + boolean ok = Util.evaluateError("Table " + tableName + " does not exist", cell_value, isErrorExpected); + if (ok) right(i,1); else wrong(i,1); @@ -100,8 +100,8 @@ public class CreateRecord extends TableFixture { if (! tableOK) { getCell(i, 1).addToBody("Table " + tableName + " does not exist"); - boolean value=Util.evaluateError("Table " + tableName + " does not exist", cell_value, error); - if(value) + boolean ok = Util.evaluateError("Table " + tableName + " does not exist", cell_value, isErrorExpected); + if (ok) right(i,1); else wrong(i,1); @@ -118,16 +118,16 @@ public class CreateRecord extends TableFixture { msg.append("Error: " + vnp.getName()); } getCell(i, 1).addToBody(msg.toString()); - boolean value=Util.evaluateError(msg.toString(),cell_value,error); - if(value) + boolean ok = Util.evaluateError(msg.toString(),cell_value,isErrorExpected); + if (ok) right(i,1); else wrong(i,1); } else { - if(error){ + if (isErrorExpected) { wrong(i,1); - }else{ - right(i, 1); + } else { + right(i, 1); } getCell(i, 1).addToBody(gpo.toString()); for (int idx = 0; idx < poinfo.getColumnCount(); idx++) { @@ -194,16 +194,16 @@ public class CreateRecord extends TableFixture { try { if (!gpo.set_ValueOfColumnReturningBoolean(columnName, value)) { columnsOK = false; - boolean value1=Util.evaluateError("Cannot set value of column",cell_value,error); - if(value1) + boolean ok = Util.evaluateError("Cannot set value of column", cell_value, isErrorExpected); + if (ok) right(getCell(i, 1)); else - exception(getCell(i, 1), new Exception("Cannot set value of column")); + exception(getCell(i, 1), new Exception("Cannot set value of column")); } } catch (Exception e) { - columnsOK = false; - boolean value1=Util.evaluateError("Cannot set value of column",cell_value,error); - if(value1) + columnsOK = false; + boolean ok = Util.evaluateError(e.getMessage(), cell_value, isErrorExpected); + if (ok) right(getCell(i, 1)); else exception(getCell(i, 1), e); diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/DeleteRecord.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/DeleteRecord.java index 734a58376e..5b279938ce 100644 --- a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/DeleteRecord.java +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/DeleteRecord.java @@ -1,7 +1,6 @@ /********************************************************************** -* This file is part of Adempiere ERP Bazaar * -* http://www.adempiere.org * -* * +* This file is part of iDempiere ERP Bazaar * +* http://www.idempiere.org * * * * Copyright (C) Contributors * * * @@ -20,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * * MA 02110-1301, USA. * * * -***********************************************************************/ +**********************************************************************/ package org.idempiere.fitnesse.fixture; @@ -31,14 +30,9 @@ import java.util.Properties; import org.compiere.model.MTable; import org.compiere.model.PO; import org.compiere.util.DB; -import org.idempiere.fitnesse.fixture.Instance; -import org.idempiere.fitnesse.fixture.Static_iDempiereInstance; -import org.idempiere.fitnesse.fixture.Util; import fitnesse.fixtures.TableFixture; - - /** * @author juliana * @@ -48,7 +42,7 @@ public class DeleteRecord extends TableFixture { /* (non-Javadoc) * @see fitnesse.fixtures.TableFixture#doStaticTable(int) */ - + private volatile static Instance adempiereInstance = null; @@ -72,8 +66,8 @@ public class DeleteRecord extends TableFixture { boolean alreadyread = false; StringBuilder whereclause = new StringBuilder(""); - boolean error = false; - String msgerror=null; + boolean isErrorExpected = false; + String msgerror = null; for (int i = 0; i < rows; i++) { String cell_title = getText(i, 0); @@ -99,8 +93,8 @@ public class DeleteRecord extends TableFixture { } whereclause.append(cell_value); } else if (cell_title.equalsIgnoreCase("*Delete*") || cell_title.equalsIgnoreCase("*Delete*Error*")) { - error = "*Delete*Error*".equalsIgnoreCase(cell_title); - msgerror=cell_value; + isErrorExpected = "*Delete*Error*".equalsIgnoreCase(cell_title); + msgerror = cell_value; if (!tableOK) { getCell(i, 1).addToBody("Table " + tableName + " does not exist"); wrong(i, 1); @@ -121,26 +115,23 @@ public class DeleteRecord extends TableFixture { gpo = table.getPO(rs, null); } else { getCell(i, 1).addToBody("No record found: " + sql); - boolean value = Util.evaluateError("No record found: ",cell_value, error); - if (value) { + boolean ok = Util.evaluateError("No record found: ",cell_value, isErrorExpected); + if (ok) { right(i, 1); - return; } else { wrong(i, 1); - return; } - + return; } if (rs.next()) { getCell(i, 1).addToBody("More than one record found: " + sql); - boolean value = Util.evaluateError("More than one record found: ", cell_value,error); - if (value) { + boolean ok = Util.evaluateError("More than one record found: ", cell_value,isErrorExpected); + if (ok) { right(i, 1); - return; } else { wrong(i, 1); - return; } + return; } if (gpo != null) { @@ -148,14 +139,13 @@ public class DeleteRecord extends TableFixture { } } catch (Exception e) { - boolean value = Util.evaluateError(e.getMessage(),msgerror, error); - if (value) { + boolean ok = Util.evaluateError(e.getMessage(), msgerror, isErrorExpected); + if (ok) { right(getCell(i, 1)); - return; } else { exception(getCell(i, 1), e); - return; } + return; } finally { DB.close(rs, pstmt); rs = null; @@ -172,11 +162,11 @@ public class DeleteRecord extends TableFixture { if (whereclause.length() > 0) whereclause.append(" AND "); whereclause.append(cell_title).append("=").append(value_evaluated); - } + } } } }//end while - + } } 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 42e58caae1..93a3887aad 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 @@ -54,8 +54,8 @@ public class Login extends TableFixture { if (adempiereInstance == null) { adempiereInstance = Static_iDempiereInstance.getInstance(); } - boolean error="*Login*Error*".equalsIgnoreCase(getText(rows-1, 0)); - String msgerror=getText(rows-1, 1); + boolean isErrorExpected = "*Login*Error*".equalsIgnoreCase(getText(rows-1, 0)); + String msgerror = getText(rows-1, 1); for (int i = 0; i < rows; i++) { String cell_title = getText(i, 0); String cell_value = getText(i, 1); @@ -106,31 +106,30 @@ public class Login extends TableFixture { || m_password == null || m_password.length() == 0 || m_role_id < 0 || m_client_id < 0) { - - boolean value=Util.evaluateError("Incomplete data to login, needed User|Password|AD_Role_ID|AD_Client_ID", msgerror, error); - if(value) + + boolean ok = Util.evaluateError("Incomplete data to login, needed User|Password|AD_Role_ID|AD_Client_ID", msgerror, isErrorExpected); + if (ok) right(i,1); - else + else exception(getCell(rows-1, 1), new Exception("Incomplete data to login, needed User|Password|AD_Role_ID|AD_Client_ID")); } else { String msg = modelLogin(); if (msg == null || msg.length() == 0) { MSession.get (Env.getCtx(), true);// Start Session - if(error){ + if (isErrorExpected) { wrong(rows-1, 0); wrong(rows-1, 1); - }else{ + } else { right(rows-1, 0); right(rows-1, 1); } } else { - - boolean value=Util.evaluateError(msg, msgerror, error); - if(value){ + + boolean ok = Util.evaluateError(msg, msgerror, isErrorExpected); + if (ok) { right(rows-1, 0); - } - else{ + } else { wrong(rows-1, 0); exception(getCell(rows-1, 1), new Exception(msg)); } diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/ReadRecord.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/ReadRecord.java index 9f6cb3d36a..e6f281d0ed 100644 --- a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/ReadRecord.java +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/ReadRecord.java @@ -67,7 +67,7 @@ public class ReadRecord extends TableFixture { POInfo poinfo = null; boolean alreadyread = false; String whereclause = new String(""); - boolean error=false; + boolean isErrorExpected = false; for (int i = 0; i < rows; i++) { String cell_title = getText(i, 0); String cell_value = getText(i, 1); @@ -89,7 +89,7 @@ public class ReadRecord extends TableFixture { if (i != 1) { exception(getCell(i, 1), new Exception("*Where* must be defined in second row")); return; - } + } whereclause = cell_value; } else if (cell_title.equalsIgnoreCase("*Read*") || cell_title.equalsIgnoreCase("*Read*Error*")) { if (! tableOK) { @@ -97,7 +97,7 @@ public class ReadRecord extends TableFixture { wrong(i, 1); return; } - error="*Read*Error*".equalsIgnoreCase(cell_title); + isErrorExpected="*Read*Error*".equalsIgnoreCase(cell_title); if (whereclause.length() == 0) { getCell(i, 1).addToBody("No where clause"); wrong(i, 1); @@ -112,42 +112,39 @@ public class ReadRecord extends TableFixture { rs = pstmt.executeQuery(); if (rs.next()) { gpo = table.getPO(rs, null); - if(error){ + if (isErrorExpected) { wrong(i,1); } } else { getCell(i, 1).addToBody("No record found: " + sql); - boolean value=Util.evaluateError("No record found: ",cell_value,error); - if(value){ + boolean ok = Util.evaluateError("No record found: ", cell_value, isErrorExpected); + if (ok) { right(i,1); - return; - }else{ + } else { wrong(i,1); - return; } + return; } if (rs.next()) { getCell(i, 1).addToBody("More than one record found: " + sql); - boolean value=Util.evaluateError("More than one record found: ",cell_value,error); - if(value){ + boolean ok = Util.evaluateError("More than one record found: ",cell_value,isErrorExpected); + if (ok) { right(i,1); - return; - }else{ + } else { wrong(i,1); - return; - } + } + return; } } catch (SQLException e) { - boolean value=Util.evaluateError(e.getMessage(),cell_value,error); - if(value){ + boolean ok = Util.evaluateError(e.getMessage(),cell_value,isErrorExpected); + if (ok) { right(getCell(i, 1)); - return; - }else{ + } else { exception(getCell(i, 1), e); - return; - } + } + return; } finally { @@ -158,7 +155,7 @@ public class ReadRecord extends TableFixture { right(i, 1); if (gpo != null) { getCell(i, 1).addToBody(gpo.toString()); - } + } // read - set context variables for (int idx = 0; idx < poinfo.getColumnCount(); idx++) { String colname = poinfo.getColumnName(idx); 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 7fe5239453..53da5cd38d 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 @@ -83,8 +83,8 @@ public class RunProcess extends TableFixture { HashMap fmap = new HashMap(); int recordID = 0; String docAction = null; - boolean error="*Run*Error*".equalsIgnoreCase(getText(rows-1, 0)); - String msgerror1=getText(rows-1, 1); + boolean isErrorExpected = "*Run*Error*".equalsIgnoreCase(getText(rows-1, 0)); + String msgerror1 = getText(rows-1, 1); for (int i = 0; i < rows; i++) { String cell_title = getText(i, 0); String cell_value = getText(i, 1); @@ -95,14 +95,14 @@ public class RunProcess extends TableFixture { } String processValue = cell_value; int processID = MProcess.getProcess_ID(processValue, null); - if (processID <= 0 ) { - boolean value=Util.evaluateError(msgerror1,"Process with Value=" + processValue + " doesn't exist", error); - if(value){ + if (processID <= 0) { + boolean ok = Util.evaluateError(msgerror1,"Process with Value=" + processValue + " doesn't exist", isErrorExpected); + if (ok) { right(getCell(i, 1)); - }else{ - exception(getCell(i, 1), new Exception("Process with Value=" + processValue + " doesn't exist")); - return; - } + } else { + exception(getCell(i, 1), new Exception("Process with Value=" + processValue + " doesn't exist")); + } + return; } process = new MProcess(ctx, processID, null); } else if (cell_title.equalsIgnoreCase("*ProcessID*")) { @@ -113,15 +113,15 @@ public class RunProcess extends TableFixture { int processID = getInt(i, 1); process = new MProcess(ctx, processID, null); if (process == null || process.get_ID() <= 0) { - boolean value=Util.evaluateError(msgerror1,"Process with ID=" + processID + " doesn't exist", error); - if(value){ + boolean ok = Util.evaluateError(msgerror1,"Process with ID=" + processID + " doesn't exist", isErrorExpected); + if (ok) { right(getCell(i, 1)); - }else{ - exception(getCell(i, 1), new Exception("Process with ID=" + processID + " doesn't exist")); - return; + } else { + exception(getCell(i, 1), new Exception("Process with ID=" + processID + " doesn't exist")); } + return; } - } else if (cell_title.equalsIgnoreCase("*Run*") || cell_title.equalsIgnoreCase("*Run*Error*") ) { + } else if (cell_title.equalsIgnoreCase("*Run*") || cell_title.equalsIgnoreCase("*Run*Error*")) { if (i != rows-1) { exception(getCell(i, 1), new Exception("*Run* must be called in last row")); return; @@ -130,11 +130,11 @@ public class RunProcess extends TableFixture { pInstance = new MPInstance (process, 0); MPInstancePara[] iParams = pInstance.getParameters(); String errorMsg = setParams(process, iParams, fmap); - if (errorMsg != null){ - boolean value=Util.evaluateError(msgerror1,errorMsg, error); - if(value){ - - }else{ + if (errorMsg != null) { + boolean ok = Util.evaluateError(msgerror1,errorMsg, isErrorExpected); + if (ok) { + // do nothing + } else { exception(getCell(i, 1), new Exception(errorMsg)); } } @@ -159,7 +159,7 @@ public class RunProcess extends TableFixture { po.set_ValueOfColumn("DocAction", docAction); po.saveEx(); } - + } } } @@ -176,52 +176,51 @@ public class RunProcess extends TableFixture { // Start if (process.isWorkflow()) { - boolean value=Util.evaluateError(msgerror1,pi.getSummary(), error); try { int AD_Workflow_ID = process.getAD_Workflow_ID(); MWorkflow wf = MWorkflow.get (ctx, AD_Workflow_ID); MWFProcess wfProcess = wf.startWait(pi); // may return null - if(wfProcess != null) + if (wfProcess != null) { getCell(i, 1).addToBody(Msg.parseTranslation(ctx, pi.getSummary())); addLogInfo(pInstance, i); - + if (wf.getWorkflowType().equals(MWorkflow.WORKFLOWTYPE_DocumentProcess)) { MTable table = MTable.get(ctx, wf.getAD_Table_ID()); if (table != null) { PO po = table.getPO(recordID, null); - if(!docAction.equals(po.get_Value("DocStatus"))){ - if(value){ - right(getCell(i, 1)); - }else{ + if (!docAction.equals(po.get_Value("DocStatus"))) { + boolean ok = Util.evaluateError(Msg.parseTranslation(ctx, pi.getSummary()), msgerror1, isErrorExpected); + if (ok) { + right(getCell(i, 1)); + } else { wrong(getCell(i, 1)); } + } else { + if (isErrorExpected) { + wrong(getCell(i, 1)); + } else { + right(getCell(i, 1)); + } } - else { - if (value) { - right(getCell(i, 1)); - } else { - wrong(getCell(i, 1)); - } - } - } - } - else{ - if(value){ - right(getCell(i, 1)); - }else{ - wrong(getCell(i, 1)); } + } else { + if (isErrorExpected) { + wrong(getCell(i, 1)); + } else { + right(getCell(i, 1)); + } } } } catch(Exception ex) { - if(value){ + boolean ok = Util.evaluateError(ex.getMessage(), cell_value, isErrorExpected); + if (ok) { right(getCell(i, 1)); - }else{ - exception(getCell(i, 1), ex); + } else { + exception(getCell(i, 1), ex); } } //started = wfProcess != null; @@ -243,23 +242,23 @@ public class RunProcess extends TableFixture { } if (!processOK || pi.isError()) { - boolean value=Util.evaluateError(msgerror1,pi.getSummary(), error); - if(value){ + boolean ok = Util.evaluateError(msgerror1,pi.getSummary(), isErrorExpected); + if (ok) { right(getCell(i, 1)); processOK = true; - }else{ - exception(getCell(i, 1), new Exception(pi.getSummary())); - processOK = false; + } else { + exception(getCell(i, 1), new Exception(pi.getSummary())); + processOK = false; } } else { - if(error){ + if (isErrorExpected) { wrong(getCell(i, 1)); - }else{ - getCell(i, 1).addToBody(Msg.parseTranslation(ctx, pi.getSummary())); - addLogInfo(pInstance, i); - right(getCell(i, 1)); + } else { + getCell(i, 1).addToBody(Msg.parseTranslation(ctx, pi.getSummary())); + addLogInfo(pInstance, i); + right(getCell(i, 1)); } } } diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/UpdateRecord.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/UpdateRecord.java index b3a492d847..4a11961e6a 100644 --- a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/UpdateRecord.java +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/UpdateRecord.java @@ -1,7 +1,6 @@ /********************************************************************** -* This file is part of Adempiere ERP Bazaar * -* http://www.adempiere.org * -* * +* This file is part of iDempiere ERP Bazaar * +* http://www.idempiere.org * * * * Copyright (C) Contributors * * * @@ -20,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * * MA 02110-1301, USA. * * * -***********************************************************************/ +**********************************************************************/ package org.idempiere.fitnesse.fixture; @@ -71,8 +70,8 @@ public class UpdateRecord extends TableFixture { boolean alreadyread = false; StringBuilder whereclause = new StringBuilder(""); - boolean error = false; - String msgerror=null; + boolean isErrorExpected = false; + String msgerror = null; for (int i = 0; i < rows; i++) { String cell_title = getText(i, 0); String cell_value = getText(i, 1); @@ -97,8 +96,8 @@ public class UpdateRecord extends TableFixture { } whereclause.append(cell_value); } else if (cell_title.equalsIgnoreCase("*Update*") || cell_title.equalsIgnoreCase("*Update*Error*")) { - error = "*Update*Error*".equalsIgnoreCase(cell_title); - msgerror=cell_value; + isErrorExpected = "*Update*Error*".equalsIgnoreCase(cell_title); + msgerror = cell_value; if (!tableOK) { getCell(i, 1).addToBody("Table " + tableName + " does not exist"); wrong(i, 1); @@ -119,36 +118,32 @@ public class UpdateRecord extends TableFixture { gpo = table.getPO(rs, null); } else { getCell(i, 1).addToBody("No record found: " + sql); - boolean value = Util.evaluateError("No record found: ",cell_value, error); - if (value) { + boolean ok = Util.evaluateError("No record found: ",cell_value, isErrorExpected); + if (ok) { right(i, 1); - return; } else { wrong(i, 1); - return; } - + return; } if (rs.next()) { getCell(i, 1).addToBody("More than one record found: " + sql); - boolean value = Util.evaluateError("More than one record found: ", cell_value,error); - if (value) { + boolean ok = Util.evaluateError("More than one record found: ", cell_value,isErrorExpected); + if (ok) { right(i, 1); - return; } else { wrong(i, 1); - return; } + return; } } catch (SQLException e) { - boolean value = Util.evaluateError(e.getMessage(),cell_value, error); - if (value) { + boolean ok = Util.evaluateError(e.getMessage(),cell_value, isErrorExpected); + if (ok) { right(getCell(i, 1)); - return; } else { exception(getCell(i, 1), e); - return; } + return; } finally { DB.close(rs, pstmt); rs = null; @@ -169,21 +164,20 @@ public class UpdateRecord extends TableFixture { whereclause.append(" AND "); whereclause.append(cell_title).append("=").append(value_evaluated); } else { - if(gpo != null){ - if(gpo.set_ValueOfColumnReturningBoolean(cell_title, cell_value)){ - if(error){ + if (gpo != null) { + if (gpo.set_ValueOfColumnReturningBoolean(cell_title, cell_value)) { + if (isErrorExpected) { wrong(getCell(i, 1)); - }else{ + } else { right(getCell(i, 1)); - } } try { gpo.saveEx(); } catch (Exception e) { - boolean value = Util.evaluateError(e.getMessage(),msgerror, error); - if (value) + boolean ok = Util.evaluateError(e.getMessage(),msgerror, isErrorExpected); + if (ok) right(getCell(i, 1)); else exception(getCell(i, 1),e); 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 f92082b156..e20edecab2 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 @@ -250,16 +250,16 @@ public class Util { return evaluate(ctx, windowNo, expr, null); } - - public static boolean evaluateError(String error, String cell,boolean isError) { + + public static boolean evaluateError(String error, String cell, boolean isExpectedError) { boolean evaluate = false; - - if(error == null) - error=""; + + if (error == null) + error = ""; if (cell == null) - cell=""; - - if (isError) { + cell = ""; + + if (isExpectedError) { if (cell.length() > 0) { if (error.contains(cell)) { evaluate = true; @@ -275,5 +275,5 @@ public class Util { } return evaluate; } - + } // AdempiereUtil diff --git a/org.idempiere.fitrecorder/src/org/idempiere/fitrecorder/FitRecorder.java b/org.idempiere.fitrecorder/src/org/idempiere/fitrecorder/FitRecorder.java index 04d8564227..0fa59bb9d7 100644 --- a/org.idempiere.fitrecorder/src/org/idempiere/fitrecorder/FitRecorder.java +++ b/org.idempiere.fitrecorder/src/org/idempiere/fitrecorder/FitRecorder.java @@ -183,7 +183,7 @@ public class FitRecorder implements ModelValidator { // Ignore records created within a workflow process if (po.get_TrxName().startsWith("WFP_")) return null; - + writeFile("\n"); writeFile("\n"); writeFile("CREATE RECORD"); @@ -227,10 +227,10 @@ public class FitRecorder implements ModelValidator { writeFile("\n"); } - + if(type == TYPE_AFTER_CHANGE) { - if (po instanceof MPInstance) + if (po instanceof MPInstance) { MProcess pro = MProcess.get(Env.getCtx(), po.get_ValueAsInt("AD_Process_ID")); MPInstance pint = (MPInstance)po; @@ -294,8 +294,7 @@ public class FitRecorder implements ModelValidator { writeFile("|*Run*|"); writeFile("\n"); - }else if(po instanceof MSession) - { + } else if (po instanceof MSession) { MSession session = (MSession) po; if (session.isProcessed()) { closefile(); @@ -387,7 +386,7 @@ public class FitRecorder implements ModelValidator { } - if(type == TYPE_AFTER_DELETE) + if (type == TYPE_AFTER_DELETE) { if (dontLogTables.contains(po.get_TableName().toUpperCase())) return null; @@ -399,7 +398,7 @@ public class FitRecorder implements ModelValidator { // Ignore records created within a workflow process if (po.get_TrxName().startsWith("WFP_")) return null; - + writeFile("\n"); writeFile("\n"); writeFile("DELETE RECORD"); @@ -422,14 +421,12 @@ public class FitRecorder implements ModelValidator { String value=null; if (DisplayType.isLookup(column.getAD_Reference_ID()) && DisplayType.List != column.getAD_Reference_ID()) { value = resolveValue(po, table, column); - }else{ + } else { value=po.get_ValueAsString(colName); } - if (column.isAllowLogging()) - { - if (column.isKey()) - { + if (column.isAllowLogging()) { + if (column.isKey()) { if (!key) { writeFile("| *Where* | "); writeFile(colName + " = " + value+ " | "); @@ -440,7 +437,7 @@ public class FitRecorder implements ModelValidator { } } } - }//while columns + }//while columns writeFile("\n"); writeFile("| *Delete* |"); @@ -517,7 +514,7 @@ public class FitRecorder implements ModelValidator { } else { value = po.get_ValueAsString(column.getColumnName()); } - + return value; } From 9388df405bab8e74698f595dcdbf94959a4dce22 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 22 Apr 2013 15:56:04 -0500 Subject: [PATCH 3/6] IDEMPIERE-730 03_update_sequences.sql for native sequence --- .../oracle/03_update_sequences.sql | 16 +++++++++++++--- .../postgresql/03_update_sequences.sql | 15 ++++++++++++--- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/migration/processes_post_migration/oracle/03_update_sequences.sql b/migration/processes_post_migration/oracle/03_update_sequences.sql index 061710f3d9..156bf102a6 100644 --- a/migration/processes_post_migration/oracle/03_update_sequences.sql +++ b/migration/processes_post_migration/oracle/03_update_sequences.sql @@ -3,6 +3,7 @@ DECLARE cmdsys VARCHAR2 (1000); cmdnosys VARCHAR2 (1000); cmdseq VARCHAR2 (1000); + cmdcrseq VARCHAR2 (1000); cmdupd VARCHAR2 (1000); currentnextsys NUMBER (10); currentnext NUMBER (10); @@ -10,6 +11,8 @@ DECLARE Currentseq Number (10); Isnativeseqon Varchar2(1); sqlcmd VARCHAR2(200); + seq_doesnot_exist EXCEPTION; + PRAGMA EXCEPTION_INIT(seq_doesnot_exist, -2289); BEGIN DBMS_OUTPUT.PUT_LINE ('Start'); @@ -20,6 +23,7 @@ BEGIN FROM AD_COLUMN c WHERE t.ad_table_id = c.ad_table_id AND c.columnname = t.tablename || '_ID') + AND IsView= 'N' ORDER BY 1) LOOP cmdsys := @@ -87,17 +91,23 @@ BEGIN || 'WHERE Name = ''' || r.Tablename || ''' AND istableid = ''Y'''; + BEGIN + EXECUTE IMMEDIATE cmdseq INTO currentseq, currentseqsys; + EXCEPTION + WHEN seq_doesnot_exist THEN + cmdcrseq:= 'CREATE SEQUENCE '||Trim(R.Tablename)||'_SQ MINVALUE 1000000 MAXVALUE 2147483647 INCREMENT BY 1 START WITH 1000000'; + Execute Immediate cmdcrseq; + EXECUTE IMMEDIATE cmdseq INTO currentseq, currentseqsys; + END; ELSE cmdseq := 'SELECT currentnext, currentnextsys FROM AD_Sequence ' || 'WHERE Name = ''' || r.tablename || ''' AND istableid = ''Y'''; + EXECUTE IMMEDIATE cmdseq INTO currentseq, currentseqsys; END IF; - EXECUTE IMMEDIATE cmdseq - INTO currentseq, currentseqsys; - IF currentnextsys <> currentseqsys OR (currentnext <> currentseq AND Isnativeseqon ='N') THEN DBMS_OUTPUT.PUT_LINE ( r.tablename diff --git a/migration/processes_post_migration/postgresql/03_update_sequences.sql b/migration/processes_post_migration/postgresql/03_update_sequences.sql index 490cdae5fd..7239f37c7f 100644 --- a/migration/processes_post_migration/postgresql/03_update_sequences.sql +++ b/migration/processes_post_migration/postgresql/03_update_sequences.sql @@ -1,9 +1,10 @@ -CREATE OR REPLACE FUNCTION update_sequences() RETURNS void as $func$ -- TODO: Currently not inserting new sequences +CREATE OR REPLACE FUNCTION update_sequences() RETURNS void as $func$ DECLARE cmdsys VARCHAR (1000); cmdnosys VARCHAR (1000); cmdseq VARCHAR (1000); + cmdcrseq VARCHAR (1000); cmdupd VARCHAR (1000); currentnextsys NUMERIC (10); currentnext NUMERIC (10); @@ -21,6 +22,7 @@ BEGIN FROM AD_COLUMN c WHERE t.ad_table_id = c.ad_table_id AND c.columnname = t.tablename || '_ID') + AND IsView= 'N' ORDER BY 1) LOOP cmdsys := @@ -82,16 +84,23 @@ BEGIN || 'WHERE Name = ''' || r.tablename || ''' AND istableid = ''Y'''; + BEGIN + EXECUTE cmdseq INTO currentseq, currentseqsys; + EXCEPTION + WHEN undefined_table THEN + cmdcrseq := 'CREATE SEQUENCE '||trim(r.tablename)||'_SQ INCREMENT 1 MINVALUE 1000000 MAXVALUE 2147483647 START '||currentseq; + EXECUTE cmdcrseq; + EXECUTE cmdseq INTO currentseq, currentseqsys; + END; ELSE cmdseq := 'SELECT currentnext, currentnextsys FROM AD_Sequence ' || 'WHERE Name = ''' || r.tablename || ''' AND istableid = ''Y'''; + EXECUTE cmdseq INTO currentseq, currentseqsys; END IF; - EXECUTE cmdseq INTO currentseq, currentseqsys; - IF currentnextsys <> currentseqsys OR (currentnext <> currentseq AND isnativeseqon ='N') THEN cmdupd := From 38877fc7ea3075d9bc97e4c2374e47061c8960f0 Mon Sep 17 00:00:00 2001 From: Juliana Corredor Date: Mon, 22 Apr 2013 19:19:27 -0500 Subject: [PATCH 4/6] IDEMPIERE-166 Rebranding of logo and product name - fix links --- .../servlet/org/compiere/web/AdempiereMonitor.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/org.adempiere.server/src/main/servlet/org/compiere/web/AdempiereMonitor.java b/org.adempiere.server/src/main/servlet/org/compiere/web/AdempiereMonitor.java index 7bae7bebf0..8c93948f31 100644 --- a/org.adempiere.server/src/main/servlet/org/compiere/web/AdempiereMonitor.java +++ b/org.adempiere.server/src/main/servlet/org/compiere/web/AdempiereMonitor.java @@ -953,12 +953,12 @@ public class AdempiereMonitor extends HttpServlet line = new tr(); CLogFile fileHandler = CLogFile.get (true, null, false); line.addElement(new th().addElement("Trace File")); - line.addElement(new td().addElement(new a ("adempiereMonitor?Trace=" + fileHandler.getFileName(), "Current"))); + line.addElement(new td().addElement(new a ("idempiereMonitor?Trace=" + fileHandler.getFileName(), "Current"))); table.addElement(line); // line = new tr(); - line.addElement(new td().addElement(new a ("adempiereMonitor?Trace=ROTATE", "Rotate Trace Log"))); - line.addElement(new td().addElement(new a ("adempiereMonitor?Trace=DELETE", "Delete all Trace Logs"))); + line.addElement(new td().addElement(new a ("idempiereMonitor?Trace=ROTATE", "Rotate Trace Log"))); + line.addElement(new td().addElement(new a ("idempiereMonitor?Trace=DELETE", "Delete all Trace Logs"))); table.addElement(line); // bb.addElement(table); @@ -980,7 +980,7 @@ public class AdempiereMonitor extends HttpServlet if (i != 0) p.addElement(" - "); String fileName = logs[i].getAbsolutePath(); - a link = new a ("adempiereMonitor?Trace=" + fileName, fileName); + a link = new a ("idempiereMonitor?Trace=" + fileName, fileName); p.addElement(link); int size = (int)(logs[i].length()/1024); if (size < 1024) @@ -1006,7 +1006,7 @@ public class AdempiereMonitor extends HttpServlet MClient client = clients[i]; if (i > 0) p.addElement(" - "); - p.addElement(new a("adempiereMonitor?EMail=" + client.getAD_Client_ID(), client.getName())); + p.addElement(new a("idempiereMonitor?EMail=" + client.getAD_Client_ID(), client.getName())); } if (clients.length == 0) p.addElement(" "); From b8a6b85a860966e85597a932f66fe028beb481d1 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 22 Apr 2013 19:34:31 -0500 Subject: [PATCH 5/6] IDEMPIERE-166 Rebranding of logo and product name - fix more links --- .../org/compiere/web/AdempiereMonitor.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/org.adempiere.server/src/main/servlet/org/compiere/web/AdempiereMonitor.java b/org.adempiere.server/src/main/servlet/org/compiere/web/AdempiereMonitor.java index 8c93948f31..3ac47a4930 100644 --- a/org.adempiere.server/src/main/servlet/org/compiere/web/AdempiereMonitor.java +++ b/org.adempiere.server/src/main/servlet/org/compiere/web/AdempiereMonitor.java @@ -194,7 +194,7 @@ public class AdempiereMonitor extends HttpServlet body b = doc.getBody(); // p para = new p(); - a link = new a ("adempiereMonitor#" + serverID, "Return"); + a link = new a ("idempiereMonitor#" + serverID, "Return"); para.addElement(link); b.addElement(para); // @@ -605,16 +605,16 @@ public class AdempiereMonitor extends HttpServlet bb.addElement(table); // p para = new p(); - a link = new a ("adempiereMonitor?Action=Start_All", "Start All"); + a link = new a ("idempiereMonitor?Action=Start_All", "Start All"); para.addElement(link); para.addElement(" - "); - link = new a ("adempiereMonitor?Action=Stop_All", "Stop All"); + link = new a ("idempiereMonitor?Action=Stop_All", "Stop All"); para.addElement(link); para.addElement(" - "); - link = new a ("adempiereMonitor?Action=Reload", "Reload"); + link = new a ("idempiereMonitor?Action=Reload", "Reload"); para.addElement(link); para.addElement(" - "); - link = new a ("adempiereMonitor", "Refresh"); + link = new a ("idempiereMonitor", "Refresh"); para.addElement(link); bb.addElement(para); @@ -659,7 +659,7 @@ public class AdempiereMonitor extends HttpServlet if (server.isAlive()) { String msg = "Stop"; - link = new a ("adempiereMonitor?Action=Stop_" + server.getServer().getServerID(), msg); + link = new a ("idempiereMonitor?Action=Stop_" + server.getServer().getServerID(), msg); if (server.getServer().isSleeping()) { line.addElement(new th().addElement("Sleeping")); @@ -680,7 +680,7 @@ public class AdempiereMonitor extends HttpServlet { String msg = "Start"; line.addElement(new th().addElement("Not Started")); - link = new a ("adempiereMonitor?Action=Start_" + server.getServer().getServerID(), msg); + link = new a ("idempiereMonitor?Action=Start_" + server.getServer().getServerID(), msg); line.addElement(new td().addElement(link)); } table.addElement(line); @@ -704,7 +704,7 @@ public class AdempiereMonitor extends HttpServlet td td = new td(); td.addElement(WebEnv.getCellContent(server.getServer().getDateNextRun(false))); td.addElement(" - "); - link = new a ("adempiereMonitor?RunNow=" + server.getServer().getServerID(), "(Run Now)"); + link = new a ("idempiereMonitor?RunNow=" + server.getServer().getServerID(), "(Run Now)"); td.addElement(link); line.addElement(td); table.addElement(line); @@ -720,10 +720,10 @@ public class AdempiereMonitor extends HttpServlet link = new a ("#top", "Top"); bb.addElement(link); bb.addElement(" - "); - link = new a ("adempiereMonitor?Log=" + server.getServer().getServerID(), "Log"); + link = new a ("idempiereMonitor?Log=" + server.getServer().getServerID(), "Log"); bb.addElement(link); bb.addElement(" - "); - link = new a ("adempiereMonitor", "Refresh"); + link = new a ("idempiereMonitor", "Refresh"); bb.addElement(link); } @@ -928,13 +928,13 @@ public class AdempiereMonitor extends HttpServlet // Cache Reset line = new tr(); line.addElement(new th().addElement(CacheMgt.get().toStringX())); - line.addElement(new td().addElement(new a ("adempiereMonitor?CacheReset=Yes", "Reset Cache"))); + line.addElement(new td().addElement(new a ("idempiereMonitor?CacheReset=Yes", "Reset Cache"))); table.addElement(line); // Trace Level line = new tr(); line.addElement(new th().addElement(new label("TraceLevel").addElement("Trace Log Level"))); - form myForm = new form("adempiereMonitor", form.METHOD_POST, form.ENC_DEFAULT); + form myForm = new form("idempiereMonitor", form.METHOD_POST, form.ENC_DEFAULT); // LogLevel Selection option[] options = new option[CLogMgt.LEVELS.length]; for (int i = 0; i < options.length; i++) From ad909c55ac9e124c6e4e97b3d1543da84e3e6fab Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 22 Apr 2013 19:45:28 -0500 Subject: [PATCH 6/6] IDEMPIERE-851 fitnesse improvements / fix problem with registering migration script --- migration/i1.0a-release/oracle/201304181900_IDEMPIERE-851.sql | 2 +- .../i1.0a-release/postgresql/201304181900_IDEMPIERE-851.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/i1.0a-release/oracle/201304181900_IDEMPIERE-851.sql b/migration/i1.0a-release/oracle/201304181900_IDEMPIERE-851.sql index cf1bca355f..1846d2bdf1 100644 --- a/migration/i1.0a-release/oracle/201304181900_IDEMPIERE-851.sql +++ b/migration/i1.0a-release/oracle/201304181900_IDEMPIERE-851.sql @@ -9,6 +9,6 @@ UPDATE AD_Column SET IsAllowLogging='N',Updated=TO_DATE('2013-04-18 18:42:14','Y ; -SELECT register_migration_script('2010304181900_IDEMPIERE-851.sql') FROM dual +SELECT register_migration_script('201304181900_IDEMPIERE-851.sql') FROM dual ; diff --git a/migration/i1.0a-release/postgresql/201304181900_IDEMPIERE-851.sql b/migration/i1.0a-release/postgresql/201304181900_IDEMPIERE-851.sql index e7da56f8ca..fea70e5e7e 100644 --- a/migration/i1.0a-release/postgresql/201304181900_IDEMPIERE-851.sql +++ b/migration/i1.0a-release/postgresql/201304181900_IDEMPIERE-851.sql @@ -9,5 +9,5 @@ UPDATE AD_Column SET IsAllowLogging='N',Updated=TO_TIMESTAMP('2013-04-18 18:42:1 ; -SELECT register_migration_script('2010304181900_IDEMPIERE-851.sql') FROM dual +SELECT register_migration_script('201304181900_IDEMPIERE-851.sql') FROM dual ;