Related to issue 39674: test has been refactored due to it no longer creates its
authorAlejandro <alekosmp86@gmail.com>
Wed, 23 Jan 2019 11:11:49 -0500
changeset 8120 4e2cf8bbd619
parent 8119 74e8b350af09
child 8121 e622205a4015
Related to issue 39674: test has been refactored due to it no longer creates its
own sampledata
src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/discounts_coupons/I39674_VerifyMessageWhenUsingCouponInOfflineMode.java
--- a/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/discounts_coupons/I39674_VerifyMessageWhenUsingCouponInOfflineMode.java	Wed Jan 23 14:50:41 2019 -0500
+++ b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/discounts_coupons/I39674_VerifyMessageWhenUsingCouponInOfflineMode.java	Wed Jan 23 11:11:49 2019 -0500
@@ -27,19 +27,15 @@
 import org.openbravo.test.mobile.retail.extmodules.selenium.TestIdExtModules;
 import org.openbravo.test.mobile.retail.extmodules.selenium.terminals.WebPOSExtModulesOfflineTerminalHelper;
 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.selenium.TestIdCore;
-import org.openbravo.test.mobile.retail.mobilecore.utils.RetailUtils;
 import org.openbravo.test.mobile.retail.pack.selenium.TestIdPack;
 
 public class I39674_VerifyMessageWhenUsingCouponInOfflineMode extends
     WebPOSExtModulesOfflineTerminalHelper {
-  final static String COUPON_OFFER_ID = RetailUtils.getRandomUUID();
-  final static String COUPON_ID = RetailUtils.getRandomUUID();
-  final static String OFFER_TYPE_ID = "4183C8EB7CDA472D9E64521DC2504B15";
+  final static String COUPON_OFFER_ID = "D8D10D6CF46943AEA0F6E1F21FA09C06";
   final static String PRODUCT_NAME = "Wilderness wash";
-  final static String DISCOUNT_NAME = "CDISC_" + RetailUtils.getRandomUUID().substring(0, 5);
-  final static String COUPON_CODE = "COUPON_" + RetailUtils.getRandomUUID().substring(0, 5);
+  final static String DISCOUNT_NAME = "Coupon 3";
+  final static String COUPON_CODE = "COUPON3";
   final static String POPUP_MESSAGE = "This coupon has already been used";
 
   @Test
@@ -70,39 +66,16 @@
   }
 
   public void beforeWithReload() {
-    createDiscount(DISCOUNT_NAME);
-    createCoupon(COUPON_CODE);
+    setActiveDiscount(COUPON_OFFER_ID, true);
   }
 
   public void afterWithReload() {
-
+    setActiveDiscount(COUPON_OFFER_ID, false);
   }
 
-  private void createDiscount(String discountName) {
-    String clientId = BackboneHelper.getTerminalValue("client");
-    String orgId = BackboneHelper.getTerminalValue("organization");
-    String sql = String
-        .format(
-            "insert into m_offer (m_offer_id, ad_client_id, ad_org_id, createdby, updatedby, name, datefrom, "
-                + "bpartner_selection, bp_group_selection, product_selection, prod_cat_selection, m_offer_type_id, "
-                + "em_obdiscp_monday, em_obdiscp_tuesday, em_obdiscp_wednesday, em_obdiscp_thursday, em_obdiscp_friday, "
-                + "em_obdiscp_saturday, em_obdiscp_sunday, em_obdiscp_wholeweek, em_obdiscp_iscoupon, em_disct_totalreceipt,"
-                + "em_disct_totalamountdisc) values ('%s', '%s', '%s', '100', '100', '%s', TO_DATE(NOW()), 'Y', 'Y', 'Y', 'Y', '%s',"
-                + "'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', '%s', '%s')", COUPON_OFFER_ID,
-            clientId, orgId, discountName, OFFER_TYPE_ID, 100, 20);
-
-    new DatabaseHelperInsertUpdateOrDelete() {
-    }.execute(sql, 1);
-  }
-
-  private void createCoupon(String couponName) {
-    String clientId = BackboneHelper.getTerminalValue("client");
-    String orgId = BackboneHelper.getTerminalValue("organization");
-    String sql = String
-        .format(
-            "insert into obdiscp_coupon(obdiscp_coupon_id, ad_client_id, ad_org_id, createdby, updatedby, couponcode, m_offer_id, oneuse) "
-                + "values ('%s', '%s', '%s', '100', '100', '%s', '%s', 'Y')", COUPON_ID, clientId,
-            orgId, couponName, COUPON_OFFER_ID);
+  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);