From af21ad996b94c9e34d78bf353935b37b382b4238 Mon Sep 17 00:00:00 2001 From: Aliaksei_Ashukha Date: Wed, 9 Feb 2022 19:56:18 +0300 Subject: [PATCH 1/9] EPMHLM-204 Support single version for web and proxy --- .../com/epam/healenium/SelfHealingDriver.java | 18 ++++++++++++++++-- .../com/epam/healenium/SelfHealingEngine.java | 6 ++---- .../com/epam/healenium/client/RestClient.java | 2 +- .../SelfHealingProxyInvocationHandler.java | 6 ++++++ src/main/resources/application.conf | 4 +++- 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/epam/healenium/SelfHealingDriver.java b/src/main/java/com/epam/healenium/SelfHealingDriver.java index 35a1a69..ea32510 100644 --- a/src/main/java/com/epam/healenium/SelfHealingDriver.java +++ b/src/main/java/com/epam/healenium/SelfHealingDriver.java @@ -12,7 +12,10 @@ */ package com.epam.healenium; +import com.epam.healenium.client.RestClient; import com.epam.healenium.handlers.proxy.SelfHealingProxyInvocationHandler; +import com.epam.healenium.service.HealingService; +import com.epam.healenium.service.NodeService; import com.epam.healenium.utils.ProxyFactory; import com.typesafe.config.Config; import org.openqa.selenium.WebDriver; @@ -31,11 +34,22 @@ public interface SelfHealingDriver extends WebDriver { * @return SelfHealingDriver instance */ static SelfHealingDriver create(WebDriver delegate) { - return create(new SelfHealingEngine(delegate)); + SelfHealingEngine selfHealingEngine = new SelfHealingEngine(delegate); + setEngineFields(delegate, selfHealingEngine); + return create(selfHealingEngine); } static SelfHealingDriver create(WebDriver delegate, Config config) { - return create(new SelfHealingEngine(delegate, config)); + SelfHealingEngine selfHealingEngine = new SelfHealingEngine(delegate, config); + setEngineFields(delegate, selfHealingEngine); + return create(selfHealingEngine); + } + + static void setEngineFields(WebDriver delegate, SelfHealingEngine selfHealingEngine) { + Config finalizedConfig = selfHealingEngine.getConfig(); + selfHealingEngine.setClient(new RestClient(finalizedConfig)); + selfHealingEngine.setNodeService(new NodeService(delegate)); + selfHealingEngine.setHealingService(new HealingService(finalizedConfig, delegate)); } static SelfHealingDriver create(SelfHealingEngine engine) { diff --git a/src/main/java/com/epam/healenium/SelfHealingEngine.java b/src/main/java/com/epam/healenium/SelfHealingEngine.java index 560971f..3dc51cf 100644 --- a/src/main/java/com/epam/healenium/SelfHealingEngine.java +++ b/src/main/java/com/epam/healenium/SelfHealingEngine.java @@ -51,6 +51,7 @@ public class SelfHealingEngine { private final Config config; private final WebDriver webDriver; private final double scoreCap; + private final boolean isProxy; private RestClient client; private NodeService nodeService; @@ -67,10 +68,7 @@ public SelfHealingEngine(@NotNull WebDriver delegate, @NotNull Config config) { this.webDriver = delegate; this.config = finalizedConfig; this.scoreCap = finalizedConfig.getDouble("score-cap"); - - this.client = new RestClient(finalizedConfig); - this.nodeService = new NodeService(delegate); - this.healingService = new HealingService(finalizedConfig, delegate); + this.isProxy = finalizedConfig.getBoolean("proxy"); } /** diff --git a/src/main/java/com/epam/healenium/client/RestClient.java b/src/main/java/com/epam/healenium/client/RestClient.java index 2c7222e..a50c246 100644 --- a/src/main/java/com/epam/healenium/client/RestClient.java +++ b/src/main/java/com/epam/healenium/client/RestClient.java @@ -69,7 +69,7 @@ public class RestClient { public RestClient(Config config) { objectMapper = initMapper(); baseUrl = "http://" + config.getString("serverHost") + ":" + config.getInt("serverPort") + "/healenium"; - imitateUrl = "http://" + config.getString("serverHost") + ":" + config.getInt("imitatePort") + "/imitate"; + imitateUrl = "http://" + config.getString("imitateHost") + ":" + config.getInt("imitatePort") + "/imitate"; sessionKey = config.hasPath("sessionKey") ? config.getString("sessionKey") : ""; mapper = new HealeniumMapper(new StackTraceReader()); } diff --git a/src/main/java/com/epam/healenium/handlers/proxy/SelfHealingProxyInvocationHandler.java b/src/main/java/com/epam/healenium/handlers/proxy/SelfHealingProxyInvocationHandler.java index 8140445..fe6f0f0 100644 --- a/src/main/java/com/epam/healenium/handlers/proxy/SelfHealingProxyInvocationHandler.java +++ b/src/main/java/com/epam/healenium/handlers/proxy/SelfHealingProxyInvocationHandler.java @@ -37,9 +37,15 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl switch (method.getName()) { case "findElement": WebElement element = findElement((By) args[0]); + if (engine.isProxy()) { + return element; + } return Optional.ofNullable(element).map(it -> wrapElement(it, loader)).orElse(null); case "findElements": List elements = findElements((By) args[0]); + if (engine.isProxy()) { + return elements; + } return elements.stream().map(it -> wrapElement(it, loader)).collect(Collectors.toList()); case "getCurrentEngine": return engine; diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index 28d4a46..63c30cf 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -4,4 +4,6 @@ heal-enabled = true serverHost = localhost serverPort = 7878 imitatePort = 8000 -backlight-healing = true \ No newline at end of file +backlight-healing = true +imitateHost = localhost +proxy = false \ No newline at end of file From 7c9828f1884eb59a2eb5a4cfc98c839da714040a Mon Sep 17 00:00:00 2001 From: Aliaksei_Ashukha Date: Wed, 9 Feb 2022 20:26:29 +0300 Subject: [PATCH 2/9] EPMHLM-204 Update jacksondatabind --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d498bfc..c6839df 100644 --- a/pom.xml +++ b/pom.xml @@ -69,7 +69,7 @@ 1.3.4 0.4.10 4.1.1 - 2.10.0 + 2.13.1 3.11 1.12 1.7.30 From 33e1543fc3b250b2c3d2458efdb84f9ee88a1c9f Mon Sep 17 00:00:00 2001 From: Aliaksei_Ashukha Date: Thu, 10 Feb 2022 13:44:14 +0300 Subject: [PATCH 3/9] EPMHLM-204 Update version to 3.2.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c6839df..ff8bcb7 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ 4.0.0 com.epam.healenium healenium-web - 3.2.1 + 3.2.2 jar healenium-web healenium web client From b55a1c42ffc280143438fece798b58cc6f221ef5 Mon Sep 17 00:00:00 2001 From: Anatoli Zaitsau Date: Wed, 23 Feb 2022 16:53:45 +0100 Subject: [PATCH 4/9] updating the version of pom xml dependencies --- pom.xml | 67 +++++++------------ .../handlers/processor/ProcessorHandler.java | 1 + .../healenium/handlers/proxy/BaseHandler.java | 1 - .../healenium/mapper/HealeniumMapper.java | 2 - .../healenium/processor/BaseProcessor.java | 1 - .../com/epam/healenium/utils/StackUtils.java | 11 +-- 6 files changed, 25 insertions(+), 58 deletions(-) diff --git a/pom.xml b/pom.xml index ff8bcb7..ae1a40e 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ 4.0.0 com.epam.healenium healenium-web - 3.2.2 + 3.2.3 jar healenium-web healenium web client @@ -66,24 +66,24 @@ UTF-8 1.8 1.8 - 1.3.4 + 3.8.4 + 1.4.2 0.4.10 - 4.1.1 + 4.1.0 2.13.1 - 3.11 - 1.12 - 1.7.30 - 18.0.0 + 3.12.0 + 1.15 + 4.9.3 + 23.0.0 1.4.2.Final - 1.18.20 - 0.7.2 - 9.4.41.v20210516 + 1.18.22 + 0.8.1 + 11.0.8 2.2 - 6.1.2 - 1.16.2 - 5.7.1 - 4.2.0 - 4.9.3 + 6.1.1 + 1.16.3 + 5.8.2 + 5.1.0 @@ -127,7 +127,7 @@ org.apache.maven.plugins maven-source-plugin - 2.2.1 + 3.2.1 attach-sources @@ -141,7 +141,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.9 + 3.3.2 8 @@ -158,7 +158,7 @@ org.apache.maven.plugins maven-jar-plugin - 2.3.1 + 3.2.2 false @@ -168,7 +168,7 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.3 + 1.6.11 true @@ -193,7 +193,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.1 + 3.10.0 8 8 @@ -211,23 +211,22 @@ org.apache.maven maven-artifact - 2.0.11 + ${maven.apache} org.apache.maven maven-compat - 3.8.1 + ${maven.apache} org.apache.maven maven-plugin-api - 3.8.1 + ${maven.apache} com.typesafe config ${typesafe.version} - compile @@ -235,59 +234,45 @@ tree-comparing ${treecomparing.version} - org.seleniumhq.selenium selenium-java ${selenium.version} - compile com.fasterxml.jackson.core jackson-databind ${jacksondatabind.version} - compile org.apache.commons commons-lang3 ${commonslang3.version} - compile commons-codec commons-codec ${commonscodec.version} - compile com.squareup.okhttp3 okhttp ${okhttp3.version} - - org.slf4j - slf4j-simple - ${slf4jsimple.version} - compile - org.jetbrains annotations ${annotations.version} - compile org.mapstruct mapstruct ${mapstruct.version} - compile org.projectlombok lombok ${lombok.version} - compile one.util @@ -298,37 +283,31 @@ org.eclipse.jetty jetty-server ${jettyserver.version} - test org.hamcrest hamcrest-core ${hamcrestcore.version} - test com.codeborne selenide ${selenide.version} - test org.testcontainers junit-jupiter ${testcontainersjunit.version} - test org.junit.jupiter junit-jupiter-engine ${junit.version} - test org.junit.jupiter junit-jupiter-api ${junit.version} - test org.mapstruct diff --git a/src/main/java/com/epam/healenium/handlers/processor/ProcessorHandler.java b/src/main/java/com/epam/healenium/handlers/processor/ProcessorHandler.java index bfe2196..973e0eb 100644 --- a/src/main/java/com/epam/healenium/handlers/processor/ProcessorHandler.java +++ b/src/main/java/com/epam/healenium/handlers/processor/ProcessorHandler.java @@ -6,6 +6,7 @@ public interface ProcessorHandler { /** * validate data before run 'execute' method. And skip whole chain in case fail validate * @return + * validating result */ boolean validate(); diff --git a/src/main/java/com/epam/healenium/handlers/proxy/BaseHandler.java b/src/main/java/com/epam/healenium/handlers/proxy/BaseHandler.java index 30a6836..397b464 100644 --- a/src/main/java/com/epam/healenium/handlers/proxy/BaseHandler.java +++ b/src/main/java/com/epam/healenium/handlers/proxy/BaseHandler.java @@ -15,7 +15,6 @@ import com.epam.healenium.PageAwareBy; import com.epam.healenium.SelfHealingEngine; import com.epam.healenium.config.ProcessorConfig; -import com.epam.healenium.mapper.HealeniumMapper; import com.epam.healenium.model.Context; import com.epam.healenium.processor.BaseProcessor; import com.epam.healenium.utils.ProxyFactory; diff --git a/src/main/java/com/epam/healenium/mapper/HealeniumMapper.java b/src/main/java/com/epam/healenium/mapper/HealeniumMapper.java index e930961..374c61f 100644 --- a/src/main/java/com/epam/healenium/mapper/HealeniumMapper.java +++ b/src/main/java/com/epam/healenium/mapper/HealeniumMapper.java @@ -21,8 +21,6 @@ import com.epam.healenium.treecomparing.Node; import com.epam.healenium.treecomparing.Scored; import com.epam.healenium.utils.StackTraceReader; -import com.epam.healenium.utils.StackUtils; -import lombok.Data; import org.openqa.selenium.By; import java.util.Collection; diff --git a/src/main/java/com/epam/healenium/processor/BaseProcessor.java b/src/main/java/com/epam/healenium/processor/BaseProcessor.java index 6dc9f2f..ea66892 100644 --- a/src/main/java/com/epam/healenium/processor/BaseProcessor.java +++ b/src/main/java/com/epam/healenium/processor/BaseProcessor.java @@ -3,7 +3,6 @@ import com.epam.healenium.SelfHealingEngine; import com.epam.healenium.client.RestClient; import com.epam.healenium.handlers.processor.ProcessorHandler; -import com.epam.healenium.mapper.HealeniumMapper; import com.epam.healenium.model.Context; import com.epam.healenium.service.HealingService; import lombok.Setter; diff --git a/src/main/java/com/epam/healenium/utils/StackUtils.java b/src/main/java/com/epam/healenium/utils/StackUtils.java index 1b7adec..53498fc 100644 --- a/src/main/java/com/epam/healenium/utils/StackUtils.java +++ b/src/main/java/com/epam/healenium/utils/StackUtils.java @@ -12,27 +12,17 @@ */ package com.epam.healenium.utils; -import com.epam.healenium.handlers.proxy.SelfHealingProxyInvocationHandler; -import com.epam.healenium.handlers.proxy.WebElementProxyHandler; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Iterables; -import lombok.NoArgsConstructor; import lombok.experimental.UtilityClass; import lombok.extern.slf4j.Slf4j; -import one.util.streamex.StreamEx; -import org.apache.commons.lang3.StringUtils; -import org.jetbrains.annotations.NotNull; import org.openqa.selenium.By; import java.lang.annotation.Annotation; import java.util.Arrays; -import java.util.Collections; -import java.util.List; import java.util.Map; import java.util.Optional; import java.util.function.Function; import java.util.function.Predicate; -import java.util.stream.Collectors; import java.util.stream.Stream; @Slf4j @@ -109,6 +99,7 @@ private Optional findAnnotatedInTrace(StackTraceElement[] ele /** * @return + * redundant packages */ public Predicate redundantPackages() { return value -> { From 8749fb5575b793b97d1a9881a7ed2623c11c151c Mon Sep 17 00:00:00 2001 From: Aliaksei_Ashukha Date: Wed, 9 Mar 2022 16:57:15 +0300 Subject: [PATCH 5/9] EPMHLM-204 Fix warnings --- src/main/java/com/epam/healenium/utils/StackUtils.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/com/epam/healenium/utils/StackUtils.java b/src/main/java/com/epam/healenium/utils/StackUtils.java index 53498fc..f328432 100644 --- a/src/main/java/com/epam/healenium/utils/StackUtils.java +++ b/src/main/java/com/epam/healenium/utils/StackUtils.java @@ -97,10 +97,6 @@ private Optional findAnnotatedInTrace(StackTraceElement[] ele .findFirst(); } - /** - * @return - * redundant packages - */ public Predicate redundantPackages() { return value -> { Stream skippingPackageStream = Stream.of("java.base", "sun.reflect", "java.lang", "org.gradle", From 812f69935f3548023088818b0883a5ca4d54a141 Mon Sep 17 00:00:00 2001 From: Aliaksei_Ashukha Date: Wed, 9 Mar 2022 18:27:50 +0300 Subject: [PATCH 6/9] EPMHLM-204 Jetty version for java 8 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ae1a40e..01b4910 100644 --- a/pom.xml +++ b/pom.xml @@ -78,7 +78,7 @@ 1.4.2.Final 1.18.22 0.8.1 - 11.0.8 + 10.0.8 2.2 6.1.1 1.16.3 From ee8381c780586c285d2ad4dac436f45cfdd37d0e Mon Sep 17 00:00:00 2001 From: Aliaksei_Ashukha Date: Wed, 9 Mar 2022 18:30:03 +0300 Subject: [PATCH 7/9] EPMHLM-204 Jetty version for java 8 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 01b4910..b2c2aa8 100644 --- a/pom.xml +++ b/pom.xml @@ -78,7 +78,7 @@ 1.4.2.Final 1.18.22 0.8.1 - 10.0.8 + 9.4.41.v20210516 2.2 6.1.1 1.16.3 From b02714ede6967757c6879c35f6dd741d6d6c3b78 Mon Sep 17 00:00:00 2001 From: Aliaksei_Ashukha Date: Wed, 9 Mar 2022 18:41:22 +0300 Subject: [PATCH 8/9] EPMHLM-204 nexus-staging-maven-plugin version fix --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b2c2aa8..8ed13b4 100644 --- a/pom.xml +++ b/pom.xml @@ -168,7 +168,7 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.11 + 1.6.3 true From 032f8c3ad525f6e3229d63de2d1fb56682232308 Mon Sep 17 00:00:00 2001 From: Aliaksei_Ashukha Date: Wed, 9 Mar 2022 19:04:05 +0300 Subject: [PATCH 9/9] EPMHLM-204 Update hlm-backed version --- src/test/resources/compose-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/compose-test.yml b/src/test/resources/compose-test.yml index 7568eb8..9921265 100644 --- a/src/test/resources/compose-test.yml +++ b/src/test/resources/compose-test.yml @@ -17,7 +17,7 @@ services: - healenium healenium: - image: healenium/hlm-backend:3.2.0 + image: healenium/hlm-backend:3.2.1 ports: - "7878:7878" links: