Related to issue 39103: test has been refactored due it no longer creates its
authorAlejandro <alekosmp86@gmail.com>
Wed, 23 Jan 2019 14:50:41 -0500
changeset 8119 74e8b350af09
parent 8118 03de69d63b09
child 8120 4e2cf8bbd619
Related to issue 39103: test has been refactored due it no longer creates its
own sampledata
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/payment/I39103_VerifyPaymentAmountsInDifferentCurrencies.java
--- a/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/payment/I39103_VerifyPaymentAmountsInDifferentCurrencies.java	Wed Jan 23 14:20:51 2019 -0500
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/payment/I39103_VerifyPaymentAmountsInDifferentCurrencies.java	Wed Jan 23 14:50:41 2019 -0500
@@ -37,10 +37,9 @@
 import org.openbravo.test.mobile.retail.pack.selenium.terminals.WebPOSTerminalHelper;
 
 public class I39103_VerifyPaymentAmountsInDifferentCurrencies extends WebPOSTerminalHelper {
+  final static String EUR_TO_USD_CONVERSION_RATE_ID = "EDF1B25C54C94CB98C77FAF10FD90B61";
+  final static String USD_TO_EUR_CONVERSION_RATE_ID = "F43CF74B7E3342D9AFB32A84B8AB482C";
   private final String EUR_CURRENCY_ID = "102";
-  private final String USD_CURRENCY_ID = "100";
-  private final String EUR_TO_USD_CONVERSION_RATE_ID = "7280CD8D381A400FAC902F7C5430BFC1";
-  private final String USD_TO_EUR_CONVERSION_RATE_ID = "3908CE0CC81443CDBF3A48A95A290294";
   private final String PRODUCT_NAME = "Avalanche transceiver";
   private final String CASH_PAYMENTMETHOD_ID = "45A202BF44884F05B8A1BF741E2063B6";
   private final String CARD_PAYMENTMETHOD_ID = "5A741F883A31408CA3AC097D76AA6D32";
@@ -93,38 +92,22 @@
   }
 
   public void beforeWithReload() {
-    disableExistingConversionRate(EUR_CURRENCY_ID, USD_CURRENCY_ID);
-    disableExistingConversionRate(USD_CURRENCY_ID, EUR_CURRENCY_ID);
-    enableConversionRate(EUR_TO_USD_CONVERSION_RATE_ID);
-    enableConversionRate(USD_TO_EUR_CONVERSION_RATE_ID);
+    setActive(EUR_TO_USD_CONVERSION_RATE_ID, true);
+    setActive(USD_TO_EUR_CONVERSION_RATE_ID, true);
   }
 
   public void afterWithReload() {
-    disableExistingConversionRate(EUR_CURRENCY_ID, USD_CURRENCY_ID);
-    disableExistingConversionRate(USD_CURRENCY_ID, EUR_CURRENCY_ID);
-    enableOriginalConversionRate();
+    setActive(EUR_TO_USD_CONVERSION_RATE_ID, false);
+    setActive(USD_TO_EUR_CONVERSION_RATE_ID, false);
   }
 
-  private void enableConversionRate(final String conversionRateId) {
-    final String sql = String.format("update c_conversion_rate set isactive = '%s' "
-        + "where c_conversion_rate_id = '%s'", "Y", conversionRateId);
-    new DatabaseHelperInsertUpdateOrDelete().execute(sql, 1);
-  }
+  private void setActive(String conversionRateId, boolean active) {
+    String sql = String.format(
+        "update c_conversion_rate set isactive = '%s' where c_conversion_rate_id = '%s'",
+        active ? "Y" : "N", conversionRateId);
 
-  private void disableExistingConversionRate(final String currencyFrom, final String currencyTo) {
-    final String sql = String.format("update c_conversion_rate set isactive = 'N' "
-        + "where c_currency_id = '%s' and c_currency_id_to = '%s'", currencyFrom, currencyTo);
-    new DatabaseHelperInsertUpdateOrDelete().execute(sql,
-        DatabaseHelperInsertUpdateOrDelete.UNKNOWN_AFFECTED_ROWS);
-  }
-
-  private void enableOriginalConversionRate() {
-    new DatabaseHelperInsertUpdateOrDelete().execute(String.format(
-        "update c_conversion_rate set isactive = 'Y' where c_conversion_rate_id = '%s'",
-        "8A43908B77844AAEB78FAE4F21023083"), 1);
-    new DatabaseHelperInsertUpdateOrDelete().execute(String.format(
-        "update c_conversion_rate set isactive = 'Y' where c_conversion_rate_id = '%s'",
-        "D6576E0314C643428315CE4A637F331B"), 1);
+    new DatabaseHelperInsertUpdateOrDelete() {
+    }.execute(sql, 1);
   }
 
   private void addProduct(final String productName) {