details:   https://code.openbravo.com/erp/devel/pi/rev/a14df06b6122
changeset: 27518:a14df06b6122
user:      Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
date:      Wed Sep 02 13:45:19 2015 +0200
summary:   Fixes issue 30679: Improve orderby in 
CostAdjustmentProcess.getNextLine query

details:   https://code.openbravo.com/erp/devel/pi/rev/9c0a20844216
changeset: 27519:9c0a20844216
user:      Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
date:      Wed Sep 02 13:46:53 2015 +0200
summary:   Fixes issue 30679: Improve orderby in 
LandedCostProcess.generateCostAdjustment query

details:   https://code.openbravo.com/erp/devel/pi/rev/9054fa451525
changeset: 27520:9054fa451525
user:      Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
date:      Wed Aug 26 20:06:13 2015 +0200
summary:   Related to issue 30679: Change order of cost adjustments assert in 
LC101LC201 test

details:   https://code.openbravo.com/erp/devel/pi/rev/1fc3c80992d5
changeset: 27521:1fc3c80992d5
user:      Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
date:      Wed Aug 12 20:50:50 2015 +0200
summary:   Fixes issue 28625 & Fixes issue 29274: Update TestCosting tests

Once dependency injection is supported in junit tests, "Costing Background 
process" and "Price Correction Background" processes will be directly called in 
TestCosting tests.
Other requests will also be avoided, calling private methods directly, using 
Reflection.

details:   https://code.openbravo.com/erp/devel/pi/rev/406116e8b8a0
changeset: 27522:406116e8b8a0
user:      Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
date:      Tue Aug 18 11:44:51 2015 +0200
summary:   Related to issue 28625: Update product names in TestCosting tests

Update how products are created in TestCosting tests to add test name info to 
product name.

details:   https://code.openbravo.com/erp/devel/pi/rev/13ff36fdab84
changeset: 27523:13ff36fdab84
user:      Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
date:      Thu Aug 27 19:04:20 2015 +0200
summary:   Related to issue 28625: Update some result orders in TestCosting 
tests

details:   https://code.openbravo.com/erp/devel/pi/rev/913c065da93c
changeset: 27524:913c065da93c
user:      Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
date:      Mon Aug 31 08:21:25 2015 +0200
summary:   Related to issue 28625: Add sleeps to R22 and F2 tests to avoid 
assert errors

details:   https://code.openbravo.com/erp/devel/pi/rev/b2ff13290c94
changeset: 27525:b2ff13290c94
user:      Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
date:      Thu Sep 03 17:50:53 2015 +0200
summary:   Related to issue 28625: Fix how Costing Rule is created in 
TestCosting

details:   https://code.openbravo.com/erp/devel/pi/rev/b24e4b703e4e
changeset: 27526:b24e4b703e4e
user:      Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
date:      Sun Aug 30 21:06:28 2015 +0200
summary:   Fixes issue 30557: Error in TestCosting when it is executed at 
midnight

Today variable has been replaced with new Date() to get the current date and 
not the date when the test suite starts.
FormatDate will be used in date asserts where it was not.
Creation and Updated date asserts have been removed.

details:   https://code.openbravo.com/erp/devel/pi/rev/d61c48c1ba81
changeset: 27527:d61c48c1ba81
user:      Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
date:      Sun Aug 30 21:07:43 2015 +0200
summary:   Related to issue 30557: Replace amount0 variable with BigDecimal.ZERO

details:   https://code.openbravo.com/erp/devel/pi/rev/d824566905ac
changeset: 27528:d824566905ac
user:      Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
date:      Tue Sep 01 11:09:05 2015 +0200
summary:   Fixes bug 30710: getCostDimensionRule doesn't check if CostingRule 
is validated

Validated = true where clause was located after order by clause instead of 
before it.

diffstat:

 src-test/src/org/openbravo/test/AllAntTaskTests.java     |     4 +
 src-test/src/org/openbravo/test/AllWebserviceTests.java  |     2 -
 src-test/src/org/openbravo/test/costing/TestCosting.java |  1783 +++++++------
 src/org/openbravo/costing/CostAdjustmentProcess.java     |     4 +-
 src/org/openbravo/costing/CostingUtils.java              |     2 +-
 src/org/openbravo/costing/LandedCostProcess.java         |    18 +-
 src/org/openbravo/costing/PriceDifferenceBackground.java |     1 +
 7 files changed, 926 insertions(+), 888 deletions(-)

diffs (truncated from 4155 to 300 lines):

diff -r d1bbb069344c -r d824566905ac 
src-test/src/org/openbravo/test/AllAntTaskTests.java
--- a/src-test/src/org/openbravo/test/AllAntTaskTests.java      Thu Sep 03 
21:46:24 2015 +0000
+++ b/src-test/src/org/openbravo/test/AllAntTaskTests.java      Tue Sep 01 
11:09:05 2015 +0200
@@ -35,6 +35,7 @@
 import org.openbravo.erpCommon.info.ClassicSelectorTest;
 import org.openbravo.test.accounting.PostDocumentTest;
 import org.openbravo.test.accounting.RecordID2Test;
+import org.openbravo.test.costing.TestCosting;
 import org.openbravo.test.dal.AdminContextTest;
 import org.openbravo.test.dal.ComputedColumnsTest;
 import org.openbravo.test.dal.DalComplexQueryRequisitionTest;
@@ -176,6 +177,9 @@
     // Taxes
     TaxesTest.class, //
 
+    // costing
+    TestCosting.class, //
+
     // scheduling
     ProcessSchedulingTest.class, //
 
diff -r d1bbb069344c -r d824566905ac 
src-test/src/org/openbravo/test/AllWebserviceTests.java
--- a/src-test/src/org/openbravo/test/AllWebserviceTests.java   Thu Sep 03 
21:46:24 2015 +0000
+++ b/src-test/src/org/openbravo/test/AllWebserviceTests.java   Tue Sep 01 
11:09:05 2015 +0200
@@ -21,7 +21,6 @@
 
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
-import org.openbravo.test.costing.TestCosting;
 import org.openbravo.test.datasource.ExtendedNavigationModelTest;
 import org.openbravo.test.datasource.FICTest;
 import org.openbravo.test.datasource.FKDropDownDatasource;
@@ -62,7 +61,6 @@
     HQLDataSourceTest.class, //
     TestAllowUnpagedDatasourcePreference.class, //
     TestNoteDatasource.class, //
-    TestCosting.class, //
     WebServicesWithNoActiveFilterTest.class, //
     ExtendedNavigationModelTest.class })
 public class AllWebserviceTests {
diff -r d1bbb069344c -r d824566905ac 
src-test/src/org/openbravo/test/costing/TestCosting.java
--- a/src-test/src/org/openbravo/test/costing/TestCosting.java  Thu Sep 03 
21:46:24 2015 +0000
+++ b/src-test/src/org/openbravo/test/costing/TestCosting.java  Tue Sep 01 
11:09:05 2015 +0200
@@ -23,6 +23,7 @@
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
+import java.lang.reflect.Method;
 import java.math.BigDecimal;
 import java.sql.Connection;
 import java.text.SimpleDateFormat;
@@ -35,6 +36,7 @@
 import java.util.Map;
 
 import org.apache.commons.lang.time.DateUtils;
+import org.codehaus.jettison.json.JSONObject;
 import org.hibernate.Query;
 import org.hibernate.criterion.Restrictions;
 import org.junit.AfterClass;
@@ -44,7 +46,18 @@
 import org.openbravo.base.provider.OBProvider;
 import org.openbravo.base.secureApp.VariablesSecureApp;
 import org.openbravo.base.structure.BaseOBObject;
+import org.openbravo.base.weld.test.WeldBaseTest;
+import org.openbravo.costing.CancelCostAdjustment;
+import org.openbravo.costing.CostingBackground;
 import org.openbravo.costing.CostingRuleProcess;
+import org.openbravo.costing.InventoryAmountUpdateProcess;
+import org.openbravo.costing.LCCostMatchFromInvoiceHandler;
+import org.openbravo.costing.LCMatchingCancelHandler;
+import org.openbravo.costing.LCMatchingProcessHandler;
+import org.openbravo.costing.LandedCostProcessHandler;
+import org.openbravo.costing.ManualCostAdjustmentProcessHandler;
+import org.openbravo.costing.PriceDifferenceBackground;
+import org.openbravo.costing.ReactivateLandedCost;
 import org.openbravo.dal.core.DalUtil;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBCriteria;
@@ -58,8 +71,6 @@
 import org.openbravo.model.ad.process.ProcessInstance;
 import org.openbravo.model.ad.system.Client;
 import org.openbravo.model.ad.ui.Process;
-import org.openbravo.model.ad.ui.ProcessRequest;
-import org.openbravo.model.ad.ui.ProcessRun;
 import org.openbravo.model.ad.utility.Sequence;
 import org.openbravo.model.common.businesspartner.BusinessPartner;
 import org.openbravo.model.common.currency.ConversionRate;
@@ -88,6 +99,7 @@
 import org.openbravo.model.materialmgmt.cost.CostAdjustment;
 import org.openbravo.model.materialmgmt.cost.CostAdjustmentLine;
 import org.openbravo.model.materialmgmt.cost.Costing;
+import org.openbravo.model.materialmgmt.cost.CostingAlgorithm;
 import org.openbravo.model.materialmgmt.cost.CostingRule;
 import org.openbravo.model.materialmgmt.cost.InventoryAmountUpdate;
 import org.openbravo.model.materialmgmt.cost.InventoryAmountUpdateLine;
@@ -114,7 +126,6 @@
 import org.openbravo.scheduling.ProcessBundle;
 import org.openbravo.service.db.CallStoredProcedure;
 import org.openbravo.service.db.DalConnectionProvider;
-import org.openbravo.test.datasource.BaseDataSourceTestDal;
 
 /**
  * Test cases to verify Cost Adjustment Project
@@ -122,7 +133,7 @@
  * @author aferraz
  */
 
-public class TestCosting extends BaseDataSourceTestDal {
+public class TestCosting extends WeldBaseTest {
 
   // User System
   private static String USERADMIN_ID = "0";
@@ -138,8 +149,6 @@
   private static String WAREHOUSE1_ID = "4028E6C72959682B01295ECFEF4502A0";
   // Warehouse with name: Spain East warehouse
   private static String WAREHOUSE2_ID = "4D7B97565A024DB7B4C61650FA2B9560";
-  // Language English (USA)
-  private static String LANGUAGE_ID = "192";
 
   // Document Sequence with name: DocumentNo_M_InOut
   private static String SHIPMENTIN_SEQUENCE_ID = 
"910E14E8BA4A419B92DF9973ACDB8A8F";
@@ -169,10 +178,6 @@
   private static String LANDEDCOSTCOST_DOCUMENTTYPE_ID = 
"F66B960D26C64215B1F4A09C3417FB16";
   // Landed Cost Distribution Algorithm with name: Distribution by Amount
   private static String LANDEDCOSTCOST_ALGORITHM_ID = 
"CF9B55BD159B474A9F79849C48715540";
-  // Process request with name: Costing Background process
-  private static String COSTING_PROCESSREQUEST_ID = 
"502EF7AF73264B9B8F76A1AAA4BE8887";
-  // Process request with name: Price Correction Background
-  private static String PRICECORRECTION_PROCESSREQUEST_ID = 
"B1274EEAEF1E4A069C1F6A65B9B06652";
   // Process with name: Validate Costing Rule
   private static String VALIDATECOSTINGRULE_PROCESS_ID = 
"A269DCA4DE114E438695B66E166999B4";
   // Process with name: Verify BOM
@@ -191,6 +196,8 @@
   private static String LANDEDCOSTTYPE3_ID = 
"CB473A64934B4D1583008D52DD0FBC49";
   // Business partner with name: Vendor USA
   private static String BUSINESSPARTNER_ID = 
"C8AD0EAF3052415BB1E15EFDEFBFD4AF";
+  // Costing Algorithm with name: Average Algorithm
+  private static String COSTINGALGORITHM_ID = 
"B069080A0AE149A79CF1FA0E24F16AB6";
   // General Ledger Configuration with name: Main US/A/Euro
   private static String GENERALLEDGER_ID = "9A68A0F8D72D4580B3EC3CAA00A5E1F0";
   // Table with name: MaterialMgmtInternalConsumption
@@ -219,11 +226,6 @@
   // Goods Shipment with documentNo: 500014
   private static String MOVEMENTOUT_ID = "2BCCC64DA82A48C3976B4D007315C2C9";
 
-  // Today's date
-  static final Date today = new Date();
-  // Amount 0
-  final BigDecimal amount0 = BigDecimal.ZERO;
-
   /********************************************** Automated tests 
**********************************************/
 
   @BeforeClass
@@ -281,32 +283,21 @@
 
       OBDal.getInstance().flush();
 
-      // Change Openbravo profile
-      new TestCosting().changeProfile(ROLE_ID, LANGUAGE_ID, ORGANIZATION_ID, 
WAREHOUSE1_ID);
-
       // Create costing rule
-      final OBCriteria<CostingRule> criteria2 = 
OBDal.getInstance().createCriteria(
-          CostingRule.class);
-      criteria2.add(Restrictions.eq(CostingRule.PROPERTY_CLIENT,
-          OBDal.getInstance().get(Client.class, CLIENT_ID)));
-      criteria2.add(Restrictions.eq(CostingRule.PROPERTY_ORGANIZATION,
-          OBDal.getInstance().get(Organization.class, ORGANIZATION_ID)));
-      criteria2.addOrderBy(CostingRule.PROPERTY_CREATIONDATE, true);
-      criteria2.setFilterOnActive(false);
-      criteria2.setFilterOnReadableClients(false);
-      criteria2.setFilterOnReadableOrganization(false);
-      CostingRule costingRule = criteria2.list().get(0);
-      CostingRule costingRuleClone = (CostingRule) DalUtil.copy(costingRule, 
false);
-      new TestCosting().setGeneralData(costingRuleClone);
-      costingRuleClone.setWarehouseDimension(true);
-      costingRuleClone.setBackdatedTransactionsFixed(true);
-      costingRuleClone.setValidated(false);
-      costingRuleClone.setEndingDate(null);
-      OBDal.getInstance().save(costingRuleClone);
+      CostingRule costingRule = 
OBProvider.getInstance().get(CostingRule.class);
+      setGeneralData(costingRule);
+      
costingRule.setCostingAlgorithm(OBDal.getInstance().get(CostingAlgorithm.class,
+          COSTINGALGORITHM_ID));
+      costingRule.setWarehouseDimension(true);
+      costingRule.setBackdatedTransactionsFixed(true);
+      costingRule.setValidated(false);
+      costingRule.setStartingDate(null);
+      costingRule.setEndingDate(null);
+      OBDal.getInstance().save(costingRule);
       OBDal.getInstance().flush();
-      OBDal.getInstance().refresh(costingRuleClone);
-      new TestCosting().runCostingBackground();
-      validateCostingRule(costingRuleClone.getId());
+      OBDal.getInstance().refresh(costingRule);
+      runCostingBackground();
+      validateCostingRule(costingRule.getId());
 
       OBDal.getInstance().commitAndClose();
     } catch (Exception e) {
@@ -404,7 +395,7 @@
       OBContext.setAdminMode(true);
 
       // Create a new product for the test
-      Product product = createProduct(price1);
+      Product product = createProduct("testCostingAAA", price1);
 
       // Create purchase order and book it
       Order purchaseOrder1 = createPurchaseOrder(product, price1, quantity1, 
day0);
@@ -458,10 +449,10 @@
       // Post cost adjustment and assert it
       postDocument(costAdjustmentList.get(0));
       List<DocumentPostAssert> documentPostAssertList = new 
ArrayList<DocumentPostAssert>();
-      documentPostAssertList.add(new DocumentPostAssert("99904", amount0, 
quantity2
+      documentPostAssertList.add(new DocumentPostAssert("99904", 
BigDecimal.ZERO, quantity2
           .multiply(price3).add(quantity2.multiply(price2).negate()), null));
       documentPostAssertList.add(new DocumentPostAssert("35000", 
quantity2.multiply(price3).add(
-          quantity2.multiply(price2).negate()), amount0, null));
+          quantity2.multiply(price2).negate()), BigDecimal.ZERO, null));
       CostAdjustment costAdjustment = 
OBDal.getInstance().get(CostAdjustment.class,
           costAdjustmentList.get(0).getId());
       assertDocumentPost(costAdjustment, product.getId(), 
documentPostAssertList);
@@ -496,7 +487,7 @@
       OBContext.setAdminMode(true);
 
       // Create a new product for the test
-      Product product = createProduct(price1);
+      Product product = createProduct("testCostingCC", price1);
 
       // Create purchase order and book it
       Order purchaseOrder = createPurchaseOrder(product, price1, quantity1, 
day0);
@@ -550,13 +541,13 @@
       // Post cost adjustment and assert it
       postDocument(costAdjustmentList.get(0));
       List<DocumentPostAssert> documentPostAssertList = new 
ArrayList<DocumentPostAssert>();
-      documentPostAssertList.add(new DocumentPostAssert("99904", amount0, 
quantity1
+      documentPostAssertList.add(new DocumentPostAssert("99904", 
BigDecimal.ZERO, quantity1
           .multiply(price2).add(quantity1.multiply(price1).negate()), null));
       documentPostAssertList.add(new DocumentPostAssert("35000", 
quantity1.multiply(price2).add(
-          quantity1.multiply(price1).negate()), amount0, null));
+          quantity1.multiply(price1).negate()), BigDecimal.ZERO, null));
       documentPostAssertList.add(new DocumentPostAssert("99900", 
quantity2.multiply(price2).add(
-          quantity2.multiply(price1).negate()), amount0, null));
-      documentPostAssertList.add(new DocumentPostAssert("35000", amount0, 
quantity2
+          quantity2.multiply(price1).negate()), BigDecimal.ZERO, null));
+      documentPostAssertList.add(new DocumentPostAssert("35000", 
BigDecimal.ZERO, quantity2
           .multiply(price2).add(quantity2.multiply(price1).negate()), null));
       CostAdjustment costAdjustment = 
OBDal.getInstance().get(CostAdjustment.class,
           costAdjustmentList.get(0).getId());
@@ -592,7 +583,7 @@
       OBContext.setAdminMode(true);
 
       // Create a new product for the test
-      Product product = createProduct(price1);
+      Product product = createProduct("testCostingC1", price1);
 
       // Create purchase order and book it
       Order purchaseOrder = createPurchaseOrder(product, price1, quantity1, 
day0);
@@ -643,13 +634,13 @@
       // Post cost adjustment and assert it
       postDocument(costAdjustmentList.get(0));
       List<DocumentPostAssert> documentPostAssertList = new 
ArrayList<DocumentPostAssert>();
-      documentPostAssertList.add(new DocumentPostAssert("99904", amount0, 
quantity1
+      documentPostAssertList.add(new DocumentPostAssert("99904", 
BigDecimal.ZERO, quantity1
           .multiply(price2).add(quantity1.multiply(price1).negate()), null));
       documentPostAssertList.add(new DocumentPostAssert("35000", 
quantity1.multiply(price2).add(
-          quantity1.multiply(price1).negate()), amount0, null));
+          quantity1.multiply(price1).negate()), BigDecimal.ZERO, null));
       documentPostAssertList.add(new DocumentPostAssert("99900", 
quantity2.multiply(price2).add(
-          quantity2.multiply(price1).negate()), amount0, null));
-      documentPostAssertList.add(new DocumentPostAssert("35000", amount0, 
quantity2
+          quantity2.multiply(price1).negate()), BigDecimal.ZERO, null));
+      documentPostAssertList.add(new DocumentPostAssert("35000", 
BigDecimal.ZERO, quantity2
           .multiply(price2).add(quantity2.multiply(price1).negate()), null));
       CostAdjustment costAdjustment = 
OBDal.getInstance().get(CostAdjustment.class,
           costAdjustmentList.get(0).getId());
@@ -687,7 +678,7 @@
       OBContext.setAdminMode(true);
 
       // Create a new product for the test
-      Product product = createProduct(price1);
+      Product product = createProduct("testCostingDDD", price1);
 
       // Create purchase order and book it
       Order purchaseOrder = createPurchaseOrder(product, price1, quantity1, 
day0);
@@ -746,9 +737,9 @@
       postDocument(costAdjustmentList.get(0));
       List<DocumentPostAssert> documentPostAssertList1 = new 
ArrayList<DocumentPostAssert>();
       documentPostAssertList1.add(new DocumentPostAssert("99904", 
quantity2.multiply(price1).add(
-          quantity2.multiply(price2).negate()), amount0, null));
-      documentPostAssertList1.add(new DocumentPostAssert("35000", amount0, 
quantity2.multiply(
-          price1).add(quantity2.multiply(price2).negate()), null));
+          quantity2.multiply(price2).negate()), BigDecimal.ZERO, null));
+      documentPostAssertList1.add(new DocumentPostAssert("35000", 
BigDecimal.ZERO, quantity2
+          .multiply(price1).add(quantity2.multiply(price2).negate()), null));
       CostAdjustment costAdjustment1 = 
OBDal.getInstance().get(CostAdjustment.class,
           costAdjustmentList.get(0).getId());
       assertDocumentPost(costAdjustment1, product.getId(), 
documentPostAssertList1);
@@ -757,9 +748,9 @@
       postDocument(costAdjustmentList.get(1));
       List<DocumentPostAssert> documentPostAssertList2 = new 
ArrayList<DocumentPostAssert>();

------------------------------------------------------------------------------
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to