Related to issue 35637: test has been refactored due to it no longer creates its
authorAlejandro <alekosmp86@gmail.com>
Thu, 24 Jan 2019 14:24:09 -0500
changeset 8121 e622205a4015
parent 8120 4e2cf8bbd619
child 8122 302e22d76237
Related to issue 35637: test has been refactored due to it no longer creates its
own sampledata.
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/discountsandpromotions/I35637_VerifyPriceAdjWithIsMultiple.java
--- a/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/discountsandpromotions/I35637_VerifyPriceAdjWithIsMultiple.java	Wed Jan 23 11:11:49 2019 -0500
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/discountsandpromotions/I35637_VerifyPriceAdjWithIsMultiple.java	Thu Jan 24 14:24:09 2019 -0500
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo S.L.U.
- * All portions are Copyright (C) 2017 Openbravo S.L.U.
+ * All portions are Copyright (C) 2017-2019 Openbravo S.L.U.
  * All Rights Reserved.
  * Contributor(s):
  ************************************************************************
@@ -19,21 +19,17 @@
  * @author RAN
  *
  */
+
 package org.openbravo.test.mobile.retail.pack.selenium.tests.discountsandpromotions;
 
 import org.junit.Test;
 import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperInsertUpdateOrDelete;
-import org.openbravo.test.mobile.retail.mobilecore.javascript.BackboneHelper;
-import org.openbravo.test.mobile.retail.mobilecore.utils.RetailUtils;
 import org.openbravo.test.mobile.retail.pack.selenium.TestIdPack;
 import org.openbravo.test.mobile.retail.pack.selenium.terminals.WebPOSTerminalHelper;
 
 public class I35637_VerifyPriceAdjWithIsMultiple extends WebPOSTerminalHelper {
-
-  private final String offerId = RetailUtils.getRandomUUID();
+  private final String offerId = "82A3FDB103404DF1B2A3FB9E07569670";
   private final String offerName = "PriceAdj IsMultiple Disc";
-  private final String offerProductId = RetailUtils.getRandomUUID();
-  private final String productId = "934E7D7587EC4C7A9E9FF58F0382D450";
   private final String productName = "Avalanche transceiver";
 
   @Test
@@ -102,37 +98,30 @@
 
   @Override
   public void beforeWithReload() {
-    final String clientId = BackboneHelper.getTerminalValue("client"), orgId = "0", userId = "100";
-
-    final String offerSQL = String.format(
-        "insert into m_offer(m_offer_id, ad_client_id, ad_org_id, createdby, updatedby, "
-            + "m_offer_type_id, name, discount, addamt, ismultiple, multiple, datefrom, "
-            + "bpartner_selection, bp_group_selection, product_selection, prod_cat_selection, "
-            + "pricelist_selection, apply_next, org_selection, characteristics_selection, "
-            + "em_obdisc_distribute, em_obdisc_role_selection, em_obdisc_approval_required) "
-            + "values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', "
-            + "TO_DATE('2017-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'Y', 'Y', 'N', 'Y', 'Y', "
-            + "'Y', 'Y', 'Y', 'N', 'Y', 'N')", offerId, clientId, orgId, userId, userId,
-        "5D4BAF6BB86D4D2C9ED3D5A6FC051579", offerName, "0", "12", "Y", "3");
-    new DatabaseHelperInsertUpdateOrDelete().execute(offerSQL, 1);
-
-    final String offerProductSQL = String.format(
-        "insert into m_offer_product(m_offer_product_id, ad_client_id, ad_org_id, createdby, updatedby, "
-            + "m_offer_id, m_product_id) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s')",
-        offerProductId, clientId, orgId, userId, userId, offerId, productId);
-    new DatabaseHelperInsertUpdateOrDelete().execute(offerProductSQL, 1);
+    setActiveDiscount(offerId, true);
   }
 
   @Override
   public void afterWithReload() {
-    new DatabaseHelperInsertUpdateOrDelete().execute(String.format(
-        "delete from m_offer_product where m_offer_product_id = '%s'", offerProductId), 1);
-    new DatabaseHelperInsertUpdateOrDelete().execute(
-        String.format("delete from m_offer where m_offer_id = '%s'", offerId), 1);
+    restoreDiscountAmtInOffer();
+    setActiveDiscount(offerId, false);
+  }
+
+  private void setActiveDiscount(String discountId, boolean active) {
+    String sql = String.format("update m_offer set isactive = '%s' where m_offer_id = '%s'",
+        active ? "Y" : "N", discountId);
+
+    new DatabaseHelperInsertUpdateOrDelete() {
+    }.execute(sql, 1);
   }
 
   public void removeDiscountAmtInOffer() {
     new DatabaseHelperInsertUpdateOrDelete().execute(String.format(
         "update m_offer set discount = 10, addamt = 0 where m_offer_id = '%s'", offerId), 1);
   }
+
+  public void restoreDiscountAmtInOffer() {
+    new DatabaseHelperInsertUpdateOrDelete().execute(String.format(
+        "update m_offer set discount = 0, addamt = 12 where m_offer_id = '%s'", offerId), 1);
+  }
 }