From 15dc606f77b5768bbf8968dac3ee9d0c7e4ed581 Mon Sep 17 00:00:00 2001 From: kamiljarmusik Date: Wed, 10 Jan 2024 16:47:44 +0100 Subject: [PATCH] - added WebsiteTest.groovy; --- pom.xml | 6 ++- scada-lts-e2e-app/pom.xml | 2 +- scada-lts-e2e-cli/pom.xml | 2 +- .../scadalts/e2e/cli/config/E2eConfigCli.java | 6 ++- .../e2e/cli/options/DefaultOptions.java | 2 +- .../e2e/cli/options/ScadaOptions.java | 3 ++ scada-lts-e2e-common/pom.xml | 2 +- .../scada-lts-e2e-common-api/pom.xml | 2 +- .../scada-lts-e2e-common-core/pom.xml | 2 +- .../e2e/common/core/config/E2eConfig.java | 1 + .../common/core/config/E2eConfigDefault.java | 2 +- .../common/core/config/E2eConfiguration.java | 1 + .../common/core/config/E2eConfigurator.java | 1 + .../e2e/common/core/types/TestPlan.java | 3 +- .../config/scadalts-e2e-config.properties | 2 + .../scada-lts-e2e-common-impl/pom.xml | 2 +- scada-lts-e2e-page/pom.xml | 2 +- .../scada-lts-e2e-page-api/pom.xml | 2 +- .../scada-lts-e2e-page-core/pom.xml | 2 +- .../page/core/config/PageConfiguration.java | 2 +- .../core/config/PageObjectConfigurator.java | 1 + .../e2e/page/core/pages/PageContent.java | 2 +- .../e2e/page/core/utils/AlertUtil.java | 20 ++++++++ .../scada-lts-e2e-page-impl/pom.xml | 2 +- .../page/impl/groovy/ConfigurationUtil.java | 19 ++++++++ .../eventhandlers/EventHandlersPage.java | 4 +- scada-lts-e2e-service/pom.xml | 2 +- .../scada-lts-e2e-service-api/pom.xml | 2 +- .../scada-lts-e2e-service-core/pom.xml | 2 +- .../core/services/get/GetServiceObject.java | 22 ++++++--- .../core/utils/UniversalServiceUtil.java | 25 ++++++++-- .../scada-lts-e2e-service-impl/pom.xml | 2 +- scada-lts-e2e-test/pom.xml | 2 +- .../scada-lts-e2e-test-api/pom.xml | 2 +- .../scada-lts-e2e-test-core/pom.xml | 2 +- .../core/config/TestCoreConfigurator.java | 5 ++ .../providers/TestClassesProviderImpl.java | 3 +- .../scada-lts-e2e-test-impl/pom.xml | 2 +- .../creators/EventHandlerObjectsCreator.java | 2 +- .../e2e/test/impl/groovy/GroovyEngine.java | 10 ++-- .../ScadaTestClassByPlanProvider.java | 3 +- .../e2e/test/impl/utils/TestWithPageUtil.java | 8 ++-- .../test/impl/utils/TestWithoutPageUtil.java | 5 ++ .../groovy/check/website/WebsiteTest.groovy | 46 +++++++++++++++++++ .../resources/groovy/groovy-config.properties | 2 +- .../MonitoringSizeWorkItemsLongerTest.groovy | 5 +- .../MonitoringThreadsStatusBlockedTest.groovy | 6 +-- 47 files changed, 201 insertions(+), 52 deletions(-) create mode 100644 scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/resources/groovy/check/website/WebsiteTest.groovy diff --git a/pom.xml b/pom.xml index f89dc50a..76d3bbf8 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.scadalts scada-lts-e2e Scada-LTS-E2E - 23.0.9-SNAPSHOT + 23.0.11-SNAPSHOT pom @@ -813,6 +813,7 @@ 0 5 4 * * ? 0 5 4 * * ? false + false @@ -876,6 +877,7 @@ 0 5 4 * * ? 0 5 4 * * ? false + false @@ -939,6 +941,7 @@ 0 5 4 * * ? 0 5 4 * * ? false + false @@ -1005,6 +1008,7 @@ 0 5 4 * * ? 0 5 4 * * ? false + false diff --git a/scada-lts-e2e-app/pom.xml b/scada-lts-e2e-app/pom.xml index 86240093..87ef1f89 100644 --- a/scada-lts-e2e-app/pom.xml +++ b/scada-lts-e2e-app/pom.xml @@ -5,7 +5,7 @@ org.scadalts scada-lts-e2e - 23.0.9-SNAPSHOT + 23.0.11-SNAPSHOT 4.0.0 diff --git a/scada-lts-e2e-cli/pom.xml b/scada-lts-e2e-cli/pom.xml index 29763f20..7146d3ea 100644 --- a/scada-lts-e2e-cli/pom.xml +++ b/scada-lts-e2e-cli/pom.xml @@ -5,7 +5,7 @@ org.scadalts scada-lts-e2e - 23.0.9-SNAPSHOT + 23.0.11-SNAPSHOT 4.0.0 diff --git a/scada-lts-e2e-cli/src/main/java/org/scadalts/e2e/cli/config/E2eConfigCli.java b/scada-lts-e2e-cli/src/main/java/org/scadalts/e2e/cli/config/E2eConfigCli.java index 639c99f6..23ff697c 100644 --- a/scada-lts-e2e-cli/src/main/java/org/scadalts/e2e/cli/config/E2eConfigCli.java +++ b/scada-lts-e2e-cli/src/main/java/org/scadalts/e2e/cli/config/E2eConfigCli.java @@ -2,7 +2,6 @@ import lombok.Builder; import lombok.EqualsAndHashCode; -import lombok.ToString; import org.apache.logging.log4j.Level; import org.scadalts.e2e.cli.commands.E2eCommand; import org.scadalts.e2e.cli.commands.RunAppCommand; @@ -280,6 +279,11 @@ public String getUnblockSendFailEmailCron() { return fromRunApp.getUnblockSendFailEmailCron(); } + @Override + public boolean isLoginDisabled() { + return fromE2e.isLoginDisabled(); + } + @Override public String toString() { return "\nportApp=" + getPortApp() + diff --git a/scada-lts-e2e-cli/src/main/java/org/scadalts/e2e/cli/options/DefaultOptions.java b/scada-lts-e2e-cli/src/main/java/org/scadalts/e2e/cli/options/DefaultOptions.java index 8e702618..cd47b30b 100644 --- a/scada-lts-e2e-cli/src/main/java/org/scadalts/e2e/cli/options/DefaultOptions.java +++ b/scada-lts-e2e-cli/src/main/java/org/scadalts/e2e/cli/options/DefaultOptions.java @@ -11,6 +11,6 @@ public class DefaultOptions { @Option(names = {"-v", "--version"}, versionHelp = true) private boolean version; - @Option(names = {"-h", "--help"}, usageHelp = true) + @Option(names = {"-h", "--help", "-?", "-help"}, usageHelp = true) private boolean help; } diff --git a/scada-lts-e2e-cli/src/main/java/org/scadalts/e2e/cli/options/ScadaOptions.java b/scada-lts-e2e-cli/src/main/java/org/scadalts/e2e/cli/options/ScadaOptions.java index 53601acd..17726b75 100644 --- a/scada-lts-e2e-cli/src/main/java/org/scadalts/e2e/cli/options/ScadaOptions.java +++ b/scada-lts-e2e-cli/src/main/java/org/scadalts/e2e/cli/options/ScadaOptions.java @@ -41,4 +41,7 @@ public class ScadaOptions extends TestOptions { @CommandLine.Option(names = {"-J", "--data-point-source-xid"}) private String dataPointSourceXid; + @CommandLine.Option(names = {"-ld", "--login-disabled-"}, negatable = true) + private boolean loginDisabled; + } diff --git a/scada-lts-e2e-common/pom.xml b/scada-lts-e2e-common/pom.xml index a6409f66..9546646a 100644 --- a/scada-lts-e2e-common/pom.xml +++ b/scada-lts-e2e-common/pom.xml @@ -6,7 +6,7 @@ scada-lts-e2e org.scadalts - 23.0.9-SNAPSHOT + 23.0.11-SNAPSHOT 4.0.0 scada-lts-e2e-common diff --git a/scada-lts-e2e-common/scada-lts-e2e-common-api/pom.xml b/scada-lts-e2e-common/scada-lts-e2e-common-api/pom.xml index 6b0ad3ce..25fac312 100644 --- a/scada-lts-e2e-common/scada-lts-e2e-common-api/pom.xml +++ b/scada-lts-e2e-common/scada-lts-e2e-common-api/pom.xml @@ -5,7 +5,7 @@ scada-lts-e2e-common org.scadalts - 23.0.9-SNAPSHOT + 23.0.11-SNAPSHOT 4.0.0 jar diff --git a/scada-lts-e2e-common/scada-lts-e2e-common-core/pom.xml b/scada-lts-e2e-common/scada-lts-e2e-common-core/pom.xml index e679402c..2b0393a9 100644 --- a/scada-lts-e2e-common/scada-lts-e2e-common-core/pom.xml +++ b/scada-lts-e2e-common/scada-lts-e2e-common-core/pom.xml @@ -5,7 +5,7 @@ scada-lts-e2e-common org.scadalts - 23.0.9-SNAPSHOT + 23.0.11-SNAPSHOT 4.0.0 jar diff --git a/scada-lts-e2e-common/scada-lts-e2e-common-core/src/main/java/org/scadalts/e2e/common/core/config/E2eConfig.java b/scada-lts-e2e-common/scada-lts-e2e-common-core/src/main/java/org/scadalts/e2e/common/core/config/E2eConfig.java index 74b3bb3f..be6b44be 100644 --- a/scada-lts-e2e-common/scada-lts-e2e-common-core/src/main/java/org/scadalts/e2e/common/core/config/E2eConfig.java +++ b/scada-lts-e2e-common/scada-lts-e2e-common-core/src/main/java/org/scadalts/e2e/common/core/config/E2eConfig.java @@ -116,6 +116,7 @@ public interface E2eConfig { boolean isUnblockSendEmailByCron(); String getUnblockSendSuccessEmailCron(); String getUnblockSendFailEmailCron(); + boolean isLoginDisabled(); static E2eConfig defaultConfig() { return new E2eConfigDefault(); diff --git a/scada-lts-e2e-common/scada-lts-e2e-common-core/src/main/java/org/scadalts/e2e/common/core/config/E2eConfigDefault.java b/scada-lts-e2e-common/scada-lts-e2e-common-core/src/main/java/org/scadalts/e2e/common/core/config/E2eConfigDefault.java index e1d13f04..81e06588 100644 --- a/scada-lts-e2e-common/scada-lts-e2e-common-core/src/main/java/org/scadalts/e2e/common/core/config/E2eConfigDefault.java +++ b/scada-lts-e2e-common/scada-lts-e2e-common-core/src/main/java/org/scadalts/e2e/common/core/config/E2eConfigDefault.java @@ -3,7 +3,6 @@ import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; -import lombok.ToString; import org.apache.logging.log4j.Level; import org.scadalts.e2e.common.core.types.AuthType; import org.scadalts.e2e.common.core.types.BrowserRef; @@ -84,6 +83,7 @@ class E2eConfigDefault implements E2eConfig { private boolean unblockSendEmailByCron; private String unblockSendSuccessEmailCron; private String unblockSendFailEmailCron; + private boolean loginDisabled; @Override public String toString() { diff --git a/scada-lts-e2e-common/scada-lts-e2e-common-core/src/main/java/org/scadalts/e2e/common/core/config/E2eConfiguration.java b/scada-lts-e2e-common/scada-lts-e2e-common-core/src/main/java/org/scadalts/e2e/common/core/config/E2eConfiguration.java index 9552a627..861a15b2 100644 --- a/scada-lts-e2e-common/scada-lts-e2e-common-core/src/main/java/org/scadalts/e2e/common/core/config/E2eConfiguration.java +++ b/scada-lts-e2e-common/scada-lts-e2e-common-core/src/main/java/org/scadalts/e2e/common/core/config/E2eConfiguration.java @@ -17,6 +17,7 @@ public class E2eConfiguration { public static URL baseUrl; public static String sessionId; public static boolean checkAuthentication = false; + public static boolean loginDisabled = true; static { try { diff --git a/scada-lts-e2e-common/scada-lts-e2e-common-core/src/main/java/org/scadalts/e2e/common/core/config/E2eConfigurator.java b/scada-lts-e2e-common/scada-lts-e2e-common-core/src/main/java/org/scadalts/e2e/common/core/config/E2eConfigurator.java index c9e0daa3..2504cf9c 100644 --- a/scada-lts-e2e-common/scada-lts-e2e-common-core/src/main/java/org/scadalts/e2e/common/core/config/E2eConfigurator.java +++ b/scada-lts-e2e-common/scada-lts-e2e-common-core/src/main/java/org/scadalts/e2e/common/core/config/E2eConfigurator.java @@ -24,6 +24,7 @@ public static void init(E2eConfig config) { E2eConfiguration.username = config.getUserName(); E2eConfiguration.logLevel = config.getLogLevel(); E2eConfiguration.checkAuthentication = config.isCheckAuthentication(); + E2eConfiguration.loginDisabled = config.isLoginDisabled(); org.apache.logging.log4j.core.config.Configurator.setRootLevel(config.getLogLevel()); org.apache.logging.log4j.core.config.Configurator.setAllLevels("org.apache.logging.log4j", config.getLogLevel()); } diff --git a/scada-lts-e2e-common/scada-lts-e2e-common-core/src/main/java/org/scadalts/e2e/common/core/types/TestPlan.java b/scada-lts-e2e-common/scada-lts-e2e-common-core/src/main/java/org/scadalts/e2e/common/core/types/TestPlan.java index 466ce7ef..3f1f1a28 100644 --- a/scada-lts-e2e-common/scada-lts-e2e-common-core/src/main/java/org/scadalts/e2e/common/core/types/TestPlan.java +++ b/scada-lts-e2e-common/scada-lts-e2e-common-core/src/main/java/org/scadalts/e2e/common/core/types/TestPlan.java @@ -4,5 +4,6 @@ public enum TestPlan { SERVICE, PAGE, CHECK, PAGE_SERVICE, SERVICE_PAGE, ALL, ANY, LOGIN, LOGOUT, AUTO_CONFIG, CONFIG_AUTO, EXPORT, IMPORT, CLEAN, PERFORMANCE, PERF, ALARM_NOTIFICATION_AUTO_CONFIG, PROD, FROM_GROOVY_SCRIPT, ALARM_STORUNG, - GEN_BACKSTOP_CONFIG, EVENT_HANDLER_SERVICE, EVENT_DETECTOR_SERVICE, CONFIG_PROD_CHECKER + GEN_BACKSTOP_CONFIG, EVENT_HANDLER_SERVICE, EVENT_DETECTOR_SERVICE, CONFIG_PROD_CHECKER, + GROOVY_SCRIPT } diff --git a/scada-lts-e2e-common/scada-lts-e2e-common-core/src/main/resources/config/scadalts-e2e-config.properties b/scada-lts-e2e-common/scada-lts-e2e-common-core/src/main/resources/config/scadalts-e2e-config.properties index fa61bbae..40ee0bb5 100644 --- a/scada-lts-e2e-common/scada-lts-e2e-common-core/src/main/resources/config/scadalts-e2e-config.properties +++ b/scada-lts-e2e-common/scada-lts-e2e-common-core/src/main/resources/config/scadalts-e2e-config.properties @@ -67,3 +67,5 @@ test.e2e.data-point-name=${test.e2e.data-point-name} test.e2e.data-point-source-xid=${test.e2e.data-point-source-xid} test.e2e.data-point-target-xid=${test.e2e.data-point-target-xid} +test.e2e.login-disabled=${test.e2e.login-disabled} + diff --git a/scada-lts-e2e-common/scada-lts-e2e-common-impl/pom.xml b/scada-lts-e2e-common/scada-lts-e2e-common-impl/pom.xml index b325086a..a0fbd7a6 100644 --- a/scada-lts-e2e-common/scada-lts-e2e-common-impl/pom.xml +++ b/scada-lts-e2e-common/scada-lts-e2e-common-impl/pom.xml @@ -5,7 +5,7 @@ scada-lts-e2e-common org.scadalts - 23.0.9-SNAPSHOT + 23.0.11-SNAPSHOT 4.0.0 jar diff --git a/scada-lts-e2e-page/pom.xml b/scada-lts-e2e-page/pom.xml index aa218a73..7a007e55 100644 --- a/scada-lts-e2e-page/pom.xml +++ b/scada-lts-e2e-page/pom.xml @@ -6,7 +6,7 @@ scada-lts-e2e org.scadalts - 23.0.9-SNAPSHOT + 23.0.11-SNAPSHOT 4.0.0 diff --git a/scada-lts-e2e-page/scada-lts-e2e-page-api/pom.xml b/scada-lts-e2e-page/scada-lts-e2e-page-api/pom.xml index a7c54066..ec6a61ff 100644 --- a/scada-lts-e2e-page/scada-lts-e2e-page-api/pom.xml +++ b/scada-lts-e2e-page/scada-lts-e2e-page-api/pom.xml @@ -5,7 +5,7 @@ scada-lts-e2e-page org.scadalts - 23.0.9-SNAPSHOT + 23.0.11-SNAPSHOT 4.0.0 scada-lts-e2e-page-api diff --git a/scada-lts-e2e-page/scada-lts-e2e-page-core/pom.xml b/scada-lts-e2e-page/scada-lts-e2e-page-core/pom.xml index b3112eb6..2ae15630 100644 --- a/scada-lts-e2e-page/scada-lts-e2e-page-core/pom.xml +++ b/scada-lts-e2e-page/scada-lts-e2e-page-core/pom.xml @@ -5,7 +5,7 @@ scada-lts-e2e-page org.scadalts - 23.0.9-SNAPSHOT + 23.0.11-SNAPSHOT 4.0.0 diff --git a/scada-lts-e2e-page/scada-lts-e2e-page-core/src/main/java/org/scadalts/e2e/page/core/config/PageConfiguration.java b/scada-lts-e2e-page/scada-lts-e2e-page-core/src/main/java/org/scadalts/e2e/page/core/config/PageConfiguration.java index bec2e5a9..0d889516 100644 --- a/scada-lts-e2e-page/scada-lts-e2e-page-core/src/main/java/org/scadalts/e2e/page/core/config/PageConfiguration.java +++ b/scada-lts-e2e-page/scada-lts-e2e-page-core/src/main/java/org/scadalts/e2e/page/core/config/PageConfiguration.java @@ -1,7 +1,6 @@ package org.scadalts.e2e.page.core.config; import org.openqa.selenium.Keys; -import org.scadalts.e2e.page.core.config.webdriver.GetConfigForSystem; import org.scadalts.e2e.page.core.config.webdriver.SystemConfig; import java.io.File; @@ -14,5 +13,6 @@ public class PageConfiguration { public static long timeout = 6001; public static boolean headless = true; public static String reportsUrl = ""; + public static String baseUrl = "http://localhost:8080/"; } diff --git a/scada-lts-e2e-page/scada-lts-e2e-page-core/src/main/java/org/scadalts/e2e/page/core/config/PageObjectConfigurator.java b/scada-lts-e2e-page/scada-lts-e2e-page-core/src/main/java/org/scadalts/e2e/page/core/config/PageObjectConfigurator.java index 8fa04aca..43af0b53 100644 --- a/scada-lts-e2e-page/scada-lts-e2e-page-core/src/main/java/org/scadalts/e2e/page/core/config/PageObjectConfigurator.java +++ b/scada-lts-e2e-page/scada-lts-e2e-page-core/src/main/java/org/scadalts/e2e/page/core/config/PageObjectConfigurator.java @@ -45,6 +45,7 @@ public static void init(E2eConfig config) { Configuration.proxyPort = config.getPortProxy(); PageConfiguration.timeout = config.getTimeoutMs(); PageConfiguration.headless = config.isHeadlessMode(); + PageConfiguration.baseUrl = config.getUrlAppBeingTested().toString(); Configuration.pageLoadTimeout = PageConfiguration.timeout; Configurator.setRootLevel(config.getLogLevel()); diff --git a/scada-lts-e2e-page/scada-lts-e2e-page-core/src/main/java/org/scadalts/e2e/page/core/pages/PageContent.java b/scada-lts-e2e-page/scada-lts-e2e-page-core/src/main/java/org/scadalts/e2e/page/core/pages/PageContent.java index d2b0b011..76c9d04a 100644 --- a/scada-lts-e2e-page/scada-lts-e2e-page-core/src/main/java/org/scadalts/e2e/page/core/pages/PageContent.java +++ b/scada-lts-e2e-page/scada-lts-e2e-page-core/src/main/java/org/scadalts/e2e/page/core/pages/PageContent.java @@ -36,7 +36,7 @@ default boolean containsText(String text) { default T acceptAlertOnPageSlow() { try { - switchTo().alert().accept(); + AlertUtil.acceptAlertSlow(); } catch (Throwable ex) { } diff --git a/scada-lts-e2e-page/scada-lts-e2e-page-core/src/main/java/org/scadalts/e2e/page/core/utils/AlertUtil.java b/scada-lts-e2e-page/scada-lts-e2e-page-core/src/main/java/org/scadalts/e2e/page/core/utils/AlertUtil.java index 1de068af..365258b0 100644 --- a/scada-lts-e2e-page/scada-lts-e2e-page-core/src/main/java/org/scadalts/e2e/page/core/utils/AlertUtil.java +++ b/scada-lts-e2e-page/scada-lts-e2e-page-core/src/main/java/org/scadalts/e2e/page/core/utils/AlertUtil.java @@ -17,6 +17,14 @@ public static void acceptAlert() { executeJavaScript(JavascriptWindow.ACCEPT_ALERT.getScriptToExecute()); } + public static void acceptAlertSlow() { + try { + Selenide.switchTo().alert().accept(); + } catch (Throwable th) { + + } + } + public static void dismissAlert() { executeJavaScript(JavascriptWindow.DISMISS_ALERT.getScriptToExecute()); } @@ -26,11 +34,23 @@ public static void acceptAfterClick(SelenideElement selenideElement) { selenideElement.click(); } + public static void acceptAfterClickSlow(SelenideElement selenideElement) { + //executeJavaScript(JavascriptWindow.ACCEPT_ALERT.getScriptToExecute()); + selenideElement.click(); + acceptAlertSlow(); + } + public static void acceptAfterClick(E2eWebElement selenideElement) { executeJavaScript(JavascriptWindow.ACCEPT_ALERT.getScriptToExecute()); selenideElement.click(); } + public static void acceptAfterClickSlow(E2eWebElement selenideElement) { + //executeJavaScript(JavascriptWindow.ACCEPT_ALERT.getScriptToExecute()); + selenideElement.click(); + acceptAlertSlow(); + } + public static void acceptAlert(Procedure procedure) { executeJavaScript(JavascriptWindow.ACCEPT_ALERT.getScriptToExecute()); procedure.invoke(); diff --git a/scada-lts-e2e-page/scada-lts-e2e-page-impl/pom.xml b/scada-lts-e2e-page/scada-lts-e2e-page-impl/pom.xml index 732c934f..78f5c346 100644 --- a/scada-lts-e2e-page/scada-lts-e2e-page-impl/pom.xml +++ b/scada-lts-e2e-page/scada-lts-e2e-page-impl/pom.xml @@ -5,7 +5,7 @@ scada-lts-e2e-page org.scadalts - 23.0.9-SNAPSHOT + 23.0.11-SNAPSHOT 4.0.0 scada-lts-e2e-page-impl diff --git a/scada-lts-e2e-page/scada-lts-e2e-page-impl/src/main/java/org/scadalts/e2e/page/impl/groovy/ConfigurationUtil.java b/scada-lts-e2e-page/scada-lts-e2e-page-impl/src/main/java/org/scadalts/e2e/page/impl/groovy/ConfigurationUtil.java index 16c5fb85..ecabd867 100644 --- a/scada-lts-e2e-page/scada-lts-e2e-page-impl/src/main/java/org/scadalts/e2e/page/impl/groovy/ConfigurationUtil.java +++ b/scada-lts-e2e-page/scada-lts-e2e-page-impl/src/main/java/org/scadalts/e2e/page/impl/groovy/ConfigurationUtil.java @@ -1,5 +1,11 @@ package org.scadalts.e2e.page.impl.groovy; +import com.codeborne.selenide.Configuration; +import org.scadalts.e2e.common.core.config.E2eConfiguration; + +import java.net.MalformedURLException; +import java.net.URL; + public final class ConfigurationUtil { private static boolean PAGE_MODE = true; @@ -23,4 +29,17 @@ public static void pageMode(boolean pageMode) { public static boolean isPageMode() { return PAGE_MODE; } + + public static void baseUrl(String baseUrl) { + Configuration.baseUrl = baseUrl; + try { + E2eConfiguration.baseUrl = new URL(baseUrl); + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + } + + public static void loginDisabled(boolean disabledLogin) { + E2eConfiguration.loginDisabled = disabledLogin; + } } diff --git a/scada-lts-e2e-page/scada-lts-e2e-page-impl/src/main/java/org/scadalts/e2e/page/impl/pages/eventhandlers/EventHandlersPage.java b/scada-lts-e2e-page/scada-lts-e2e-page-impl/src/main/java/org/scadalts/e2e/page/impl/pages/eventhandlers/EventHandlersPage.java index 8d5d1a4e..c2aeedc9 100644 --- a/scada-lts-e2e-page/scada-lts-e2e-page-impl/src/main/java/org/scadalts/e2e/page/impl/pages/eventhandlers/EventHandlersPage.java +++ b/scada-lts-e2e-page/scada-lts-e2e-page-impl/src/main/java/org/scadalts/e2e/page/impl/pages/eventhandlers/EventHandlersPage.java @@ -11,11 +11,11 @@ import org.scadalts.e2e.page.impl.criterias.EventDetectorCriteria; import org.scadalts.e2e.page.impl.criterias.EventHandlerCriteria; -import java.util.function.Predicate; import static com.codeborne.selenide.Condition.not; import static com.codeborne.selenide.Selenide.page; import static org.scadalts.e2e.page.core.utils.AlertUtil.acceptAfterClick; +import static org.scadalts.e2e.page.core.utils.AlertUtil.acceptAfterClickSlow; import static org.scadalts.e2e.page.core.utils.DynamicElementUtil.*; import static org.scadalts.e2e.page.core.utils.PageStabilityUtil.reopenWhile; import static org.scadalts.e2e.page.core.utils.PageStabilityUtil.waitWhile; @@ -40,7 +40,7 @@ public EventHandlersPage() { public EditEventHandlersPage openEventHandlerCreator(EventDetectorCriteria criteria) { delay(); SelenideElement selenideElement = _findActionInTree(criteria); - acceptAfterClick(selenideElement); + acceptAfterClickSlow(selenideElement); printCurrentUrl(); return page(new EditEventHandlersPage(this)); } diff --git a/scada-lts-e2e-service/pom.xml b/scada-lts-e2e-service/pom.xml index 72e1d666..f8902263 100644 --- a/scada-lts-e2e-service/pom.xml +++ b/scada-lts-e2e-service/pom.xml @@ -5,7 +5,7 @@ scada-lts-e2e org.scadalts - 23.0.9-SNAPSHOT + 23.0.11-SNAPSHOT 4.0.0 diff --git a/scada-lts-e2e-service/scada-lts-e2e-service-api/pom.xml b/scada-lts-e2e-service/scada-lts-e2e-service-api/pom.xml index 11e7232f..91a43f7b 100644 --- a/scada-lts-e2e-service/scada-lts-e2e-service-api/pom.xml +++ b/scada-lts-e2e-service/scada-lts-e2e-service-api/pom.xml @@ -5,7 +5,7 @@ scada-lts-e2e-service org.scadalts - 23.0.9-SNAPSHOT + 23.0.11-SNAPSHOT 4.0.0 diff --git a/scada-lts-e2e-service/scada-lts-e2e-service-core/pom.xml b/scada-lts-e2e-service/scada-lts-e2e-service-core/pom.xml index d104af35..176d58ce 100644 --- a/scada-lts-e2e-service/scada-lts-e2e-service-core/pom.xml +++ b/scada-lts-e2e-service/scada-lts-e2e-service-core/pom.xml @@ -5,7 +5,7 @@ scada-lts-e2e-service org.scadalts - 23.0.9-SNAPSHOT + 23.0.11-SNAPSHOT 4.0.0 diff --git a/scada-lts-e2e-service/scada-lts-e2e-service-core/src/main/java/org/scadalts/e2e/service/core/services/get/GetServiceObject.java b/scada-lts-e2e-service/scada-lts-e2e-service-core/src/main/java/org/scadalts/e2e/service/core/services/get/GetServiceObject.java index 2e95cbfc..e307ad92 100644 --- a/scada-lts-e2e-service/scada-lts-e2e-service-core/src/main/java/org/scadalts/e2e/service/core/services/get/GetServiceObject.java +++ b/scada-lts-e2e-service/scada-lts-e2e-service-core/src/main/java/org/scadalts/e2e/service/core/services/get/GetServiceObject.java @@ -32,6 +32,9 @@ public class GetServiceObject implements WebServiceObject { private final URL baseUrl; private final Client client; + public Optional> getAsString(GetConfig getConfig, long timeout) { + return _get(getConfig, timeout, a -> a); + } public Optional> get(GetConfig getConfig, long timeout, Class clazz) { return _get(getConfig, timeout, a -> { @@ -43,7 +46,7 @@ public Optional> get(GetConfig getConfig, long timeout, Class }); } - public Optional>> getMap(GetConfig getConfig, long timeout, Class token) { + public Optional>> getAsMap(GetConfig getConfig, long timeout, Class token) { return _get(getConfig, timeout, a -> { try { return new ObjectMapper().readValue(a, new TypeReference>() {}); @@ -53,7 +56,7 @@ public Optional>> getMap(GetConfig getConfig, lon }); } - public Optional>> getList(GetConfig getConfig, long timeout, Class token) { + public Optional>> getAsList(GetConfig getConfig, long timeout, Class token) { return _get(getConfig, timeout, a -> { try { return new ObjectMapper().readValue(a, new TypeReference>() {}); @@ -66,7 +69,7 @@ public Optional>> getList(GetConfig getConfig, long time private Optional> _get(GetConfig getConfig, long timeout, Function mapper) { try { E2eResponse response = applyWhile(this::_get, getConfig, mapper, - new StabilityUtil.Timeout(timeout), a -> a.getStatus() == 200); + new StabilityUtil.Timeout(timeout), a -> (a.getStatus() == 200 || a.getStatus() == 301) && a.getValue() != null); return Optional.ofNullable(response); } catch (Throwable e) { logger.error(e.getMessage(), e); @@ -75,17 +78,24 @@ private Optional> _get(GetConfig getConfig, long timeout, Fun } private E2eResponse _get(GetConfig getConfig, Function mapper) { + Response response = doGet(getConfig); + return mapToObject(mapper, response); + } + + private Response doGet(GetConfig getConfig) { String endpoint = baseUrl + getConfig.getEndpoint(); Cookie cookie = CookieFactory.newSessionCookie(E2eConfiguration.sessionId); logger.info("endpoint: {}", endpoint); logger.info("cookie: {}", cookie); MediaType mediaType = MediaType.APPLICATION_JSON_TYPE; - Response response = client - .target(endpoint) + return client.target(endpoint) .request(mediaType) .cookie(cookie) .get(); - return E2eResponseFactory.newResponse(response,mapper.apply(response.readEntity(String.class))); + } + + private static E2eResponse mapToObject(Function mapper, Response response) { + return E2eResponseFactory.newResponse(response, mapper.apply(response.readEntity(String.class))); } @Override diff --git a/scada-lts-e2e-service/scada-lts-e2e-service-core/src/main/java/org/scadalts/e2e/service/core/utils/UniversalServiceUtil.java b/scada-lts-e2e-service/scada-lts-e2e-service-core/src/main/java/org/scadalts/e2e/service/core/utils/UniversalServiceUtil.java index 600a8059..565050a2 100644 --- a/scada-lts-e2e-service/scada-lts-e2e-service-core/src/main/java/org/scadalts/e2e/service/core/utils/UniversalServiceUtil.java +++ b/scada-lts-e2e-service/scada-lts-e2e-service-core/src/main/java/org/scadalts/e2e/service/core/utils/UniversalServiceUtil.java @@ -15,7 +15,16 @@ public final class UniversalServiceUtil { private UniversalServiceUtil() {} - public static E2eResponse> getMap(GetConfig getConfig, long timeout, Class token) { + public static E2eResponse getAsString(GetConfig getConfig, long timeout) { + try { + return _getString(getConfig, timeout); + } catch (Throwable th) { + logger.warn(th.getMessage(), th); + return E2eResponse.empty(); + } + } + + public static E2eResponse> getAsMap(GetConfig getConfig, long timeout, Class token) { try { return _getMap(getConfig, timeout, token); } catch (Throwable th) { @@ -24,7 +33,7 @@ public static E2eResponse> getMap(GetConfig getConfig, long t } } - public static E2eResponse> getList(GetConfig getConfig, long timeout, Class token) { + public static E2eResponse> getAsList(GetConfig getConfig, long timeout, Class token) { try { return _getList(getConfig, timeout, token); } catch (Throwable th) { @@ -45,7 +54,7 @@ public static E2eResponse get(GetConfig getConfig, long timeout, Class private static E2eResponse> _getMap(GetConfig getConfig, long timeout, Class token) { try (GetServiceObject getServiceObject = UniversalServiceObjectFactory.newGetServiceObject()) { - Optional>> responseOpt = getServiceObject.getMap(getConfig, timeout, token); + Optional>> responseOpt = getServiceObject.getAsMap(getConfig, timeout, token); return responseOpt.orElseGet(E2eResponse::empty); } } @@ -53,7 +62,7 @@ private static E2eResponse> _getMap(GetConfig getConfig, long private static E2eResponse> _getList(GetConfig getConfig, long timeout, Class token) { try (GetServiceObject getServiceObject = UniversalServiceObjectFactory.newGetServiceObject()) { - Optional>> responseOpt = getServiceObject.getList(getConfig, timeout, token); + Optional>> responseOpt = getServiceObject.getAsList(getConfig, timeout, token); return responseOpt.orElseGet(E2eResponse::empty); } } @@ -65,4 +74,12 @@ private static E2eResponse _get(GetConfig getConfig, long timeout, Class< return responseOpt.orElseGet(E2eResponse::empty); } } + + private static E2eResponse _getString(GetConfig getConfig, long timeout) { + try (GetServiceObject getServiceObject = + UniversalServiceObjectFactory.newGetServiceObject()) { + Optional> responseOpt = getServiceObject.getAsString(getConfig, timeout); + return responseOpt.orElseGet(E2eResponse::empty); + } + } } diff --git a/scada-lts-e2e-service/scada-lts-e2e-service-impl/pom.xml b/scada-lts-e2e-service/scada-lts-e2e-service-impl/pom.xml index e8a5d9dc..22dbcdba 100644 --- a/scada-lts-e2e-service/scada-lts-e2e-service-impl/pom.xml +++ b/scada-lts-e2e-service/scada-lts-e2e-service-impl/pom.xml @@ -5,7 +5,7 @@ scada-lts-e2e-service org.scadalts - 23.0.9-SNAPSHOT + 23.0.11-SNAPSHOT 4.0.0 diff --git a/scada-lts-e2e-test/pom.xml b/scada-lts-e2e-test/pom.xml index f46809cc..0ee1d5e3 100644 --- a/scada-lts-e2e-test/pom.xml +++ b/scada-lts-e2e-test/pom.xml @@ -6,7 +6,7 @@ scada-lts-e2e org.scadalts - 23.0.9-SNAPSHOT + 23.0.11-SNAPSHOT 4.0.0 diff --git a/scada-lts-e2e-test/scada-lts-e2e-test-api/pom.xml b/scada-lts-e2e-test/scada-lts-e2e-test-api/pom.xml index a5f7ef83..19e2b288 100644 --- a/scada-lts-e2e-test/scada-lts-e2e-test-api/pom.xml +++ b/scada-lts-e2e-test/scada-lts-e2e-test-api/pom.xml @@ -5,7 +5,7 @@ org.scadalts scada-lts-e2e-test - 23.0.9-SNAPSHOT + 23.0.11-SNAPSHOT 4.0.0 diff --git a/scada-lts-e2e-test/scada-lts-e2e-test-core/pom.xml b/scada-lts-e2e-test/scada-lts-e2e-test-core/pom.xml index 5500718b..adef1878 100644 --- a/scada-lts-e2e-test/scada-lts-e2e-test-core/pom.xml +++ b/scada-lts-e2e-test/scada-lts-e2e-test-core/pom.xml @@ -5,7 +5,7 @@ scada-lts-e2e-test org.scadalts - 23.0.9-SNAPSHOT + 23.0.11-SNAPSHOT 4.0.0 diff --git a/scada-lts-e2e-test/scada-lts-e2e-test-core/src/main/java/org/scadalts/e2e/test/core/config/TestCoreConfigurator.java b/scada-lts-e2e-test/scada-lts-e2e-test-core/src/main/java/org/scadalts/e2e/test/core/config/TestCoreConfigurator.java index 0e5aaf76..5192ba58 100644 --- a/scada-lts-e2e-test/scada-lts-e2e-test-core/src/main/java/org/scadalts/e2e/test/core/config/TestCoreConfigurator.java +++ b/scada-lts-e2e-test/scada-lts-e2e-test-core/src/main/java/org/scadalts/e2e/test/core/config/TestCoreConfigurator.java @@ -3,6 +3,7 @@ import lombok.extern.log4j.Log4j2; import org.scadalts.e2e.common.core.config.ConfigHandler; import org.scadalts.e2e.common.core.config.E2eConfig; +import org.scadalts.e2e.common.core.config.E2eConfiguration; import java.util.Objects; @@ -27,4 +28,8 @@ public static void init(E2eConfig config) { public static void init() { init(ConfigHandler.getConfig()); } + + public static boolean isLoginEnabled() { + return !E2eConfiguration.loginDisabled; + } } diff --git a/scada-lts-e2e-test/scada-lts-e2e-test-core/src/main/java/org/scadalts/e2e/test/core/plans/providers/TestClassesProviderImpl.java b/scada-lts-e2e-test/scada-lts-e2e-test-core/src/main/java/org/scadalts/e2e/test/core/plans/providers/TestClassesProviderImpl.java index 50e6b098..e5e3f042 100644 --- a/scada-lts-e2e-test/scada-lts-e2e-test-core/src/main/java/org/scadalts/e2e/test/core/plans/providers/TestClassesProviderImpl.java +++ b/scada-lts-e2e-test/scada-lts-e2e-test-core/src/main/java/org/scadalts/e2e/test/core/plans/providers/TestClassesProviderImpl.java @@ -51,7 +51,8 @@ private boolean isAny(E2eConfig config) { private boolean isGroovyOnly(E2eConfig config) { if(config.getTestPlans().length == 1) { - return config.getTestPlans()[0] == TestPlan.FROM_GROOVY_SCRIPT; + return config.getTestPlans()[0] == TestPlan.FROM_GROOVY_SCRIPT || + config.getTestPlans()[0] == TestPlan.GROOVY_SCRIPT; } return false; } diff --git a/scada-lts-e2e-test/scada-lts-e2e-test-impl/pom.xml b/scada-lts-e2e-test/scada-lts-e2e-test-impl/pom.xml index 4e521c9d..d4eed847 100644 --- a/scada-lts-e2e-test/scada-lts-e2e-test-impl/pom.xml +++ b/scada-lts-e2e-test/scada-lts-e2e-test-impl/pom.xml @@ -5,7 +5,7 @@ scada-lts-e2e-test org.scadalts - 23.0.9-SNAPSHOT + 23.0.11-SNAPSHOT 4.0.0 diff --git a/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/java/org/scadalts/e2e/test/impl/creators/EventHandlerObjectsCreator.java b/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/java/org/scadalts/e2e/test/impl/creators/EventHandlerObjectsCreator.java index 0236187f..3567ea93 100644 --- a/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/java/org/scadalts/e2e/test/impl/creators/EventHandlerObjectsCreator.java +++ b/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/java/org/scadalts/e2e/test/impl/creators/EventHandlerObjectsCreator.java @@ -59,7 +59,7 @@ public EventHandlersPage createObjects() { criteria.getIdentifier().getType(), criteria.getXid().getValue(), criteria.getClass().getSimpleName()); eventHandlersPage.openEventHandlerCreator(criteria.getEventDetectorCriteria()) - .acceptAlert() + .acceptAlertOnPageSlow() .setEventHandlerType(criteria.getIdentifier().getType()) .setXid(criteria.getXid()) .setAlisas(criteria.getIdentifier()) diff --git a/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/java/org/scadalts/e2e/test/impl/groovy/GroovyEngine.java b/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/java/org/scadalts/e2e/test/impl/groovy/GroovyEngine.java index a2a843a9..b7e122d4 100644 --- a/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/java/org/scadalts/e2e/test/impl/groovy/GroovyEngine.java +++ b/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/java/org/scadalts/e2e/test/impl/groovy/GroovyEngine.java @@ -16,6 +16,7 @@ import java.util.Collection; +import static org.scadalts.e2e.test.core.config.TestCoreConfigurator.isLoginEnabled; import static org.scadalts.e2e.test.impl.groovy.CreatorUtil.deleteObjects; import static org.scadalts.e2e.test.impl.groovy.GroovyUtil.getGroovyExecutes; @@ -51,7 +52,8 @@ public void after() { if (TestWithPageUtil.isLogged()) TestWithPageUtil.close(); } else { - if(!E2eConfiguration.checkAuthentication || TestWithoutPageUtil.isApiLogged()) + if(isLoginEnabled() + && (!E2eConfiguration.checkAuthentication || TestWithoutPageUtil.isApiLogged())) TestWithoutPageUtil.close(); } ConfigurationUtil.pageMode(false); @@ -70,11 +72,13 @@ private static void _clean() { deleteObjects(); ConfigurationUtil.headless(PageConfiguration.headless); ConfigurationUtil.path(PageConfiguration.reportsUrl); + ConfigurationUtil.baseUrl(PageConfiguration.baseUrl); if(ConfigurationUtil.isPageMode()) { - if (TestWithPageUtil.isLogged()) + if (isLoginEnabled() && TestWithPageUtil.isLogged()) TestWithPageUtil.close(); } else { - if(TestWithoutPageUtil.isApiLogged()) + if(isLoginEnabled() + && (!E2eConfiguration.checkAuthentication || TestWithoutPageUtil.isApiLogged())) TestWithoutPageUtil.close(); } } diff --git a/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/java/org/scadalts/e2e/test/impl/providers/ScadaTestClassByPlanProvider.java b/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/java/org/scadalts/e2e/test/impl/providers/ScadaTestClassByPlanProvider.java index d383c660..d25b1e70 100644 --- a/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/java/org/scadalts/e2e/test/impl/providers/ScadaTestClassByPlanProvider.java +++ b/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/java/org/scadalts/e2e/test/impl/providers/ScadaTestClassByPlanProvider.java @@ -26,7 +26,7 @@ public class ScadaTestClassByPlanProvider implements TestClassByPlanProvider { - private static Map> tests = new HashMap<>(); + private static final Map> tests = new HashMap<>(); static { tests.put(TestPlan.CHECK, ScadaCheckTestsSuite.class); @@ -48,6 +48,7 @@ public class ScadaTestClassByPlanProvider implements TestClassByPlanProvider { tests.put(TestPlan.PROD, ScadaProdTestsSuite.class); tests.put(TestPlan.CONFIG_PROD_CHECKER, ConfigForProdChecker.class); tests.put(TestPlan.FROM_GROOVY_SCRIPT, GroovyEngine.class); + tests.put(TestPlan.GROOVY_SCRIPT, GroovyEngine.class); tests.put(TestPlan.ALARM_STORUNG, StorungsAndAlarmsServiceTestsSuite.class); tests.put(TestPlan.EVENT_DETECTOR_SERVICE, EventDetectorServiceTestsSuite.class); tests.put(TestPlan.EVENT_HANDLER_SERVICE, EventHandlerServiceTestsSuite.class); diff --git a/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/java/org/scadalts/e2e/test/impl/utils/TestWithPageUtil.java b/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/java/org/scadalts/e2e/test/impl/utils/TestWithPageUtil.java index ad71fc92..1daf9263 100644 --- a/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/java/org/scadalts/e2e/test/impl/utils/TestWithPageUtil.java +++ b/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/java/org/scadalts/e2e/test/impl/utils/TestWithPageUtil.java @@ -21,6 +21,7 @@ import static org.scadalts.e2e.common.core.utils.ExecutorUtil.executeFunction; import static org.scadalts.e2e.page.core.utils.MeasurePrinter.print; +import static org.scadalts.e2e.test.core.config.TestCoreConfigurator.isLoginEnabled; @Log4j2 public class TestWithPageUtil { @@ -59,7 +60,7 @@ public static NavigationPage openNavigationPage(CreatorObject creatorObjec public static NavigationPage openNavigationPage() { _setup(); - if (!E2eConfiguration.checkAuthentication) + if (isLoginEnabled() && !E2eConfiguration.checkAuthentication) close(); return preparingTest(); } @@ -97,7 +98,8 @@ private static NavigationPage preparingTest() { } private static NavigationPage _preparingTest() { - if (!E2eConfiguration.checkAuthentication || !isLogged()) { + if (isLoginEnabled() + && (!E2eConfiguration.checkAuthentication || !isLogged())) { _loginOrThrow(); } return navigationPage; @@ -112,7 +114,7 @@ private static void _loginOrThrow() { private static void _close() { logger.info("close..."); try { - if (navigationPage != null && E2eConfiguration.checkAuthentication && isLogged()) + if (isLoginEnabled() && (navigationPage != null && E2eConfiguration.checkAuthentication && isLogged())) logout(); } finally { if(navigationPage != null) diff --git a/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/java/org/scadalts/e2e/test/impl/utils/TestWithoutPageUtil.java b/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/java/org/scadalts/e2e/test/impl/utils/TestWithoutPageUtil.java index c5d00d1e..0367a9e0 100644 --- a/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/java/org/scadalts/e2e/test/impl/utils/TestWithoutPageUtil.java +++ b/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/java/org/scadalts/e2e/test/impl/utils/TestWithoutPageUtil.java @@ -35,6 +35,7 @@ import java.util.function.Predicate; import static org.scadalts.e2e.common.core.utils.ExecutorUtil.executeFunction; +import static org.scadalts.e2e.test.core.config.TestCoreConfigurator.isLoginEnabled; @Log4j2 public class TestWithoutPageUtil { @@ -50,6 +51,8 @@ public static void preparingTest() { public static void close() { try { + if(!isLoginEnabled()) + return; logout(); } catch (Throwable th) { logger.warn(th.getMessage(), th); @@ -258,6 +261,8 @@ public static int createEventDetectorAndGetId(int dataPointId, EventDetectorCrit private static void _preparingTest() { _setup(); + if(!isLoginEnabled()) + return; if(!E2eConfiguration.checkAuthentication) { _login(); } else if(!isApiLogged()) { diff --git a/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/resources/groovy/check/website/WebsiteTest.groovy b/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/resources/groovy/check/website/WebsiteTest.groovy new file mode 100644 index 00000000..0dbc750c --- /dev/null +++ b/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/resources/groovy/check/website/WebsiteTest.groovy @@ -0,0 +1,46 @@ +package groovy.check.website + +import org.junit.Before +import org.junit.BeforeClass +import org.junit.Test +import org.scadalts.e2e.service.core.services.E2eResponse +import org.scadalts.e2e.service.core.services.get.GetConfig + +import static org.junit.Assert.assertNotNull +import static org.junit.Assert.assertTrue +import static org.scadalts.e2e.page.impl.groovy.ConfigurationUtil.headless +import static org.scadalts.e2e.page.impl.groovy.ConfigurationUtil.baseUrl +import static org.scadalts.e2e.page.impl.groovy.ConfigurationUtil.pageMode + +import org.scadalts.e2e.service.core.utils.UniversalServiceUtil + +class WebsiteTest { + + private static String BASE_URL = "http://www.scada-lts.com"; + + @BeforeClass + static void preconfig() { + headless(true) + pageMode(false) + baseUrl(BASE_URL) + } + + @Before + void config() { + } + + @Test + void test() { + //given: + GetConfig config = new GetConfig("/") + String msg = "Page " + BASE_URL + " is not available!" + + //when: + E2eResponse response = UniversalServiceUtil.getAsString(config, 3000) + String value = response.getValue() + + //then: + assertNotNull(msg, value) + assertTrue(msg, value.contains("Moved Permanently")) + } +} \ No newline at end of file diff --git a/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/resources/groovy/groovy-config.properties b/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/resources/groovy/groovy-config.properties index 2c2c8474..83321f66 100644 --- a/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/resources/groovy/groovy-config.properties +++ b/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/resources/groovy/groovy-config.properties @@ -1,4 +1,4 @@ -add.test.paths=service/monitor/MonitoringSizeWorkItemsLongerTest.groovy;service/monitor/MonitoringThreadsStatusBlockedTest.groovy;Test.groovy;check/graphicalviews/GraphicalViewsScreenshot.groovy;service/monitor/CheckPointValueTest.groovy +add.test.paths=service/monitor/MonitoringSizeWorkItemsLongerTest.groovy;service/monitor/MonitoringThreadsStatusBlockedTest.groovy;Test.groovy;check/graphicalviews/GraphicalViewsScreenshot.groovy;service/monitor/CheckPointValueTest.groovy;check/website/WebsiteTest.groovy run.test=Test.groovy run.test.with-points=CheckPointValueTest.groovy run.test.auto=false diff --git a/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/resources/groovy/service/monitor/MonitoringSizeWorkItemsLongerTest.groovy b/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/resources/groovy/service/monitor/MonitoringSizeWorkItemsLongerTest.groovy index 4e308220..6965a9a9 100644 --- a/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/resources/groovy/service/monitor/MonitoringSizeWorkItemsLongerTest.groovy +++ b/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/resources/groovy/service/monitor/MonitoringSizeWorkItemsLongerTest.groovy @@ -2,6 +2,7 @@ package groovy.service.monitor import org.junit.Before import org.junit.BeforeClass +import org.junit.Test import org.scadalts.e2e.service.core.services.E2eResponse import org.scadalts.e2e.service.core.services.get.GetConfig @@ -39,7 +40,7 @@ class MonitoringSizeWorkItemsLongerTest { void config() { } - @org.junit.Test + @Test void test() { //given: int longer = 1500 @@ -47,7 +48,7 @@ class MonitoringSizeWorkItemsLongerTest { GetConfig config = new GetConfig("/api/work-items/longer/{0}/", String.valueOf(longer)) //when: - E2eResponse> response = UniversalServiceUtil.getMap(config, 3000, Object.class) + E2eResponse> response = UniversalServiceUtil.getAsMap(config, 3000, Object.class) Map type = response.getValue() Integer size = type.get("size") diff --git a/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/resources/groovy/service/monitor/MonitoringThreadsStatusBlockedTest.groovy b/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/resources/groovy/service/monitor/MonitoringThreadsStatusBlockedTest.groovy index 7ddf36d9..5a2ea473 100644 --- a/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/resources/groovy/service/monitor/MonitoringThreadsStatusBlockedTest.groovy +++ b/scada-lts-e2e-test/scada-lts-e2e-test-impl/src/main/resources/groovy/service/monitor/MonitoringThreadsStatusBlockedTest.groovy @@ -2,12 +2,12 @@ package groovy.service.monitor import org.junit.Before import org.junit.BeforeClass +import org.junit.Test import org.scadalts.e2e.service.core.services.E2eResponse import org.scadalts.e2e.service.core.services.get.GetConfig import java.text.MessageFormat -import static org.junit.Assert.assertNotNull import static org.junit.Assert.assertTrue import static org.scadalts.e2e.page.impl.groovy.ConfigurationUtil.headless import static org.scadalts.e2e.page.impl.groovy.ConfigurationUtil.pageMode @@ -39,7 +39,7 @@ class MonitoringThreadsStatusBlockedTest { void config() { } - @org.junit.Test + @Test void test() { //given: String blockedStatus = "BLOCKED" @@ -47,7 +47,7 @@ class MonitoringThreadsStatusBlockedTest { GetConfig config = new GetConfig("/api/threads/states/state/{0}/", blockedStatus) //when: - E2eResponse> response = UniversalServiceUtil.getList(config, 3000, Object.class) + E2eResponse> response = UniversalServiceUtil.getAsList(config, 3000, Object.class) List threads = response.getValue() //then: