Related to issue 38888: Failing SS Build
authorMartin Taal <martin.taal@openbravo.com>
Wed, 05 Dec 2018 09:09:35 +0100
changeset 7957 94bfc436b816
parent 7956 2fca23b250a8
child 7958 0b4b66b2e78a
Related to issue 38888: Failing SS Build
Change query, add ok button to void layaway
src-test/org/openbravo/test/mobile/retail/multiserver/MultiserverUtils.java
src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/store1/MS012_I31462_VoidLayaway.java
src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/store1/StatelessMultiServerOrderLoaderTest.java
--- a/src-test/org/openbravo/test/mobile/retail/multiserver/MultiserverUtils.java	Tue Dec 04 23:31:00 2018 +0100
+++ b/src-test/org/openbravo/test/mobile/retail/multiserver/MultiserverUtils.java	Wed Dec 05 09:09:35 2018 +0100
@@ -146,12 +146,13 @@
     final String toServerKey = getServerKey(toServerType);
     final String sqlOutgoing = "select node_id AS count from sym_outgoing_batch where node_id = '"
         + toServerKey + "' and status='ER'";
-    new DatabaseHelperSelect() {
+
+    new DatabaseHelperQuery() {
       @Override
-      protected void yieldResultSet(final ResultSet rs) throws SQLException {
-        Assert.fail("There are batches in error on " + fromServerType);
+      protected void handleResultSet(final ResultSet rs) throws SQLException {
+        Assert.assertFalse("There are batches in error on " + fromServerType, rs.next());
       }
-    }.execute(sqlOutgoing, 0, fromServerType);
+    }.execute(sqlOutgoing, fromServerType);
   }
 
   private static String getServerKey(ServerType server) {
--- a/src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/store1/MS012_I31462_VoidLayaway.java	Tue Dec 04 23:31:00 2018 +0100
+++ b/src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/store1/MS012_I31462_VoidLayaway.java	Wed Dec 05 09:09:35 2018 +0100
@@ -72,6 +72,7 @@
     // void
     tap(TestIdPack.BUTTON_MENU);
     tap(TestIdPack.BUTTON_MENU_VOIDLAYAWAY);
+    tap(TestIdPack.BUTTON_POPUP_OK);
     verify(TestIdPack.LABEL_RECEIPT_TYPE, "Layaway");
     verify(TestIdPack.LABEL_RECEIPT_COUNTER, "1");
     verify(TestIdPack.LABEL_TOTALTOPAY, "2.90");
--- a/src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/store1/StatelessMultiServerOrderLoaderTest.java	Tue Dec 04 23:31:00 2018 +0100
+++ b/src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/store1/StatelessMultiServerOrderLoaderTest.java	Wed Dec 05 09:09:35 2018 +0100
@@ -24,13 +24,18 @@
 import org.apache.commons.io.IOUtils;
 import org.json.JSONArray;
 import org.json.JSONObject;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
+import org.openbravo.test.mobile.core.junit.SequentialTestInfo;
 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.DatabaseHelperQuery;
 import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperSelect;
 import org.openbravo.test.mobile.retail.mobilecore.utils.RetailUtils;
 import org.openbravo.test.mobile.retail.mobilecore.webservice.WebServicesHelper;
+import org.openbravo.test.mobile.retail.multiserver.MultiserverUtils;
+import org.openbravo.test.mobile.retail.pack.database.ServerType;
 import org.testng.Assert;
 
 /**
@@ -48,6 +53,16 @@
   private boolean doBasicAuthentication = false;
   private boolean failBasicAuthentication = false;
 
+  @Before
+  public void before() {
+    SequentialTestInfo.setServerType(ServerType.STORE1);
+  }
+
+  @After
+  public void after() {
+    SequentialTestInfo.setServerType(ServerType.UNKNOWN);
+  }
+
   protected String getUserPwdParameters() {
     if (doStateLess) {
       if (failBasicAuthentication) {
@@ -148,27 +163,9 @@
     assertThat("String " + containedIn + " not present in " + jsonStr, containedIn == null
         || jsonStr.contains(containedIn));
   }
+
   protected String sendOrderFromFile(final String fileName) throws Exception {
-    return sendOrderFromFile(fileName, true);
-  }
-
-  protected String sendOrderFromFile(final String fileName, final boolean syncRequest)
-      throws Exception {
-    return sendOrderFromFile(fileName, RetailUtils.getRandomUUID(), syncRequest);
-  }
-
-  protected String sendOrderFromFile(final String fileName, final String orderId) throws Exception {
-    return sendOrderFromFile(fileName, orderId, false, 200, true);
-  }
-
-  protected String sendOrderFromFile(final String fileName, final String orderId,
-      final boolean syncRequest) throws Exception {
-    return sendOrderFromFile(fileName, orderId, false, 200, syncRequest);
-  }
-
-  protected String sendOrderFromFile(final String fileName, final String orderId,
-      final Boolean isAsync, final int expectedStatus) throws Exception {
-    return sendOrderFromFile(fileName, orderId, isAsync, expectedStatus, true);
+    return sendOrderFromFile(fileName, RetailUtils.getRandomUUID(), false, 200, true);
   }
 
   protected String sendOrderFromFile(final String fileName, final String orderId,
@@ -177,13 +174,16 @@
     json = replaceIds(json, orderId);
     final String result = sendOrder(json, isAsync, expectedStatus, syncRequest);
 
+    // let it replicate
+    MultiserverUtils.waitForSynchronization(ServerType.STORE1);
+
     if (!result.contains("\"status\":-1") && orderId != null) {
       final String sql = "select c_order_id from c_order where c_order_id='" + orderId + "'";
       new DatabaseHelperSelect() {
         @Override
         protected void yieldResultSet(final ResultSet rs) throws SQLException {
         }
-      }.execute(sql, 1, false);
+      }.execute(sql, 1, false, ServerType.STORE1);
     }
     return result;
   }
@@ -205,7 +205,7 @@
             loaded = dateFormat.format(calendar.getTime());
           }
         }
-      }.execute(sql);
+      }.execute(sql, ServerType.STORE1);
     }
     if (loaded == null) {
       loaded = OBUtils.getSystemTimestampLong();