Related to issue 28933, verifies issue 29223: Added 2 new tests to verify that the quotation number is properly created
authorRafa Alonso <rafael.alonso@openbravo.com>
Thu, 12 Mar 2015 13:07:38 +0100
changeset 4087 94792f88756f
parent 4086 6ccbb3a507e6
child 4088 b2c06861d0ad
Related to issue 28933, verifies issue 29223: Added 2 new tests to verify that the quotation number is properly created
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/documentno/I29223_QuotationnoConsecutive.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/documentno/I29223_QuotationnoConsecutiveAfterDelete.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/documentno/I29223_QuotationnoConsecutive.java	Thu Mar 12 13:07:38 2015 +0100
@@ -0,0 +1,74 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * 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) 2015 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author RAL
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.documentno;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.common.selenium.javascript.BackboneHelper;
+import org.openbravo.test.mobile.common.selenium.javascript.TestId;
+import org.openbravo.test.mobile.common.selenium.terminals.WebPOSTerminalHelper;
+
+public class I29223_QuotationnoConsecutive extends WebPOSTerminalHelper {
+
+  @Test
+  public void test() {
+    // create the first quotation
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_CREATEQUOTATION);
+
+    createNewQuotationAndVerifyNumber();
+    createNewQuotationAndVerifyNumber();
+    createNewQuotationAndVerifyNumber();
+
+    // restore
+    tap(TestId.BUTTON_DELETERECEIPT);
+    tap(TestId.BUTTON_DELETERECEIPT_CONFIRM);
+    tap(TestId.BUTTON_DELETERECEIPT);
+    tap(TestId.BUTTON_DELETERECEIPT_CONFIRM);
+    tap(TestId.BUTTON_DELETERECEIPT);
+    tap(TestId.BUTTON_DELETERECEIPT_CONFIRM);
+    tap(TestId.BUTTON_DELETERECEIPT);
+    tap(TestId.BUTTON_DELETERECEIPT_CONFIRM);
+  }
+
+  private void createNewQuotationAndVerifyNumber() {
+    // get the current quotation number
+    final String currentQuotationno = BackboneHelper.getDocumentNo();
+    // create a quotation
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_CREATEQUOTATION);
+    final String newQuotationno = getNextQuotationno(currentQuotationno);
+    // verify number
+    assertThat(BackboneHelper.getDocumentNo(), equalTo(newQuotationno));
+  }
+
+  private String getNextQuotationno(final String quotationno) {
+    final String[] documentnoHeader = quotationno.split("/");
+    final int documentNumber = Integer.parseInt(documentnoHeader[1]) + 1;
+    final String newDocumentno = String.format("%s/%07d", documentnoHeader[0], documentNumber);
+    return newDocumentno;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/documentno/I29223_QuotationnoConsecutiveAfterDelete.java	Thu Mar 12 13:07:38 2015 +0100
@@ -0,0 +1,84 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * 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) 2015 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author RAL
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.documentno;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.common.selenium.javascript.BackboneHelper;
+import org.openbravo.test.mobile.common.selenium.javascript.TestId;
+import org.openbravo.test.mobile.common.selenium.terminals.WebPOSTerminalHelper;
+
+public class I29223_QuotationnoConsecutiveAfterDelete extends WebPOSTerminalHelper {
+
+  @Test
+  public void test() {
+    // create the first quotation
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_CREATEQUOTATION);
+    final String firstQuotationno = BackboneHelper.getDocumentNo();
+
+    createNewQuotationAndVerifyNumber();
+    createNewQuotationAndVerifyNumber();
+    createNewQuotationAndVerifyNumber();
+
+    // delete created quotations
+    tap(TestId.BUTTON_DELETERECEIPT);
+    tap(TestId.BUTTON_DELETERECEIPT_CONFIRM);
+    tap(TestId.BUTTON_DELETERECEIPT);
+    tap(TestId.BUTTON_DELETERECEIPT_CONFIRM);
+    tap(TestId.BUTTON_DELETERECEIPT);
+    tap(TestId.BUTTON_DELETERECEIPT_CONFIRM);
+    tap(TestId.BUTTON_DELETERECEIPT);
+    tap(TestId.BUTTON_DELETERECEIPT_CONFIRM);
+
+    // create again a quotation and verify that it haas the same number as the first one
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_CREATEQUOTATION);
+    assertThat(BackboneHelper.getDocumentNo(), equalTo(firstQuotationno));
+
+    // restore
+    tap(TestId.BUTTON_DELETERECEIPT);
+    tap(TestId.BUTTON_DELETERECEIPT_CONFIRM);
+  }
+
+  private void createNewQuotationAndVerifyNumber() {
+    // get the current quotation number
+    final String currentQuotationno = BackboneHelper.getDocumentNo();
+    // create a quotation
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_CREATEQUOTATION);
+    final String newQuotationno = getNextQuotationno(currentQuotationno);
+    // verify number
+    assertThat(BackboneHelper.getDocumentNo(), equalTo(newQuotationno));
+  }
+
+  private String getNextQuotationno(final String quotationno) {
+    final String[] documentnoHeader = quotationno.split("/");
+    final int documentNumber = Integer.parseInt(documentnoHeader[1]) + 1;
+    final String newDocumentno = String.format("%s/%07d", documentnoHeader[0], documentNumber);
+    return newDocumentno;
+  }
+
+}