Related to issue 38350: Adding master data test to check development modules.
authorJavier Armendáriz <javier.armendariz@openbravo.com>
Tue, 24 Apr 2018 10:22:50 +0200
changeset 5040 9f32627b3273
parent 5039 e162f2408f30
child 5041 19a81fc4f435
Related to issue 38350: Adding master data test to check development modules.

Adding tests ADMia/ADMib which checks that production instances cannot have
modules marked as In Development.
src-test/com/openbravo/test/integration/erp/gui/applicationdictionary/module/ModuleTab.java
src-test/com/openbravo/test/integration/erp/testscripts/applicationdictionary/module/Module.java
src-test/com/openbravo/test/integration/erp/testsuites/smoke/masterdata/ADMi_ActivateInstanceBaseTest.java
src-test/com/openbravo/test/integration/erp/testsuites/smoke/masterdata/ADMi_DevelopmentModulesInProduction.java
src-test/com/openbravo/test/integration/erp/testsuites/smoke/masterdata/ADMia_UnmarkDevelopmentModuleInProduction.java
src-test/com/openbravo/test/integration/erp/testsuites/smoke/masterdata/ADMib_ProductionInstanceCannotHaveDevModules.java
src-test/com/openbravo/test/integration/erp/testsuites/smoke/masterdata/MasterDataSuite.java
--- a/src-test/com/openbravo/test/integration/erp/gui/applicationdictionary/module/ModuleTab.java	Thu May 03 12:43:05 2018 +0200
+++ b/src-test/com/openbravo/test/integration/erp/gui/applicationdictionary/module/ModuleTab.java	Tue Apr 24 10:22:50 2018 +0200
@@ -48,4 +48,8 @@
     // TOOD add children
   }
 
+  public void assertErrorMessage(String errorMessage) {
+    standardView.assertErrorMessage(errorMessage);
+  }
+
 }
--- a/src-test/com/openbravo/test/integration/erp/testscripts/applicationdictionary/module/Module.java	Thu May 03 12:43:05 2018 +0200
+++ b/src-test/com/openbravo/test/integration/erp/testscripts/applicationdictionary/module/Module.java	Tue Apr 24 10:22:50 2018 +0200
@@ -69,4 +69,7 @@
     return (ModuleTab) window.selectTab(ModuleTab.IDENTIFIER);
   }
 
+  public void assertErrorMessage(String errorMessage) {
+    ((ModuleTab)getTab()).assertErrorMessage(errorMessage);
+  }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/com/openbravo/test/integration/erp/testsuites/smoke/masterdata/ADMi_ActivateInstanceBaseTest.java	Tue Apr 24 10:22:50 2018 +0200
@@ -0,0 +1,67 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (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 SLU
+ * All portions are Copyright (C) 2018 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package com.openbravo.test.integration.erp.testsuites.smoke.masterdata;
+
+import static com.openbravo.test.integration.erp.data.generalsetup.application.instanceactivation.Purposes.PRODUCTION;
+import static com.openbravo.test.integration.erp.data.generalsetup.application.instanceactivation.Purposes.TESTING;
+
+import com.openbravo.test.integration.erp.common.TestFiles;
+import com.openbravo.test.integration.erp.data.ProfileData;
+import com.openbravo.test.integration.erp.data.generalsetup.application.instanceactivation.ActivateOnlineData;
+import com.openbravo.test.integration.erp.testscripts.OpenbravoERPTest;
+import com.openbravo.test.integration.erp.testscripts.generalsetup.application.intanceactivation.InstanceActivation;
+import java.io.File;
+import java.io.IOException;
+import org.apache.commons.io.FileUtils;
+import org.apache.log4j.Logger;
+
+public abstract class ADMi_ActivateInstanceBaseTest extends OpenbravoERPTest {
+
+  private static Logger logger = Logger.getLogger(ADMi_ActivateInstanceBaseTest.class);
+
+  protected void changeRoleToSystemAdmin() {
+    mainPage.getNavigationBar().changeProfile(
+      new ProfileData.Builder().role("System Administrator - System").client("System")
+        .organization("*").isDefault(true).build());
+    mainPage.assertLogin(logInData.getUserName());
+  }
+
+  protected void setupInstanceAsProduction() {
+    ActivateOnlineData activateOnlineData = new ActivateOnlineData.Builder().requiredFields(
+      PRODUCTION.purpose(), readLicenseKeyFile()).build();
+
+    InstanceActivation.activateInstanceOnline(mainPage, activateOnlineData);
+  }
+
+  protected void setupInstanceAsTesting() {
+    ActivateOnlineData activateOnlineData = new ActivateOnlineData.Builder().requiredFields(
+      TESTING.purpose(), readLicenseKeyFile()).build();
+
+    InstanceActivation.activateInstanceOnline(mainPage, activateOnlineData);
+  }
+
+  private String readLicenseKeyFile() {
+    try {
+      return FileUtils.readFileToString(new File(TestFiles.getRelativeFilePath("SystemKey.txt")));
+    } catch (IOException exception) {
+      logger.error("Cannot open license file", exception);
+      return "";
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/com/openbravo/test/integration/erp/testsuites/smoke/masterdata/ADMi_DevelopmentModulesInProduction.java	Tue Apr 24 10:22:50 2018 +0200
@@ -0,0 +1,43 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (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 SLU
+ * All portions are Copyright (C) 2018 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package com.openbravo.test.integration.erp.testsuites.smoke.masterdata;
+
+import org.junit.AfterClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+import com.openbravo.test.integration.erp.testscripts.OpenbravoERPTest;
+import com.openbravo.test.integration.erp.testscripts.SuiteThatStopsIfFailure;
+import com.openbravo.test.integration.selenium.SeleniumSingleton;
+
+/**
+ * Suite to test dev modules in production
+ *
+ * @author jarmendariz
+ */
+@RunWith(SuiteThatStopsIfFailure.class)
+@Suite.SuiteClasses({ ADMia_UnmarkDevelopmentModuleInProduction.class, ADMib_ProductionInstanceCannotHaveDevModules.class })
+public class ADMi_DevelopmentModulesInProduction {
+  @AfterClass
+  public static void tearDown() {
+    OpenbravoERPTest.forceLoginRequired();
+    OpenbravoERPTest.seleniumStarted = false;
+    SeleniumSingleton.INSTANCE.quit();
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/com/openbravo/test/integration/erp/testsuites/smoke/masterdata/ADMia_UnmarkDevelopmentModuleInProduction.java	Tue Apr 24 10:22:50 2018 +0200
@@ -0,0 +1,87 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (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 SLU
+ * All portions are Copyright (C) 2018 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package com.openbravo.test.integration.erp.testsuites.smoke.masterdata;
+
+import static org.junit.Assert.assertFalse;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.apache.log4j.Logger;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import com.openbravo.test.integration.erp.data.LogInData;
+import com.openbravo.test.integration.erp.data.applicationdictionary.module.ModuleData;
+import com.openbravo.test.integration.erp.testscripts.applicationdictionary.module.Module;
+import com.openbravo.test.integration.selenium.Sleep;
+import com.openbravo.test.integration.util.ConfigurationProperties;
+
+/**
+ * Test that once a instance its set as production, all development modules should be unmarked
+ *
+ * @author jarmendariz
+ */
+@RunWith(Parameterized.class)
+public class ADMia_UnmarkDevelopmentModuleInProduction extends ADMi_ActivateInstanceBaseTest {
+
+  private static Logger logger = Logger.getLogger(ADMia_UnmarkDevelopmentModuleInProduction.class);
+
+  public ADMia_UnmarkDevelopmentModuleInProduction(LogInData logInData) {
+    this.logInData = logInData;
+  }
+
+  @Parameters
+  public static Collection<LogInData[]> parameters() {
+    return Arrays.asList(new LogInData[][] { { new LogInData.Builder()
+        .userName(ConfigurationProperties.INSTANCE.getSystemAdministratorUser())
+        .password(ConfigurationProperties.INSTANCE.getSystemAdministratorPassword()).build() } });
+  }
+
+  @Test
+  public void testModuleIsNotInDevelopmentInProduction() {
+    changeRoleToSystemAdmin();
+    setupInstanceAsTesting();
+    setCoreModuleAsInDevelopment();
+    setupInstanceAsProduction();
+
+    verifyCoreModuleIsNotInDevelopment();
+    setupInstanceAsTesting();
+  }
+
+  private void verifyCoreModuleIsNotInDevelopment() {
+    Module module = new Module(mainPage).open();
+    Sleep.trySleep();
+    module.select(new ModuleData.Builder().name("Core").build());
+    Boolean inDevelopment = (Boolean) module.getData().getDataField("inDevelopment");
+
+    assertFalse("Core module should not be in development", inDevelopment);
+  }
+
+  private void setCoreModuleAsInDevelopment() {
+    Module module = new Module(mainPage).open();
+    module.select(new ModuleData.Builder().name("Core").build());
+    Boolean inDevelopment = (Boolean) module.getData().getDataField("inDevelopment");
+    if (!inDevelopment) {
+      module.edit(new ModuleData.Builder().inDevelopment(Boolean.TRUE).build());
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/com/openbravo/test/integration/erp/testsuites/smoke/masterdata/ADMib_ProductionInstanceCannotHaveDevModules.java	Tue Apr 24 10:22:50 2018 +0200
@@ -0,0 +1,72 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (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 SLU
+ * All portions are Copyright (C) 2018 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package com.openbravo.test.integration.erp.testsuites.smoke.masterdata;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import com.openbravo.test.integration.erp.data.LogInData;
+import com.openbravo.test.integration.erp.data.applicationdictionary.module.ModuleData;
+import com.openbravo.test.integration.erp.testscripts.applicationdictionary.module.Module;
+import com.openbravo.test.integration.util.ConfigurationProperties;
+
+/**
+ * Test that once a instance its set as production, any attempt to mark a module as in development
+ * should fail
+ *
+ * @author jarmendariz
+ */
+@RunWith(Parameterized.class)
+public class ADMib_ProductionInstanceCannotHaveDevModules extends ADMi_ActivateInstanceBaseTest {
+
+  public ADMib_ProductionInstanceCannotHaveDevModules(LogInData logInData) {
+    this.logInData = logInData;
+  }
+
+  @Parameters
+  public static Collection<LogInData[]> parameters() {
+    return Arrays.asList(new LogInData[][] { { new LogInData.Builder()
+        .userName(ConfigurationProperties.INSTANCE.getSystemAdministratorUser())
+        .password(ConfigurationProperties.INSTANCE.getSystemAdministratorPassword()).build() } });
+  }
+
+  @Test
+  public void testSavingAModuleAsInDevelopmentInProductionShouldFail() {
+    changeRoleToSystemAdmin();
+    setupInstanceAsProduction();
+
+    verifyCoreModuleCannotBeSetAsInDevelopment();
+    setupInstanceAsTesting();
+  }
+
+  private void verifyCoreModuleCannotBeSetAsInDevelopment() {
+    Module module = new Module(mainPage).open();
+    module.select(new ModuleData.Builder().name("Core").build());
+    module.edit(new ModuleData.Builder().inDevelopment(Boolean.TRUE).build());
+
+    module
+        .assertErrorMessage("Saving failed. Cannot have development modules in a Production instance");
+  }
+
+}
--- a/src-test/com/openbravo/test/integration/erp/testsuites/smoke/masterdata/MasterDataSuite.java	Thu May 03 12:43:05 2018 +0200
+++ b/src-test/com/openbravo/test/integration/erp/testsuites/smoke/masterdata/MasterDataSuite.java	Tue Apr 24 10:22:50 2018 +0200
@@ -40,7 +40,7 @@
 @RunWith(SuiteThatStopsIfFailure.class)
 @Suite.SuiteClasses({ ADMa_LoggingInAndOut.class, ADMb_SetupInstanceSuite.class,
     ADMc_SetupClientAndOrganization.class, ADMd_SetupUserAndRole.class, ADMe_SetupProduct.class,
-    ADMf_SetupBusinessPartner.class })
+    ADMf_SetupBusinessPartner.class, ADMi_DevelopmentModulesInProduction.class })
 // ADMha_SetupInitialDataLoad.class has been commented. IDL was being removed.
 // ADMhb_LoadProductsData.class is temporarily commented. Some error was being shown.
 // ADMhc_LoadBusinessPartnersData.class is temporarily commented. BusinessPartners.csv was not