From 9f22430aad00dae433157f306db0cfabd1fb2dc8 Mon Sep 17 00:00:00 2001 From: hengsin Date: Mon, 1 Aug 2022 01:22:06 +0800 Subject: [PATCH] IDEMPIERE-5359 Unit test not working with Oracle (#1414) --- .../oracle/202207291542_IDEMPIERE-5359.sql | 13 +++++ .../202207291542_IDEMPIERE-5359.sql | 7 +++ .../src/org/compiere/apps/form/Match.java | 4 +- .../test/base/Convert_PostgreSQLTest.java | 24 ++++++++++ .../org/idempiere/test/base/InOutTest.java | 11 ++--- .../test/base/MatchInv2ndAcctSchemaTest.java | 15 +++--- .../org/idempiere/test/base/MatchInvTest.java | 36 +++++++------- .../src/org/idempiere/test/base/POTest.java | 12 +++++ .../org/idempiere/test/base/QueryTest.java | 2 +- .../idempiere/test/model/AllocationTest.java | 48 +++++++++---------- .../idempiere/test/model/InventoryTest.java | 2 +- .../test/model/MDiscountSchemaTest.java | 1 + .../idempiere/test/model/MInfoWindowTest.java | 1 + .../idempiere/test/model/MProductTest.java | 3 +- .../idempiere/test/model/MSchedulerTest.java | 1 + .../test/model/MStorageOnHandTest.java | 1 + .../test/model/MUOMConversionTest.java | 1 + .../test/model/ModelClassMappingTest.java | 6 ++- .../org/idempiere/test/model/ProcessTest.java | 3 +- .../idempiere/test/model/ProductionTest.java | 2 +- 20 files changed, 128 insertions(+), 65 deletions(-) create mode 100644 migration/iD10/oracle/202207291542_IDEMPIERE-5359.sql create mode 100644 migration/iD10/postgresql/202207291542_IDEMPIERE-5359.sql diff --git a/migration/iD10/oracle/202207291542_IDEMPIERE-5359.sql b/migration/iD10/oracle/202207291542_IDEMPIERE-5359.sql new file mode 100644 index 0000000000..9abe6d58c2 --- /dev/null +++ b/migration/iD10/oracle/202207291542_IDEMPIERE-5359.sql @@ -0,0 +1,13 @@ +-- IDEMPIERE-5359 Unit test not working with Oracle +SELECT register_migration_script('202207291542_IDEMPIERE-5359.sql') FROM dual; + +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Jul 29, 2022, 3:42:38 PM MYT +UPDATE AD_Column SET ColumnSQL='(SELECT 123.45 FROM DUAL)',Updated=TO_DATE('2022-07-29 15:42:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214655 +; + +DROP INDEX M_PRODUCTIONLINEMA_KEY +; + diff --git a/migration/iD10/postgresql/202207291542_IDEMPIERE-5359.sql b/migration/iD10/postgresql/202207291542_IDEMPIERE-5359.sql new file mode 100644 index 0000000000..ee589a9543 --- /dev/null +++ b/migration/iD10/postgresql/202207291542_IDEMPIERE-5359.sql @@ -0,0 +1,7 @@ +-- IDEMPIERE-5359 Unit test not working with Oracle +SELECT register_migration_script('202207291542_IDEMPIERE-5359.sql') FROM dual; + +-- Jul 29, 2022, 3:42:38 PM MYT +UPDATE AD_Column SET ColumnSQL='(SELECT 123.45 FROM DUAL)',Updated=TO_TIMESTAMP('2022-07-29 15:42:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214655 +; + diff --git a/org.adempiere.ui/src/org/compiere/apps/form/Match.java b/org.adempiere.ui/src/org/compiere/apps/form/Match.java index f3319bf214..0f1082998f 100644 --- a/org.adempiere.ui/src/org/compiere/apps/form/Match.java +++ b/org.adempiere.ui/src/org/compiere/apps/form/Match.java @@ -311,7 +311,7 @@ public class Match m_sql.append(" AND mi.M_InOutLine_ID = ").append(Line_ID); m_groupBy = " GROUP BY hdr.C_Invoice_ID,hdr.DocumentNo,hdr.DateInvoiced,bp.Name,hdr.C_BPartner_ID," - + " lin.Line,lin.C_InvoiceLine_ID,p.Name,lin.M_Product_ID,dt.DocBaseType,lin.QtyInvoiced, org.Name, hdr.AD_Org_ID " //JAVIER + + " lin.Line,lin.C_InvoiceLine_ID,p.Name,lin.M_Product_ID,dt.DocBaseType,lin.QtyInvoiced, org.Name, hdr.AD_Org_ID, dt.DocBaseType " //JAVIER + "HAVING " + (matched ? "0" : "CASE WHEN dt.DocBaseType='APC' THEN lin.QtyInvoiced * -1 ELSE lin.QtyInvoiced END") + "<>SUM(NVL(mi.Qty,0))"; @@ -394,7 +394,7 @@ public class Match m_sql.append(" AND m.C_OrderLine_ID = ").append(Line_ID); m_groupBy = " GROUP BY hdr.M_InOut_ID,hdr.DocumentNo,hdr.MovementDate,bp.Name,hdr.C_BPartner_ID," - + " lin.Line,lin.M_InOutLine_ID,p.Name,lin.M_Product_ID,lin.MovementQty, org.Name, hdr.AD_Org_ID, dt.DocBaseType " //JAVIER + + " lin.Line,lin.M_InOutLine_ID,p.Name,lin.M_Product_ID,lin.MovementQty, org.Name, hdr.AD_Org_ID, dt.DocBaseType, hdr.IsSOTrx " //JAVIER + "HAVING " + (matched ? "0" : "CASE WHEN (dt.DocBaseType='MMS' AND hdr.issotrx='N') THEN lin.MovementQty * -1 ELSE lin.MovementQty END"); if (matchToType == MATCH_ORDER) diff --git a/org.idempiere.test/src/org/idempiere/test/base/Convert_PostgreSQLTest.java b/org.idempiere.test/src/org/idempiere/test/base/Convert_PostgreSQLTest.java index 7347c75b89..8b3bb54c1b 100644 --- a/org.idempiere.test/src/org/idempiere/test/base/Convert_PostgreSQLTest.java +++ b/org.idempiere.test/src/org/idempiere/test/base/Convert_PostgreSQLTest.java @@ -52,6 +52,7 @@ public final class Convert_PostgreSQLTest extends AbstractTestCase { @Test public void test1807657() { + if (DB.isOracle()) return; String originalNative = Ini.getProperty(P_POSTGRE_SQL_NATIVE); try { testNotNative(); @@ -78,6 +79,7 @@ public final class Convert_PostgreSQLTest extends AbstractTestCase { } @Test public void test1751966() { + if (DB.isOracle()) return; String originalNative = Ini.getProperty(P_POSTGRE_SQL_NATIVE); try { testNotNative(); @@ -113,6 +115,7 @@ public final class Convert_PostgreSQLTest extends AbstractTestCase { //[ 1707959 ] Copy from other PrintFormat doesn't work anymore @Test public void test1707959() { + if (DB.isOracle()) return; String originalNative = Ini.getProperty(P_POSTGRE_SQL_NATIVE); try { testNotNative(); @@ -139,6 +142,7 @@ public final class Convert_PostgreSQLTest extends AbstractTestCase { //[ 1707611 ] Column synchronization for mandatory columns doesn't work @Test public void testAlterColumn() { + if (DB.isOracle()) return; String originalNative = Ini.getProperty(P_POSTGRE_SQL_NATIVE); try { testNotNative(); @@ -201,6 +205,7 @@ public final class Convert_PostgreSQLTest extends AbstractTestCase { // https://sourceforge.net/p/adempiere/bugs/504/ @Test public void test1705768() { + if (DB.isOracle()) return; String originalNative = Ini.getProperty(P_POSTGRE_SQL_NATIVE); try { testNotNative(); @@ -215,6 +220,7 @@ public final class Convert_PostgreSQLTest extends AbstractTestCase { @Test public void test1704261() { + if (DB.isOracle()) return; String originalNative = Ini.getProperty(P_POSTGRE_SQL_NATIVE); try { testNotNative(); @@ -230,6 +236,7 @@ public final class Convert_PostgreSQLTest extends AbstractTestCase { @Test public void testAlterTable() { + if (DB.isOracle()) return; String originalNative = Ini.getProperty(P_POSTGRE_SQL_NATIVE); try { testNotNative(); @@ -251,6 +258,7 @@ public final class Convert_PostgreSQLTest extends AbstractTestCase { @Test public void test1662983() { + if (DB.isOracle()) return; String originalNative = Ini.getProperty(P_POSTGRE_SQL_NATIVE); try { testNotNative(); @@ -271,6 +279,7 @@ public final class Convert_PostgreSQLTest extends AbstractTestCase { @Test public void testMultiColumnAssignment() { + if (DB.isOracle()) return; String originalNative = Ini.getProperty(P_POSTGRE_SQL_NATIVE); try { testNotNative(); @@ -324,6 +333,7 @@ public final class Convert_PostgreSQLTest extends AbstractTestCase { @Test public void testReservedWordInQuote() { + if (DB.isOracle()) return; String originalNative = Ini.getProperty(P_POSTGRE_SQL_NATIVE); try { testNotNative(); @@ -339,6 +349,7 @@ public final class Convert_PostgreSQLTest extends AbstractTestCase { @Test public void test1580231() { + if (DB.isOracle()) return; String originalNative = Ini.getProperty(P_POSTGRE_SQL_NATIVE); try { testNotNative(); @@ -391,6 +402,7 @@ public final class Convert_PostgreSQLTest extends AbstractTestCase { @Test public void testAliasInUpdate() { + if (DB.isOracle()) return; String originalNative = Ini.getProperty(P_POSTGRE_SQL_NATIVE); try { testNotNative(); @@ -406,6 +418,7 @@ public final class Convert_PostgreSQLTest extends AbstractTestCase { @Test public void test1580226() { + if (DB.isOracle()) return; String originalNative = Ini.getProperty(P_POSTGRE_SQL_NATIVE); try { testNotNative(); @@ -453,6 +466,7 @@ public final class Convert_PostgreSQLTest extends AbstractTestCase { @Test public void testTrunc() { + if (DB.isOracle()) return; String originalNative = Ini.getProperty(P_POSTGRE_SQL_NATIVE); try { testNotNative(); @@ -468,6 +482,7 @@ public final class Convert_PostgreSQLTest extends AbstractTestCase { @Test public void testSubQuery() { + if (DB.isOracle()) return; //MLanguage.addTable sql = "INSERT INTO " + "AD_Column_Trl" + "(AD_Language,IsTranslated, AD_Client_ID,AD_Org_ID, " @@ -487,6 +502,7 @@ public final class Convert_PostgreSQLTest extends AbstractTestCase { @Test public void test1622302() { + if (DB.isOracle()) return; String originalNative = Ini.getProperty(P_POSTGRE_SQL_NATIVE); try { testNotNative(); @@ -504,6 +520,7 @@ public final class Convert_PostgreSQLTest extends AbstractTestCase { @Test public void test1638046() { + if (DB.isOracle()) return; String originalNative = Ini.getProperty(P_POSTGRE_SQL_NATIVE); try { testNotNative(); @@ -529,6 +546,7 @@ public final class Convert_PostgreSQLTest extends AbstractTestCase { //[ 1727193 ] Convert failed with decode in quoted string @Test public void test1727193() { + if (DB.isOracle()) return; sql = "UPDATE a set a.ten_decode = 'b'"; sqe = "UPDATE a set a.ten_decode = 'b'"; r = DB.getDatabase().convertStatement(sql); @@ -542,6 +560,7 @@ public final class Convert_PostgreSQLTest extends AbstractTestCase { @Test public void testDecode() { + if (DB.isOracle()) return; String originalNative = Ini.getProperty(P_POSTGRE_SQL_NATIVE); try { testNotNative(); @@ -568,6 +587,7 @@ public final class Convert_PostgreSQLTest extends AbstractTestCase { @Test public void test2371805_GetDate() { + if (DB.isOracle()) return; String originalNative = Ini.getProperty(P_POSTGRE_SQL_NATIVE); try { testNotNative(); @@ -590,6 +610,7 @@ public final class Convert_PostgreSQLTest extends AbstractTestCase { */ @Test public void testCasts() { + if (DB.isOracle()) return; String originalNative = Ini.getProperty(P_POSTGRE_SQL_NATIVE); try { testNotNative(); @@ -630,6 +651,7 @@ public final class Convert_PostgreSQLTest extends AbstractTestCase { */ @Test public void test2521586() { + if (DB.isOracle()) return; sql = "INSERT INTO M_Forecast (M_Forecast_ID) VALUES (1000000)"; sqe = "INSERT INTO M_Forecast (M_Forecast_ID) VALUES (1000000)"; r = DB.getDatabase().convertStatement(sql); @@ -643,6 +665,7 @@ public final class Convert_PostgreSQLTest extends AbstractTestCase { @Test public void test3137355() { + if (DB.isOracle()) return; sql = "INSERT INTO MyTable (a, b, c, d, xml) VALUES ('val1', 'val2', 'this ''is'' a string with ''quotes'' and backslashes ''\\''', 'val4')"; sqe = "INSERT INTO MyTable (a, b, c, d, xml) VALUES ('val1', 'val2', E'this ''is'' a string with ''quotes'' and backslashes ''\\\\''', 'val4')"; r = DB.getDatabase().convertStatement(sql); @@ -662,6 +685,7 @@ public final class Convert_PostgreSQLTest extends AbstractTestCase { @Test public void testNativeSysdate() { + if (DB.isOracle()) return; String originalNative = Ini.getProperty(P_POSTGRE_SQL_NATIVE); String originalSimilarTo = Env.getContext(Env.getCtx(), "P|IsUseSimilarTo"); try { diff --git a/org.idempiere.test/src/org/idempiere/test/base/InOutTest.java b/org.idempiere.test/src/org/idempiere/test/base/InOutTest.java index e38d75a128..32ad0feb27 100644 --- a/org.idempiere.test/src/org/idempiere/test/base/InOutTest.java +++ b/org.idempiere.test/src/org/idempiere/test/base/InOutTest.java @@ -198,6 +198,8 @@ public class InOutTest extends AbstractTestCase { } } } finally { + rollback(); + deleteConversionRate(crUsdCompany); deleteConversionRate(crUsdSpot); deleteConversionRate(crEurCompany); @@ -205,9 +207,7 @@ public class InOutTest extends AbstractTestCase { pp.deleteEx(true); plv.deleteEx(true); - priceList.deleteEx(true); - - rollback(); + priceList.deleteEx(true); } } @@ -357,14 +357,13 @@ public class InOutTest extends AbstractTestCase { } } } finally { + rollback(); deleteConversionRate(crUsdCompany); deleteConversionRate(crEurCompany); pp.deleteEx(true); plv.deleteEx(true); - priceList.deleteEx(true); - - rollback(); + priceList.deleteEx(true); } } diff --git a/org.idempiere.test/src/org/idempiere/test/base/MatchInv2ndAcctSchemaTest.java b/org.idempiere.test/src/org/idempiere/test/base/MatchInv2ndAcctSchemaTest.java index 2c39278a22..9d4c9f622f 100644 --- a/org.idempiere.test/src/org/idempiere/test/base/MatchInv2ndAcctSchemaTest.java +++ b/org.idempiere.test/src/org/idempiere/test/base/MatchInv2ndAcctSchemaTest.java @@ -395,6 +395,8 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase { testMatchInvoicePosting(ass, miList, notInvoicedReceiptsLineList, inventoryClearingLineList); } finally { + rollback(); + deleteConversionRate(crUsd1); deleteConversionRate(crUsd2); deleteConversionRate(crEur1); @@ -402,9 +404,7 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase { pp.deleteEx(true); plv.deleteEx(true); - priceList.deleteEx(true); - - rollback(); + priceList.deleteEx(true); } } @@ -1538,14 +1538,13 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase { testMatchInvoicePosting(ass, miList, notInvoicedReceiptsLineList, inventoryClearingLineList); } finally { + rollback(); deleteConversionRate(crUsd); deleteConversionRate(crEur); pp.deleteEx(true); plv.deleteEx(true); - priceList.deleteEx(true); - - rollback(); + priceList.deleteEx(true); } } @@ -1642,13 +1641,13 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase { inventoryClearingLineList2.add(new PostingLine(inventoryClearingLine.currency, inventoryClearingLine.amtAcctCr, inventoryClearingLine.amtAcctDr)); testMatchInvoicePosting(ass, miList0.toArray(miList2), notInvoicedReceiptsLineList2, inventoryClearingLineList2); } finally { + rollback(); deleteConversionRate(crUsd); deleteConversionRate(crEur); pp.deleteEx(true); plv.deleteEx(true); - priceList.deleteEx(true); - rollback(); + priceList.deleteEx(true); } } diff --git a/org.idempiere.test/src/org/idempiere/test/base/MatchInvTest.java b/org.idempiere.test/src/org/idempiere/test/base/MatchInvTest.java index 6c1222ab1e..3a1b41324b 100644 --- a/org.idempiere.test/src/org/idempiere/test/base/MatchInvTest.java +++ b/org.idempiere.test/src/org/idempiere/test/base/MatchInvTest.java @@ -237,9 +237,9 @@ public class MatchInvTest extends AbstractTestCase { for (int id : ids) { MFactAcct fa = new MFactAcct(Env.getCtx(), id, getTrxName()); if (fa.getAccount_ID() == acctNIR.getAccount_ID()) - assertEquals(fa.getAmtAcctCr(), credMatchAmt, "MatchInv incorrect amount posted "+fa.getAmtAcctCr().toPlainString()); + assertEquals(fa.getAmtAcctCr().setScale(2, RoundingMode.HALF_UP), credMatchAmt.setScale(2, RoundingMode.HALF_UP), "MatchInv incorrect amount posted "+fa.getAmtAcctCr().toPlainString()); else if (fa.getAccount_ID() == acctInvClr.getAccount_ID()) - assertEquals(fa.getAmtAcctDr(), credMatchAmt, "MatchInv incorrect amount posted "+fa.getAmtAcctDr().toPlainString()); + assertEquals(fa.getAmtAcctDr().setScale(2, RoundingMode.HALF_UP), credMatchAmt.setScale(2, RoundingMode.HALF_UP), "MatchInv incorrect amount posted "+fa.getAmtAcctDr().toPlainString()); } } @@ -348,9 +348,9 @@ public class MatchInvTest extends AbstractTestCase { for (int id : ids) { MFactAcct fa = new MFactAcct(Env.getCtx(), id, getTrxName()); if (fa.getAccount_ID() == acctNIR.getAccount_ID()) - assertEquals(fa.getAmtAcctDr(), invMatchAmt, "MatchInv incorrect amount posted "+fa.getAmtAcctCr().toPlainString()); + assertEquals(fa.getAmtAcctDr().setScale(2, RoundingMode.HALF_UP), invMatchAmt.setScale(2, RoundingMode.HALF_UP), "MatchInv incorrect amount posted "+fa.getAmtAcctCr().toPlainString()); else if (fa.getAccount_ID() == acctInvClr.getAccount_ID()) - assertEquals(fa.getAmtAcctCr(), invMatchAmt, "MatchInv incorrect amount posted "+fa.getAmtAcctCr().toPlainString()); + assertEquals(fa.getAmtAcctCr().setScale(2, RoundingMode.HALF_UP), invMatchAmt.setScale(2, RoundingMode.HALF_UP), "MatchInv incorrect amount posted "+fa.getAmtAcctCr().toPlainString()); } } @@ -525,11 +525,11 @@ public class MatchInvTest extends AbstractTestCase { for (int id : ids) { MFactAcct fa = new MFactAcct(Env.getCtx(), id, getTrxName()); if (fa.getAccount_ID() == acctNIR.getAccount_ID()) - assertEquals(fa.getAmtAcctDr(), mulchCost, ""); + assertEquals(fa.getAmtAcctDr().setScale(2, RoundingMode.HALF_UP), mulchCost.setScale(2, RoundingMode.HALF_UP), ""); else if (fa.getAccount_ID() == acctInvClr.getAccount_ID()) - assertEquals(fa.getAmtAcctCr(), invMatchAmt, ""); + assertEquals(fa.getAmtAcctCr().setScale(2, RoundingMode.HALF_UP), invMatchAmt.setScale(2, RoundingMode.HALF_UP), ""); else if (fa.getAccount_ID() == acctIPV.getAccount_ID()) - assertEquals(fa.getAmtAcctDr().subtract(fa.getAmtAcctCr()), invMatchAmt.subtract(mulchCost), ""); + assertEquals(fa.getAmtAcctDr().subtract(fa.getAmtAcctCr()).setScale(2, RoundingMode.HALF_UP), invMatchAmt.subtract(mulchCost).setScale(2, RoundingMode.HALF_UP), ""); } } } finally { @@ -647,12 +647,12 @@ public class MatchInvTest extends AbstractTestCase { for (int id : ids) { MFactAcct fa = new MFactAcct(Env.getCtx(), id, getTrxName()); if (fa.getAccount_ID() == acctNIR.getAccount_ID()) { - assertEquals(fa.getAmtAcctDr(), invMatchAmt, "MatchInv incorrect amount posted "+fa.getAmtAcctDr().toPlainString()); + assertEquals(fa.getAmtAcctDr().setScale(2, RoundingMode.HALF_UP), invMatchAmt.setScale(2, RoundingMode.HALF_UP), "MatchInv incorrect amount posted "+fa.getAmtAcctDr().toPlainString()); assertEquals(mi.getQty(), fa.getQty(), "Accounting fact quantity incorrect"); } else if (fa.getAccount_ID() == acctInvClr.getAccount_ID()) { - assertEquals(fa.getAmtAcctCr(), invMatchAmt, "MatchInv incorrect amount posted "+fa.getAmtAcctCr().toPlainString()); - assertEquals(mi.getQty().negate(), fa.getQty(), "Accounting fact quantity incorrect"); + assertEquals(fa.getAmtAcctCr().setScale(2, RoundingMode.HALF_UP), invMatchAmt.setScale(2, RoundingMode.HALF_UP), "MatchInv incorrect amount posted "+fa.getAmtAcctCr().toPlainString()); + assertEquals(mi.getQty().negate().setScale(2, RoundingMode.HALF_UP), fa.getQty().setScale(2, RoundingMode.HALF_UP), "Accounting fact quantity incorrect"); } } } @@ -710,12 +710,12 @@ public class MatchInvTest extends AbstractTestCase { for (int id : ids) { MFactAcct fa = new MFactAcct(Env.getCtx(), id, getTrxName()); if (fa.getAccount_ID() == acctInvClr.getAccount_ID() && fa.getQty().compareTo(BigDecimal.ZERO) < 0) { - assertEquals(fa.getAmtAcctCr(), credMatchAmt, "MatchInv incorrect amount posted "+fa.getAmtAcctCr().toPlainString()); + assertEquals(fa.getAmtAcctCr().setScale(2, RoundingMode.HALF_UP), credMatchAmt.setScale(2, RoundingMode.HALF_UP), "MatchInv incorrect amount posted "+fa.getAmtAcctCr().toPlainString()); amtAcctCrInvClr = amtAcctCrInvClr.add(fa.getAmtAcctCr()); assertEquals(mi.getQty(), fa.getQty(), "Accounting fact quantity incorrect"); } else if (fa.getAccount_ID() == acctInvClr.getAccount_ID() && fa.getQty().compareTo(BigDecimal.ZERO) > 0) { - assertEquals(fa.getAmtAcctDr(), credMatchAmt, "MatchInv incorrect amount posted "+fa.getAmtAcctDr().toPlainString()); + assertEquals(fa.getAmtAcctDr().setScale(2, RoundingMode.HALF_UP), credMatchAmt.setScale(2, RoundingMode.HALF_UP), "MatchInv incorrect amount posted "+fa.getAmtAcctDr().toPlainString()); amtAcctDrInvClr = amtAcctDrInvClr.add(fa.getAmtAcctDr()); assertEquals(mi.getQty().negate(), fa.getQty(), "Accounting fact quantity incorrect"); } @@ -889,6 +889,7 @@ public class MatchInvTest extends AbstractTestCase { } } } finally { + rollback(); String whereClause = "ValidFrom=? AND ValidTo=? " + "AND C_Currency_ID=? AND C_Currency_ID_To=? " + "AND C_ConversionType_ID=? " @@ -915,8 +916,7 @@ public class MatchInvTest extends AbstractTestCase { pp.deleteEx(true); plv.deleteEx(true); - priceList.deleteEx(true); - rollback(); + priceList.deleteEx(true); } } @@ -1238,16 +1238,16 @@ public class MatchInvTest extends AbstractTestCase { MFactAcct fa = new MFactAcct(Env.getCtx(), id, getTrxName()); if (fa.getAccount_ID() == acctNIR.getAccount_ID()) { if (mi.isReversal()) - assertEquals(fa.getAmtAcctCr(), invMatchAmt, "MatchInv incorrect amount posted "); + assertEquals(fa.getAmtAcctCr().setScale(2, RoundingMode.HALF_UP), invMatchAmt.setScale(2, RoundingMode.HALF_UP), "MatchInv incorrect amount posted "); else - assertEquals(fa.getAmtAcctDr(), invMatchAmt, "MatchInv incorrect amount posted "); + assertEquals(fa.getAmtAcctDr().setScale(2, RoundingMode.HALF_UP), invMatchAmt.setScale(2, RoundingMode.HALF_UP), "MatchInv incorrect amount posted "); assertEquals(mi.getQty(), fa.getQty(), "Accounting fact quantity incorrect"); } else if (fa.getAccount_ID() == acctInvClr.getAccount_ID()) { if (mi.isReversal()) - assertEquals(fa.getAmtAcctDr(), invMatchAmt, "MatchInv incorrect amount posted "); + assertEquals(fa.getAmtAcctDr().setScale(2, RoundingMode.HALF_UP), invMatchAmt.setScale(2, RoundingMode.HALF_UP), "MatchInv incorrect amount posted "); else - assertEquals(fa.getAmtAcctCr(), invMatchAmt, "MatchInv incorrect amount posted "); + assertEquals(fa.getAmtAcctCr().setScale(2, RoundingMode.HALF_UP), invMatchAmt.setScale(2, RoundingMode.HALF_UP), "MatchInv incorrect amount posted "); assertEquals(mi.getQty().negate(), fa.getQty(), "Accounting fact quantity incorrect"); } } diff --git a/org.idempiere.test/src/org/idempiere/test/base/POTest.java b/org.idempiere.test/src/org/idempiere/test/base/POTest.java index 7f117ec417..f5045d3cb2 100644 --- a/org.idempiere.test/src/org/idempiere/test/base/POTest.java +++ b/org.idempiere.test/src/org/idempiere/test/base/POTest.java @@ -349,6 +349,12 @@ public class POTest extends AbstractTestCase //test update with default optimistic locking using updated timestamp bp1.set_UseOptimisticLocking(true); bp1.setDescription("bp1"); + if (DB.isOracle()) { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + } + } updated = bp1.save(); assertTrue(updated); @@ -418,6 +424,12 @@ public class POTest extends AbstractTestCase //test delete with default optimistic locking MMessage msg2 = new MMessage(Env.getCtx(), msg1.getAD_Message_ID(), getTrxName()); msg1.setMsgText("msg 1.1 test"); + if (DB.isOracle()) { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + } + } msg1.saveEx(); msg2.set_UseOptimisticLocking(true); diff --git a/org.idempiere.test/src/org/idempiere/test/base/QueryTest.java b/org.idempiere.test/src/org/idempiere/test/base/QueryTest.java index 5ff9eaf6d4..85756f3b4a 100644 --- a/org.idempiere.test/src/org/idempiere/test/base/QueryTest.java +++ b/org.idempiere.test/src/org/idempiere/test/base/QueryTest.java @@ -405,7 +405,7 @@ public class QueryTest extends AbstractTestCase { testPo = query.setParameters(testPo.get_ID()).first(); I_Test testRecord = POWrapper.create(testPo, I_Test.class); assertTrue(null == testPo.get_ValueOld(MTest.COLUMNNAME_TestVirtualQty)); - assertEquals(expected, testRecord.getTestVirtualQty().setScale(2, RoundingMode.HALF_UP), "Wrong value returned"); + assertEquals(expected.setScale(2, RoundingMode.HALF_UP), testRecord.getTestVirtualQty().setScale(2, RoundingMode.HALF_UP), "Wrong value returned"); // without virtual column lazy loading testPo = query.setNoVirtualColumn(false).setParameters(testPo.get_ID()).first(); diff --git a/org.idempiere.test/src/org/idempiere/test/model/AllocationTest.java b/org.idempiere.test/src/org/idempiere/test/model/AllocationTest.java index 73d71dab06..fbdb94582b 100644 --- a/org.idempiere.test/src/org/idempiere/test/model/AllocationTest.java +++ b/org.idempiere.test/src/org/idempiere/test/model/AllocationTest.java @@ -654,8 +654,8 @@ public class AllocationTest extends AbstractTestCase { int taxid = DictionaryIDs.C_Tax.CT_SALES.id; // (CT Sales, Rate 6) MInvoice invoice = createInvoice(true,false, date, date, bpartner.getC_BPartner_ID(), payterm, taxid, Env.ONEHUNDRED); - assertEquals(invoice.getTotalLines(), new BigDecimal("100.0")); - assertEquals(invoice.getGrandTotal(), new BigDecimal("106.00")); + assertEquals(invoice.getTotalLines().setScale(2, RoundingMode.HALF_UP), new BigDecimal("100.00")); + assertEquals(invoice.getGrandTotal().setScale(2, RoundingMode.HALF_UP), new BigDecimal("106.00")); // Payamt with discount BigDecimal payAmt = new BigDecimal("102"); @@ -785,8 +785,8 @@ public class AllocationTest extends AbstractTestCase { int taxid = DictionaryIDs.C_Tax.CT_SALES.id; // (CT Sales, Rate 6) MInvoice invoice = createInvoice(true, true, date, date, bpartner.getC_BPartner_ID(), payterm, taxid, Env.ONEHUNDRED); - assertEquals(invoice.getTotalLines(), new BigDecimal("100.0")); - assertEquals(invoice.getGrandTotal(), new BigDecimal("106.00")); + assertEquals(invoice.getTotalLines().setScale(2, RoundingMode.HALF_UP), new BigDecimal("100.00")); + assertEquals(invoice.getGrandTotal().setScale(2, RoundingMode.HALF_UP), new BigDecimal("106.00")); // Payamt with discount BigDecimal payAmt = new BigDecimal("102"); @@ -915,8 +915,8 @@ public class AllocationTest extends AbstractTestCase { int taxid = DictionaryIDs.C_Tax.CT_SALES.id; // (CT Sales, Rate 6) MInvoice invoice = createInvoice(false, false, date, date, bpartner.getC_BPartner_ID(), payterm, taxid, Env.ONEHUNDRED); - assertEquals(invoice.getTotalLines(), new BigDecimal("100.0")); - assertEquals(invoice.getGrandTotal(), new BigDecimal("106.00")); + assertEquals(invoice.getTotalLines().setScale(2, RoundingMode.HALF_UP), new BigDecimal("100.00")); + assertEquals(invoice.getGrandTotal().setScale(2, RoundingMode.HALF_UP), new BigDecimal("106.00")); // Payamt with discount BigDecimal payAmt = new BigDecimal("102"); @@ -1045,8 +1045,8 @@ public class AllocationTest extends AbstractTestCase { int taxid = DictionaryIDs.C_Tax.CT_SALES.id; // (CT Sales, Rate 6) MInvoice invoice = createInvoice(false, true, date, date, bpartner.getC_BPartner_ID(), payterm, taxid, Env.ONEHUNDRED); - assertEquals(invoice.getTotalLines(), new BigDecimal("100.0")); - assertEquals(invoice.getGrandTotal(), new BigDecimal("106.00")); + assertEquals(invoice.getTotalLines().setScale(2, RoundingMode.HALF_UP), new BigDecimal("100.00")); + assertEquals(invoice.getGrandTotal().setScale(2, RoundingMode.HALF_UP), new BigDecimal("106.00")); // Payamt with discount BigDecimal payAmt = new BigDecimal("102"); @@ -1175,8 +1175,8 @@ public class AllocationTest extends AbstractTestCase { int taxid = DictionaryIDs.C_Tax.CT_SALES.id; // (CT Sales, Rate 6) MInvoice invoice = createInvoice(true,false, date, date, bpartner.getC_BPartner_ID(), payterm, taxid, Env.ONEHUNDRED); - assertEquals(invoice.getTotalLines(), new BigDecimal("100.0")); - assertEquals(invoice.getGrandTotal(), new BigDecimal("106.00")); + assertEquals(invoice.getTotalLines().setScale(2, RoundingMode.HALF_UP), new BigDecimal("100.00")); + assertEquals(invoice.getGrandTotal().setScale(2, RoundingMode.HALF_UP), new BigDecimal("106.00")); // Payamt with discount BigDecimal payAmt = new BigDecimal("102"); @@ -1307,8 +1307,8 @@ public class AllocationTest extends AbstractTestCase { int taxid = DictionaryIDs.C_Tax.CT_SALES.id; // (CT Sales, Rate 6) MInvoice invoice = createInvoice(true, true, date, date, bpartner.getC_BPartner_ID(), payterm, taxid, Env.ONEHUNDRED); - assertEquals(invoice.getTotalLines(), new BigDecimal("100.0")); - assertEquals(invoice.getGrandTotal(), new BigDecimal("106.00")); + assertEquals(invoice.getTotalLines().setScale(2, RoundingMode.HALF_UP), new BigDecimal("100.00")); + assertEquals(invoice.getGrandTotal().setScale(2, RoundingMode.HALF_UP), new BigDecimal("106.00")); // Payamt with discount BigDecimal payAmt = new BigDecimal("102").negate(); @@ -1438,8 +1438,8 @@ public class AllocationTest extends AbstractTestCase { int taxid = DictionaryIDs.C_Tax.CT_SALES.id; // (CT Sales, Rate 6) MInvoice invoice = createInvoice(false, false, date, date, bpartner.getC_BPartner_ID(), payterm, taxid, Env.ONEHUNDRED); - assertEquals(invoice.getTotalLines(), new BigDecimal("100.0")); - assertEquals(invoice.getGrandTotal(), new BigDecimal("106.00")); + assertEquals(invoice.getTotalLines().setScale(2, RoundingMode.HALF_UP), new BigDecimal("100.00")); + assertEquals(invoice.getGrandTotal().setScale(2, RoundingMode.HALF_UP), new BigDecimal("106.00")); BigDecimal payAmt = new BigDecimal("102"); @@ -1569,8 +1569,8 @@ public class AllocationTest extends AbstractTestCase { int taxid = DictionaryIDs.C_Tax.CT_SALES.id; // (CT Sales, Rate 6) MInvoice invoice = createInvoice(false, true, date, date, bpartner.getC_BPartner_ID(), payterm, taxid, Env.ONEHUNDRED); - assertEquals(invoice.getTotalLines(), new BigDecimal("100.0")); - assertEquals(invoice.getGrandTotal(), new BigDecimal("106.00")); + assertEquals(invoice.getTotalLines().setScale(2, RoundingMode.HALF_UP), new BigDecimal("100.00")); + assertEquals(invoice.getGrandTotal().setScale(2, RoundingMode.HALF_UP), new BigDecimal("106.00")); // Payamt with discount BigDecimal payAmt = new BigDecimal("102").negate(); @@ -1700,14 +1700,14 @@ public class AllocationTest extends AbstractTestCase { int taxid = DictionaryIDs.C_Tax.CT_SALES.id; // (CT Sales, Rate 6) MInvoice invoice = createInvoice(true,false, date, date, bpartner.getC_BPartner_ID(), payterm, taxid, Env.ONEHUNDRED); - assertEquals(invoice.getTotalLines(), new BigDecimal("100.0")); - assertEquals(invoice.getGrandTotal(), new BigDecimal("106.00")); + assertEquals(invoice.getTotalLines().setScale(2, RoundingMode.HALF_UP), new BigDecimal("100.00")); + assertEquals(invoice.getGrandTotal().setScale(2, RoundingMode.HALF_UP), new BigDecimal("106.00")); int paytermcm = DictionaryIDs.C_PaymentTerm.IMMEDIATE.id; MInvoice creditmemo = createInvoice(true,true, date, date, bpartner.getC_BPartner_ID(), paytermcm, taxid, new BigDecimal("96.23")); - assertEquals(creditmemo.getTotalLines(), new BigDecimal("96.23")); - assertEquals(creditmemo.getGrandTotal(), new BigDecimal("102.00")); + assertEquals(creditmemo.getTotalLines().setScale(2, RoundingMode.HALF_UP), new BigDecimal("96.23")); + assertEquals(creditmemo.getGrandTotal().setScale(2, RoundingMode.HALF_UP), new BigDecimal("102.00")); MAllocationHdr alloc = new MAllocationHdr(Env.getCtx(), true, date, usd.getC_Currency_ID(), Env.getContext(Env.getCtx(), "#AD_User_Name"), getTrxName()); alloc.setAD_Org_ID(invoice.getAD_Org_ID()); @@ -1837,14 +1837,14 @@ public class AllocationTest extends AbstractTestCase { int taxid = DictionaryIDs.C_Tax.CT_SALES.id; // (CT Sales, Rate 6) MInvoice invoice = createInvoice(false, false, date, date, bpartner.getC_BPartner_ID(), payterm, taxid, Env.ONEHUNDRED); - assertEquals(invoice.getTotalLines(), new BigDecimal("100.0")); - assertEquals(invoice.getGrandTotal(), new BigDecimal("106.00")); + assertEquals(invoice.getTotalLines().setScale(2, RoundingMode.HALF_UP), new BigDecimal("100.00")); + assertEquals(invoice.getGrandTotal().setScale(2, RoundingMode.HALF_UP), new BigDecimal("106.00")); int paytermcm = DictionaryIDs.C_PaymentTerm.IMMEDIATE.id; MInvoice creditmemo = createInvoice(false,true, date, date, bpartner.getC_BPartner_ID(), paytermcm, taxid, new BigDecimal("96.23")); - assertEquals(creditmemo.getTotalLines(), new BigDecimal("96.23")); - assertEquals(creditmemo.getGrandTotal(), new BigDecimal("102.00")); + assertEquals(creditmemo.getTotalLines().setScale(2, RoundingMode.HALF_UP), new BigDecimal("96.23")); + assertEquals(creditmemo.getGrandTotal().setScale(2, RoundingMode.HALF_UP), new BigDecimal("102.00")); MAllocationHdr alloc = new MAllocationHdr(Env.getCtx(), true, date, usd.getC_Currency_ID(), Env.getContext(Env.getCtx(), "#AD_User_Name"), getTrxName()); diff --git a/org.idempiere.test/src/org/idempiere/test/model/InventoryTest.java b/org.idempiere.test/src/org/idempiere/test/model/InventoryTest.java index 4da2c3e72d..02f14c1c79 100644 --- a/org.idempiere.test/src/org/idempiere/test/model/InventoryTest.java +++ b/org.idempiere.test/src/org/idempiere/test/model/InventoryTest.java @@ -255,7 +255,7 @@ public class InventoryTest extends AbstractTestCase { Env.ZERO); iline.saveEx(); - //show error out with negative on hand (skip the only asi record with serno) + //should error out with negative on hand (skip the only asi record with serno) ProcessInfo info = MWorkflow.runDocumentActionWorkflow(inventory, DocAction.ACTION_Complete); assertTrue(info.isError(), info.getSummary()); } finally { diff --git a/org.idempiere.test/src/org/idempiere/test/model/MDiscountSchemaTest.java b/org.idempiere.test/src/org/idempiere/test/model/MDiscountSchemaTest.java index 5769aab2c1..da69ad3b7f 100644 --- a/org.idempiere.test/src/org/idempiere/test/model/MDiscountSchemaTest.java +++ b/org.idempiere.test/src/org/idempiere/test/model/MDiscountSchemaTest.java @@ -134,6 +134,7 @@ public class MDiscountSchemaTest extends AbstractTestCase { assertEquals(fixedPrice, line1.getPriceActual().setScale(2, RoundingMode.HALF_UP), "Unexpected Order Line price"); } finally { + rollback(); if (discountBreak != null && discountBreak.get_ID() > 0) discountBreak.deleteEx(true); } diff --git a/org.idempiere.test/src/org/idempiere/test/model/MInfoWindowTest.java b/org.idempiere.test/src/org/idempiere/test/model/MInfoWindowTest.java index 84e121e7c7..14d27503f7 100644 --- a/org.idempiere.test/src/org/idempiere/test/model/MInfoWindowTest.java +++ b/org.idempiere.test/src/org/idempiere/test/model/MInfoWindowTest.java @@ -151,6 +151,7 @@ public class MInfoWindowTest extends AbstractTestCase { assertNotNull(infoColumns); assertEquals(1, infoColumns.length); } finally { + rollback(); ca.deleteEx(true); } } diff --git a/org.idempiere.test/src/org/idempiere/test/model/MProductTest.java b/org.idempiere.test/src/org/idempiere/test/model/MProductTest.java index 4347f26d99..7a9652e7f5 100644 --- a/org.idempiere.test/src/org/idempiere/test/model/MProductTest.java +++ b/org.idempiere.test/src/org/idempiere/test/model/MProductTest.java @@ -236,7 +236,8 @@ public class MProductTest extends AbstractTestCase { @Test public void testDeactivateProductBOMValidation() { - Query query = new Query(Env.getCtx(), MPPProductBOM.Table_Name, MPPProductBOM.COLUMNNAME_PP_Product_BOM_ID+"<1000000", getTrxName()); + Query query = new Query(Env.getCtx(), MPPProductBOM.Table_Name, MPPProductBOM.COLUMNNAME_PP_Product_BOM_ID+"<1000000" + + " AND M_Product_ID NOT IN (SELECT M_Product_ID FROM PP_Product_BOMLine)", getTrxName()); MPPProductBOM bom = query.setClient_ID().setOnlyActiveRecords(true).first(); MPPProductBOMLine[] lines = bom.getLines(); final MProduct product = new MProduct(Env.getCtx(), lines[0].getM_Product_ID(), getTrxName()); diff --git a/org.idempiere.test/src/org/idempiere/test/model/MSchedulerTest.java b/org.idempiere.test/src/org/idempiere/test/model/MSchedulerTest.java index 3708d9945d..09f45a9d64 100644 --- a/org.idempiere.test/src/org/idempiere/test/model/MSchedulerTest.java +++ b/org.idempiere.test/src/org/idempiere/test/model/MSchedulerTest.java @@ -141,6 +141,7 @@ public class MSchedulerTest extends AbstractTestCase { assertEquals(formatter2.format(cal2.getTime().toInstant()), formatter2.format(ts2.toInstant()), "Un-expected date next run"); assertFalse(cal1.getTimeInMillis() == ts2.getTime(), "Un-expected date next run"); } finally { + rollback(); if (schedule != null && schedule.get_ID() > 0) schedule.deleteEx(true); clientInfo.setTimeZone(currentTimeZone); diff --git a/org.idempiere.test/src/org/idempiere/test/model/MStorageOnHandTest.java b/org.idempiere.test/src/org/idempiere/test/model/MStorageOnHandTest.java index aae5447da8..7928704a07 100644 --- a/org.idempiere.test/src/org/idempiere/test/model/MStorageOnHandTest.java +++ b/org.idempiere.test/src/org/idempiere/test/model/MStorageOnHandTest.java @@ -149,6 +149,7 @@ public class MStorageOnHandTest extends AbstractTestCase { as.saveEx(); } } finally { + rollback(); product.deleteEx(true); } } diff --git a/org.idempiere.test/src/org/idempiere/test/model/MUOMConversionTest.java b/org.idempiere.test/src/org/idempiere/test/model/MUOMConversionTest.java index d8976add94..6fa3267f54 100644 --- a/org.idempiere.test/src/org/idempiere/test/model/MUOMConversionTest.java +++ b/org.idempiere.test/src/org/idempiere/test/model/MUOMConversionTest.java @@ -126,6 +126,7 @@ public class MUOMConversionTest extends AbstractTestCase { converted = MUOMConversion.convertProductFrom(Env.getCtx(), DictionaryIDs.M_Product.OAK.id, DictionaryIDs.C_UOM.HOUR.id, new BigDecimal("1"), 1); assertEquals(conv1.getDivideRate().setScale(1, RoundingMode.HALF_UP), converted); } finally { + rollback(); DB.executeUpdateEx("DELETE FROM C_UOM_Conversion WHERE C_UOM_Conversion_ID=?", new Object[] {conv1.get_ID()}, null); if (conv2 != null) conv2.deleteEx(true); diff --git a/org.idempiere.test/src/org/idempiere/test/model/ModelClassMappingTest.java b/org.idempiere.test/src/org/idempiere/test/model/ModelClassMappingTest.java index f9b52ce0db..75ce9ee9d0 100644 --- a/org.idempiere.test/src/org/idempiere/test/model/ModelClassMappingTest.java +++ b/org.idempiere.test/src/org/idempiere/test/model/ModelClassMappingTest.java @@ -70,11 +70,13 @@ public class ModelClassMappingTest extends AbstractTestCase { @Test public void testModelClassMappingForCoreTables() { Query query = new Query(Env.getCtx(), MTable.Table_Name, "IsView='N' AND EntityType IN ('D','EE01','EE02','EE04','EE05') " - + "AND TableName NOT Like 'I\\_%' AND TableName NOT Like 'T\\_%' AND TableName NOT Like 'W\\_%'" - + "AND TableName NOT Like '%\\_Trl'", getTrxName()); + + "AND TableName NOT Like 'I!_%' ESCAPE '!' AND TableName NOT Like 'T!_%' ESCAPE '!' AND TableName NOT Like 'W!_%' ESCAPE '!' " + + "AND TableName NOT Like '%!_Trl' ESCAPE '!'", getTrxName()); List> references = Service.locator().list(IModelFactory.class).getServiceReferences(); List tables = query.setOnlyActiveRecords(true).setOrderBy("TableName").list(); for(MTable table : tables) { + if (table.getTableName().endsWith("_Trl")) + continue; Class clazz = null; for(IServiceReferenceHolder reference : references) { IModelFactory service = reference.getService(); diff --git a/org.idempiere.test/src/org/idempiere/test/model/ProcessTest.java b/org.idempiere.test/src/org/idempiere/test/model/ProcessTest.java index ec7c27f1cc..0706738f9b 100644 --- a/org.idempiere.test/src/org/idempiere/test/model/ProcessTest.java +++ b/org.idempiere.test/src/org/idempiere/test/model/ProcessTest.java @@ -273,7 +273,8 @@ public class ProcessTest extends AbstractTestCase { inout.load(getTrxName()); assertEquals(DocAction.STATUS_Completed, inout.getDocStatus(), "Expected Completed Status for Shipment"); - } finally { + } finally { + rollback(); docCompleteNodeNext.deleteEx(true); processNodePara.deleteEx(true); processNode.deleteEx(true); diff --git a/org.idempiere.test/src/org/idempiere/test/model/ProductionTest.java b/org.idempiere.test/src/org/idempiere/test/model/ProductionTest.java index 2e31a32ccb..5e8b45c02c 100644 --- a/org.idempiere.test/src/org/idempiere/test/model/ProductionTest.java +++ b/org.idempiere.test/src/org/idempiere/test/model/ProductionTest.java @@ -370,7 +370,7 @@ public class ProductionTest extends AbstractTestCase { break; } BigDecimal varianceExpected = componentCost.subtract(endProductCost).setScale(as.getStdPrecision(), RoundingMode.HALF_UP); - assertEquals(varianceExpected, variance, "Variance not posted correctly."); + assertEquals(varianceExpected.setScale(2, RoundingMode.HALF_UP), variance.setScale(2, RoundingMode.HALF_UP), "Variance not posted correctly."); } finally { getTrx().rollback(); mulch.setM_Product_Category_ID(categorySaveId);