Related to issue 38888: Failing SS Build
authorMartin Taal <martin.taal@openbravo.com>
Tue, 20 Nov 2018 09:17:39 +0100
changeset 7891 fc0d0e1a3ffb
parent 7890 2fc2c5f729fe
child 7892 db99acea4bc3
child 7967 4be68922b46c
Related to issue 38888: Failing SS Build
Add a wait for sync before going offline, do not wait for msg table when cs is offline
src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/offline/OfflineMSCentral003_CreateMultiorder.java
src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/offline/OfflineMSCentral005_Cashmanagement.java
src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/offline/OfflineMSCentral006_LAWa010_CreateLayaway.java
src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/offline/OfflineMSCentral008_RejectQuotations.java
src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/offline/OfflineMSCentral009_MS020_ReturnServiceTests.java
--- a/src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/offline/OfflineMSCentral003_CreateMultiorder.java	Tue Nov 20 11:26:24 2018 +0530
+++ b/src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/offline/OfflineMSCentral003_CreateMultiorder.java	Tue Nov 20 09:17:39 2018 +0100
@@ -7,6 +7,7 @@
 import java.sql.SQLException;
 
 import org.junit.Test;
+import org.openbravo.test.mobile.core.utils.OBUtils;
 import org.openbravo.test.mobile.retail.mobilecore.annotations.TestClassAnnotations;
 import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperSelect;
 import org.openbravo.test.mobile.retail.mobilecore.javascript.BackboneHelper;
@@ -57,6 +58,9 @@
     tap(TestIdPack.BUTTON_SEARCHPRODUCT_BASECAMPLANTERN);
     verify(TestIdPack.LABEL_TOTALTOPAY, totalToPay2);
 
+    // small wait as it seems that menu is not clicked
+    OBUtils.pause(2000);
+
     // pay open tickets
     tap(TestIdPack.BUTTON_MENU);
     tap(TestIdPack.BUTTON_MENU_PAYOPENTICKETS);
--- a/src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/offline/OfflineMSCentral005_Cashmanagement.java	Tue Nov 20 11:26:24 2018 +0530
+++ b/src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/offline/OfflineMSCentral005_Cashmanagement.java	Tue Nov 20 09:17:39 2018 +0100
@@ -38,6 +38,7 @@
     // the only one in the fin_finacc_transaction table
     final int randomNumber = random.nextInt(max - min) + min;
 
+    MultiserverUtils.waitForSynchronization();
     goCentralOffline();
 
     tap(TestIdPack.BUTTON_MENU);
--- a/src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/offline/OfflineMSCentral006_LAWa010_CreateLayaway.java	Tue Nov 20 11:26:24 2018 +0530
+++ b/src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/offline/OfflineMSCentral006_LAWa010_CreateLayaway.java	Tue Nov 20 09:17:39 2018 +0100
@@ -1,14 +1,17 @@
 package org.openbravo.test.mobile.retail.multiserver.selenium.tests.offline;
 
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
 import org.junit.Test;
 import org.openbravo.test.mobile.core.utils.OBUtils;
 import org.openbravo.test.mobile.retail.mobilecore.annotations.TestClassAnnotations;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperSelect;
 import org.openbravo.test.mobile.retail.mobilecore.javascript.BackboneHelper;
 import org.openbravo.test.mobile.retail.multiserver.MultiserverOfflineUtils;
 import org.openbravo.test.mobile.retail.multiserver.MultiserverUtils;
 import org.openbravo.test.mobile.retail.multiserver.selenium.terminals.WebPOSCentralOfflineTerminalHelper;
 import org.openbravo.test.mobile.retail.pack.database.ServerType;
-import org.openbravo.test.mobile.retail.pack.database.WebPOSDatabaseHelper;
 import org.openbravo.test.mobile.retail.pack.selenium.TestIdPack;
 
 @TestClassAnnotations(isHighVolumeCompatible = true)
@@ -36,11 +39,25 @@
     tap(TestIdPack.BUTTON_LAYAWAY);
     verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
 
-    WebPOSDatabaseHelper.getCOrderIdByDocumentNo(receiptNo, ServerType.STORE1);
+    getCOrderIdByDocumentNo(receiptNo, ServerType.STORE1);
 
     MultiserverUtils.waitForSynchronization();
     MultiserverOfflineUtils.goCentralOnline();
 
-    WebPOSDatabaseHelper.getCOrderIdByDocumentNo(receiptNo, ServerType.CENTRAL);
+    getCOrderIdByDocumentNo(receiptNo, ServerType.CENTRAL);
   }
+
+  private String getCOrderIdByDocumentNo(final String documentNo, final ServerType server) {
+    final StringBuilder cOrderIdStringBuilder = new StringBuilder();
+    final String cOrdeQuery = String.format("SELECT c_order_id FROM c_order WHERE documentno='%s'",
+        documentNo);
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        cOrderIdStringBuilder.append(rs.getString("c_order_id"));
+      }
+    }.execute(cOrdeQuery, 1, false, server);
+    return cOrderIdStringBuilder.toString();
+  }
+
 }
--- a/src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/offline/OfflineMSCentral008_RejectQuotations.java	Tue Nov 20 11:26:24 2018 +0530
+++ b/src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/offline/OfflineMSCentral008_RejectQuotations.java	Tue Nov 20 09:17:39 2018 +0100
@@ -45,6 +45,9 @@
     tap(TestIdPack.BUTTON_DELETERECEIPT);
     verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
 
+    // wait for synchronization to not have
+    // transactions pending to sync
+    MultiserverUtils.waitForSynchronization();
     // go offline
     goCentralOffline();
     MultiserverUtils.waitForSynchronization();
--- a/src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/offline/OfflineMSCentral009_MS020_ReturnServiceTests.java	Tue Nov 20 11:26:24 2018 +0530
+++ b/src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/offline/OfflineMSCentral009_MS020_ReturnServiceTests.java	Tue Nov 20 09:17:39 2018 +0100
@@ -23,6 +23,7 @@
     // Initial steps: be sure there is enough cash for returns
     WebPOSAPI.cleanCashup(this);
     beSureThereIsMoney();
+    MultiserverUtils.waitForSynchronization();
     goCentralOffline();
 
     // Verify not returnable service error