From 5268e338f0b19f8aec69bb0c291001abd34f1e26 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Tue, 17 Dec 2024 15:30:01 +0530 Subject: [PATCH 01/28] changed to constants in SingleModLibertyLSTestCommon and SingleModJakartaLSTestCommon --- .../tools/intellij/util/Constants.java | 14 ++++ .../it/SingleModJakartaLSTestCommon.java | 35 +++++----- .../it/SingleModLibertyLSTestCommon.java | 69 ++++++++++--------- 3 files changed, 67 insertions(+), 51 deletions(-) diff --git a/src/main/java/io/openliberty/tools/intellij/util/Constants.java b/src/main/java/io/openliberty/tools/intellij/util/Constants.java index 275899b57..3bb63f71c 100644 --- a/src/main/java/io/openliberty/tools/intellij/util/Constants.java +++ b/src/main/java/io/openliberty/tools/intellij/util/Constants.java @@ -94,4 +94,18 @@ public final class Constants { public static final String JAKARTA_LANG_SERVER="Eclipse LSP4Jakarta"; public static final String MICROPROFILE_SERVER="Eclipse LSP4MP"; + /** + * Constants for Integration testing + */ + public static final String SYSTEM_RESOURCE_JAVA = "SystemResource.java"; + public static final String SYSTEM_RESOURCE_2_JAVA = "SystemResource2.java"; + public static final String SYSTEM_RESOURCE = "SystemResource"; + public static final String SYSTEM_RESOURCE_2 = "SystemResource2"; + public static final String SERVER_XML = "server.xml"; + public static final String SERVER_ENV = "server.env"; + public static final String BOOTSTRAP_PROPERTIES = "bootstrap.properties"; + public static final String COMPACT_MODE = "Compact Mode"; + + + } diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java index 73eadc194..7f1a40952 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java @@ -13,6 +13,7 @@ import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.fixtures.JTreeFixture; import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture; +import io.openliberty.tools.intellij.util.Constants; import org.junit.jupiter.api.*; import java.nio.file.Path; @@ -61,8 +62,8 @@ public void afterEach(TestInfo info) { public static void cleanup() { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2)); - UIBotTestUtils.closeFileEditorTab(remoteRobot, "SystemResource.java", "5"); - UIBotTestUtils.closeFileEditorTab(remoteRobot, "SystemResource2.java", "5"); + UIBotTestUtils.closeFileEditorTab(remoteRobot, Constants.SYSTEM_RESOURCE_JAVA, "5"); + UIBotTestUtils.closeFileEditorTab(remoteRobot, Constants.SYSTEM_RESOURCE_2_JAVA, "5"); UIBotTestUtils.closeProjectView(remoteRobot); UIBotTestUtils.closeProjectFrame(remoteRobot); @@ -80,7 +81,7 @@ public void testInsertJakartaCodeSnippetIntoJavaPart() { String insertedCode = "public String methodname() {"; // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, "SystemResource.java"); + UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SYSTEM_RESOURCE_JAVA); // Save the current content. UIBotTestUtils.copyWindowContent(remoteRobot); @@ -90,8 +91,8 @@ public void testInsertJakartaCodeSnippetIntoJavaPart() { // Insert a code snippet into java part try { - UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, "SystemResource.java", snippetStr, snippetChooser); - Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "system", "SystemResource.java"); + UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, Constants.SYSTEM_RESOURCE_JAVA, snippetStr, snippetChooser); + Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "system", Constants.SYSTEM_RESOURCE_JAVA); TestUtils.validateCodeInJavaSrc(pathToSrc.toString(), insertedCode); } finally { @@ -109,28 +110,28 @@ public void testJakartaDiagnosticsInJavaPart() { String privateString = "private Response getProperties() {"; String flaggedString = "getProperties"; String expectedHoverData = "Only public methods can be exposed as resource methods"; - Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "system", "SystemResource2.java"); + Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "system", Constants.SYSTEM_RESOURCE_2_JAVA); // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, "SystemResource2.java"); + UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SYSTEM_RESOURCE_2_JAVA); // Modify the method signature - UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, "SystemResource2.java", publicString, privateString); + UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, Constants.SYSTEM_RESOURCE_2_JAVA, publicString, privateString); try { // validate the method signature is no longer set to public TestUtils.validateStringNotInFile(pathToSrc.toString(), publicString); //there should be a diagnostic for "private" on method signature - move cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, "SystemResource2.java", UIBotTestUtils.PopupType.DIAGNOSTIC); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, Constants.SYSTEM_RESOURCE_2_JAVA, UIBotTestUtils.PopupType.DIAGNOSTIC); String foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC); TestUtils.validateHoverData(expectedHoverData, foundHoverData); - UIBotTestUtils.clickOnFileTab(remoteRobot, "SystemResource2.java"); + UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SYSTEM_RESOURCE_2_JAVA); } finally { // Replace modified content with the original content - UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, "SystemResource2.java", privateString, publicString); + UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, Constants.SYSTEM_RESOURCE_2_JAVA, privateString, publicString); } } @@ -144,24 +145,24 @@ public void testJakartaQuickFixInJavaPart() { String privateString = "private Response getProperties() {"; String flaggedString = "getProperties"; - Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "system", "SystemResource2.java"); + Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "system", Constants.SYSTEM_RESOURCE_2_JAVA); String quickfixChooserString = "Make method public"; // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, "SystemResource2.java"); + UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SYSTEM_RESOURCE_2_JAVA); // Save the current content. UIBotTestUtils.copyWindowContent(remoteRobot); // Modify the method signature - UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, "SystemResource2.java", publicString, privateString); + UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, Constants.SYSTEM_RESOURCE_2_JAVA, publicString, privateString); try { // validate public signature no longer found in java part TestUtils.validateStringNotInFile(pathToSrc.toString(), publicString); //there should be a diagnostic - move cursor to hover point - UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, "SystemResource2.java", quickfixChooserString); + UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, Constants.SYSTEM_RESOURCE_2_JAVA, quickfixChooserString); // trigger and use the quickfix popup attached to the diagnostic UIBotTestUtils.chooseQuickFix(remoteRobot, quickfixChooserString); @@ -200,8 +201,8 @@ public static void prepareEnv(String projectPath, String projectName) { // must be expanded here before trying to open specific files projTree.expand(projectName, "src", "main", "java", "io.openliberty.mp.sample", "system"); - UIBotTestUtils.openFile(remoteRobot, projectName, "SystemResource", projectName, "src", "main", "java", "io.openliberty.mp.sample", "system"); - UIBotTestUtils.openFile(remoteRobot, projectName, "SystemResource2", projectName, "src", "main", "java", "io.openliberty.mp.sample", "system"); + UIBotTestUtils.openFile(remoteRobot, projectName, Constants.SYSTEM_RESOURCE, projectName, "src", "main", "java", "io.openliberty.mp.sample", "system"); + UIBotTestUtils.openFile(remoteRobot, projectName, Constants.SYSTEM_RESOURCE_2, projectName, "src", "main", "java", "io.openliberty.mp.sample", "system"); // Removes the build tool window if it is opened. This prevents text to be hidden by it. diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java index 9e2a0833b..8c496339b 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -14,6 +14,7 @@ import com.intellij.remoterobot.fixtures.JTreeFixture; import com.intellij.remoterobot.utils.Keyboard; import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture; +import io.openliberty.tools.intellij.util.Constants; import org.junit.jupiter.api.*; import java.nio.file.Path; @@ -64,11 +65,11 @@ public void afterEach(TestInfo info) { */ @AfterAll public static void cleanup() { - UIBotTestUtils.closeFileEditorTab(remoteRobot, "server.xml", "5"); - UIBotTestUtils.closeFileEditorTab(remoteRobot, "server.env", "5"); - UIBotTestUtils.closeFileEditorTab(remoteRobot, "bootstrap.properties", "5"); + UIBotTestUtils.closeFileEditorTab(remoteRobot, Constants.SERVER_XML, "5"); + UIBotTestUtils.closeFileEditorTab(remoteRobot, Constants.SERVER_ENV, "5"); + UIBotTestUtils.closeFileEditorTab(remoteRobot, Constants.BOOTSTRAP_PROPERTIES, "5"); if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, Constants.COMPACT_MODE, 3); } UIBotTestUtils.closeProjectView(remoteRobot); UIBotTestUtils.closeProjectFrame(remoteRobot); @@ -86,7 +87,7 @@ public void testServerXMLFeatureHover() { String hoverExpectedOutcome = "This feature provides support for the MicroProfile Health specification."; //mover cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, "server.xml", UIBotTestUtils.PopupType.DOCUMENTATION); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, Constants.SERVER_XML, UIBotTestUtils.PopupType.DOCUMENTATION); String hoverFoundOutcome = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DOCUMENTATION); // Validate that the hover action raised the expected hint text @@ -104,7 +105,7 @@ public void testServerXMLNonFeatureHover() { String hoverExpectedOutcome = "Configuration properties for an HTTP endpoint."; //mover cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, "server.xml", UIBotTestUtils.PopupType.DOCUMENTATION); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, Constants.SERVER_XML, UIBotTestUtils.PopupType.DOCUMENTATION); String hoverFoundOutcome = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DOCUMENTATION); // Validate that the hover action raised the expected hint text @@ -122,7 +123,7 @@ public void testInsertFeatureIntoServerXML() { String insertedFeature = "el-3.0"; // get focus on server.xml tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, "server.xml"); + UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SERVER_XML); // Save the current server.xml content. UIBotTestUtils.copyWindowContent(remoteRobot); @@ -130,7 +131,7 @@ public void testInsertFeatureIntoServerXML() { // Insert a new element in server.xml. try { UIBotTestUtils.insertStanzaInAppServerXML(remoteRobot, stanzaSnippet, 18, 40, UIBotTestUtils.InsertionType.FEATURE, true); - Path pathToServerXML = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", "server.xml"); + Path pathToServerXML = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", Constants.SERVER_XML); TestUtils.validateStanzaInConfigFile(pathToServerXML.toString(), insertedFeature); } finally { // Replace server.xml content with the original content @@ -149,7 +150,7 @@ public void testInsertLibertyConfigElementIntoServerXML() { String insertedConfig = ""; // get focus on server.xml tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, "server.xml"); + UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SERVER_XML); // Save the current server.xml content. UIBotTestUtils.copyWindowContent(remoteRobot); @@ -158,7 +159,7 @@ public void testInsertLibertyConfigElementIntoServerXML() { try { UIBotTestUtils.insertStanzaInAppServerXML(remoteRobot, stanzaSnippet, 20, 0, UIBotTestUtils.InsertionType.ELEMENT, true); TestUtils.sleepAndIgnoreException(2); // wait for editor to update - Path pathToServerXML = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", "server.xml"); + Path pathToServerXML = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", Constants.SERVER_XML); TestUtils.validateStanzaInConfigFile(pathToServerXML.toString(), insertedConfig); } finally { // Replace server.xml content with the original content @@ -180,14 +181,14 @@ public void testInsertLibertyConfigIntoServerEnvForCapitalCase() { String expectedServerEnvString = "WLP_LOGGING_CONSOLE_FORMAT=SIMPLE"; // get focus on server.env tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, "server.env"); + UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SERVER_ENV); // Save the current server.env content. UIBotTestUtils.copyWindowContent(remoteRobot); try { - UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, "server.env", envCfgSnippet, envCfgNameChooserSnippet, envCfgValueSnippet, true); - Path pathToServerEnv = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", "server.env"); + UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, Constants.SERVER_ENV, envCfgSnippet, envCfgNameChooserSnippet, envCfgValueSnippet, true); + Path pathToServerEnv = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", Constants.SERVER_ENV); TestUtils.validateStringInFile(pathToServerEnv.toString(), expectedServerEnvString); } finally { // Replace server.xml content with the original content @@ -265,14 +266,14 @@ public void testInsertLibertyConfigIntoBootstrapPropsForLowerCase() { String expectedBootstrapPropsString = "com.ibm.ws.logging.console.format=TBASIC"; // get focus on bootstrap.properties tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, "bootstrap.properties"); + UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.BOOTSTRAP_PROPERTIES); // Save the current bootstrap.properties content. UIBotTestUtils.copyWindowContent(remoteRobot); try { - UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, "bootstrap.properties", configNameSnippet, configNameChooserSnippet, configValueSnippet, true); - Path pathToBootstrapProps = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", "bootstrap.properties"); + UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, Constants.BOOTSTRAP_PROPERTIES, configNameSnippet, configNameChooserSnippet, configValueSnippet, true); + Path pathToBootstrapProps = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", Constants.BOOTSTRAP_PROPERTIES); TestUtils.validateStringInFile(pathToBootstrapProps.toString(), expectedBootstrapPropsString); } finally { // Replace server.xml content with the original content @@ -367,7 +368,7 @@ public void testServerEnvCfgHover() { String hoverExpectedOutcome = "This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default."; //mover cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, "server.env", UIBotTestUtils.PopupType.DOCUMENTATION); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, Constants.SERVER_ENV, UIBotTestUtils.PopupType.DOCUMENTATION); String hoverFoundOutcome = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DOCUMENTATION); // Validate that the hover action raised the expected hint text @@ -386,7 +387,7 @@ public void testBootstrapPropsCfgHover() { String hoverExpectedOutcome = "This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default."; //mover cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, "bootstrap.properties", UIBotTestUtils.PopupType.DOCUMENTATION); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, Constants.BOOTSTRAP_PROPERTIES, UIBotTestUtils.PopupType.DOCUMENTATION); String hoverFoundOutcome = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DOCUMENTATION); // Validate that the hover action raised the expected hint text @@ -405,10 +406,10 @@ public void testDiagnosticInServerXML() { String expectedHoverData = "cvc-datatype-valid.1.2.3: 'wrong' is not a valid value of union type 'booleanType'."; Path pathToServerXML = null; - pathToServerXML = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", "server.xml"); + pathToServerXML = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", Constants.SERVER_XML); // get focus on server.xml tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, "server.xml"); + UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SERVER_XML); // Save the current server.xml content. UIBotTestUtils.copyWindowContent(remoteRobot); @@ -417,7 +418,7 @@ public void testDiagnosticInServerXML() { UIBotTestUtils.insertStanzaInAppServerXML(remoteRobot, stanzaSnippet, 20, 0, UIBotTestUtils.InsertionType.ELEMENT, false); //move cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, "server.xml", UIBotTestUtils.PopupType.DIAGNOSTIC); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, Constants.SERVER_XML, UIBotTestUtils.PopupType.DIAGNOSTIC); String foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC); TestUtils.validateHoverData(expectedHoverData, foundHoverData); @@ -441,10 +442,10 @@ public void testQuickFixInServerXML() { String expectedHoverData = "cvc-datatype-valid.1.2.3: 'wrong' is not a valid value of union type 'booleanType'."; Path pathToServerXML = null; - pathToServerXML = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", "server.xml"); + pathToServerXML = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", Constants.SERVER_XML); // get focus on server.xml tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, "server.xml"); + UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SERVER_XML); // Save the current server.xml content. UIBotTestUtils.copyWindowContent(remoteRobot); @@ -453,7 +454,7 @@ public void testQuickFixInServerXML() { UIBotTestUtils.insertStanzaInAppServerXML(remoteRobot, stanzaSnippet, 20, 0, UIBotTestUtils.InsertionType.ELEMENT, false); //there should be a diagnostic - move cursor to hover point - UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, "server.xml", quickfixChooserString); + UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, Constants.SERVER_XML, quickfixChooserString); UIBotTestUtils.chooseQuickFix(remoteRobot, quickfixChooserString); TestUtils.validateStanzaInConfigFile(pathToServerXML.toString(), correctedStanza); @@ -476,15 +477,15 @@ public void testDiagnosticInServerEnv() { String expectedHoverData = "The value `NONE` is not valid for the variable `WLP_LOGGING_CONSOLE_FORMAT`."; // get focus on server.env tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, "server.env"); + UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SERVER_ENV); // Save the current server.env content. UIBotTestUtils.copyWindowContent(remoteRobot); try { - UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, "server.env", envCfgSnippet, envCfgNameChooserSnippet, incorrectValue, false); + UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, Constants.SERVER_ENV, envCfgSnippet, envCfgNameChooserSnippet, incorrectValue, false); //move cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, "NONE", "server.env", UIBotTestUtils.PopupType.DIAGNOSTIC); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, "NONE", Constants.SERVER_ENV, UIBotTestUtils.PopupType.DIAGNOSTIC); String foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC); TestUtils.validateHoverData(expectedHoverData, foundHoverData); @@ -506,16 +507,16 @@ public void testDiagnosticInBootstrapProperties() { String expectedHoverData = "The value `none` is not valid for the property `com.ibm.ws.logging.console.format`."; // get focus on bootstrap.properties tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, "bootstrap.properties"); + UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.BOOTSTRAP_PROPERTIES); // Save the current bootstrap.properties content. UIBotTestUtils.copyWindowContent(remoteRobot); try { - UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, "bootstrap.properties", configNameSnippet, configNameChooserSnippet, incorrectValue, false); + UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, Constants.BOOTSTRAP_PROPERTIES, configNameSnippet, configNameChooserSnippet, incorrectValue, false); //move cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, "none", "bootstrap.properties", UIBotTestUtils.PopupType.DIAGNOSTIC); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, "none", Constants.BOOTSTRAP_PROPERTIES, UIBotTestUtils.PopupType.DIAGNOSTIC); String foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC); TestUtils.validateHoverData(expectedHoverData, foundHoverData); } finally { @@ -581,7 +582,7 @@ public static void prepareEnv(String projectPath, String projectName) { UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); UIBotTestUtils.openProjectView(remoteRobot); if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, Constants.COMPACT_MODE, 3); } // IntelliJ does not start building and indexing until the Project View is open UIBotTestUtils.waitForIndexing(remoteRobot); @@ -594,13 +595,13 @@ public static void prepareEnv(String projectPath, String projectName) { projTree.expand(projectName, "src", "main", "liberty", "config"); // open server.xml file - UIBotTestUtils.openFile(remoteRobot, projectName, "server.xml", projectName, "src", "main", "liberty", "config"); + UIBotTestUtils.openFile(remoteRobot, projectName, Constants.SERVER_XML, projectName, "src", "main", "liberty", "config"); // open server.env file - UIBotTestUtils.openFile(remoteRobot, projectName, "server.env", projectName, "src", "main", "liberty", "config"); + UIBotTestUtils.openFile(remoteRobot, projectName, Constants.SERVER_ENV, projectName, "src", "main", "liberty", "config"); // open bootstrap.properties file - UIBotTestUtils.openFile(remoteRobot, projectName, "bootstrap.properties", projectName, "src", "main", "liberty", "config"); + UIBotTestUtils.openFile(remoteRobot, projectName, Constants.BOOTSTRAP_PROPERTIES, projectName, "src", "main", "liberty", "config"); // Removes the build tool window if it is opened. This prevents text to be hidden by it. UIBotTestUtils.removeToolWindow(remoteRobot, "Build:"); From 1e62f896744a529ec1e5defeb781be8a613f21e6 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Tue, 17 Dec 2024 19:40:12 +0530 Subject: [PATCH 02/28] SingleModMPLSTestCommon file --- .../tools/intellij/util/Constants.java | 4 ++ .../intellij/it/SingleModMPLSTestCommon.java | 55 ++++++++++--------- 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/src/main/java/io/openliberty/tools/intellij/util/Constants.java b/src/main/java/io/openliberty/tools/intellij/util/Constants.java index 3bb63f71c..c878e8324 100644 --- a/src/main/java/io/openliberty/tools/intellij/util/Constants.java +++ b/src/main/java/io/openliberty/tools/intellij/util/Constants.java @@ -101,11 +101,15 @@ public final class Constants { public static final String SYSTEM_RESOURCE_2_JAVA = "SystemResource2.java"; public static final String SYSTEM_RESOURCE = "SystemResource"; public static final String SYSTEM_RESOURCE_2 = "SystemResource2"; + public static final String SERVER_XML = "server.xml"; public static final String SERVER_ENV = "server.env"; public static final String BOOTSTRAP_PROPERTIES = "bootstrap.properties"; public static final String COMPACT_MODE = "Compact Mode"; + public static final String SERVICE_LIVE_HEALTH_CHECK_JAVA = "ServiceLiveHealthCheck.java"; + public static final String MPG_PROPERTIES = "microprofile-config.properties"; + } diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java index 590c9da03..ae0568407 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java @@ -13,6 +13,7 @@ import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.fixtures.JTreeFixture; import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture; +import io.openliberty.tools.intellij.util.Constants; import org.junit.jupiter.api.*; import java.nio.file.Path; @@ -64,10 +65,10 @@ public static void cleanup() { projectFrame.findText("META-INF").doubleClick(); projectFrame.findText("resources").doubleClick(); - UIBotTestUtils.closeFileEditorTab(remoteRobot, "ServiceLiveHealthCheck.java", "5"); - UIBotTestUtils.closeFileEditorTab(remoteRobot, "microprofile-config.properties", "5"); + UIBotTestUtils.closeFileEditorTab(remoteRobot, Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA, "5"); + UIBotTestUtils.closeFileEditorTab(remoteRobot, Constants.MPG_PROPERTIES, "5"); if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, Constants.COMPACT_MODE, 3); } UIBotTestUtils.closeProjectView(remoteRobot); UIBotTestUtils.closeProjectFrame(remoteRobot); @@ -85,7 +86,7 @@ public void testInsertCodeSnippetIntoJavaPart() { String insertedCode = "public class ServiceLiveHealthCheck implements HealthCheck {"; // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, "ServiceLiveHealthCheck.java"); + UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA); // Save the current content. UIBotTestUtils.copyWindowContent(remoteRobot); @@ -95,8 +96,8 @@ public void testInsertCodeSnippetIntoJavaPart() { // Insert a code snippet into java part try { - UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, "ServiceLiveHealthCheck.java", snippetStr, snippetChooser); - Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "health","ServiceLiveHealthCheck.java"); + UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA, snippetStr, snippetChooser); + Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "health",Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA); TestUtils.validateCodeInJavaSrc(pathToSrc.toString(), insertedCode); } finally { // Replace modified content with the original content @@ -116,14 +117,14 @@ public void testMPDiagnosticsInJavaPart() { String expectedHoverData = "The class `io.openliberty.mp.sample.health.ServiceLiveHealthCheck` implementing the HealthCheck interface should use the @Liveness, @Readiness or @Health annotation."; // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, "ServiceLiveHealthCheck.java"); + UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA); // Save the current content. UIBotTestUtils.copyWindowContent(remoteRobot); // Delete the liveness annotation - UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot, "ServiceLiveHealthCheck.java", livenessString); - Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "health", "ServiceLiveHealthCheck.java"); + UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot, Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA, livenessString); + Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "health", Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA); try { // validate @Liveness no longer found in java part @@ -134,7 +135,7 @@ public void testMPDiagnosticsInJavaPart() { int maxWait = 60, delay = 5; // in some cases it can take 35s for the diagnostic to appear for (int i = 0; i <= maxWait; i += delay) { //there should be a diagnostic - move cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, "ServiceLiveHealthCheck.java", UIBotTestUtils.PopupType.DIAGNOSTIC); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA, UIBotTestUtils.PopupType.DIAGNOSTIC); foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC); if (!foundHoverData.isBlank()) { @@ -162,21 +163,21 @@ public void testMPQuickFixInJavaFile() { String mainQuickFixActionStr = "Generate OpenAPI Annotations for 'ServiceLiveHealthCheck'"; // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, "ServiceLiveHealthCheck.java"); + UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA); // Save the current content. UIBotTestUtils.copyWindowContent(remoteRobot); // Delete the liveness annotation - UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot,"ServiceLiveHealthCheck.java", livenessString); - Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "health", "ServiceLiveHealthCheck.java"); + UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot,Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA, livenessString); + Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "health", Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA); try { // validate @Liveness no longer found in java part TestUtils.validateStringNotInFile(pathToSrc.toString(), livenessString); //there should be a diagnostic - move cursor to hover point - UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, "ServiceLiveHealthCheck.java", quickfixChooserString); + UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA, quickfixChooserString); // trigger and use the quickfix popup attached to the diagnostic UIBotTestUtils.chooseQuickFix(remoteRobot, quickfixChooserString); @@ -201,14 +202,14 @@ public void testInsertMicroProfileProperty() { String expectedMpCfgPropertiesString = "mp.health.disable-default-procedures=true"; // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, "microprofile-config.properties"); + UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.MPG_PROPERTIES); // Save the current microprofile-config.properties content. UIBotTestUtils.copyWindowContent(remoteRobot); try { - UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, "microprofile-config.properties", cfgSnippet, cfgNameChooserSnippet, cfgValueSnippet, true); - Path pathToMpCfgProperties = Paths.get(projectsPath, projectName, "src", "main", "resources", "META-INF", "microprofile-config.properties"); + UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, Constants.MPG_PROPERTIES, cfgSnippet, cfgNameChooserSnippet, cfgValueSnippet, true); + Path pathToMpCfgProperties = Paths.get(projectsPath, projectName, "src", "main", "resources", "META-INF", Constants.MPG_PROPERTIES); TestUtils.validateStringInFile(pathToMpCfgProperties.toString(), expectedMpCfgPropertiesString); } finally { // Replace modified microprofile-config.properties with the original content @@ -231,7 +232,7 @@ public void testMicroProfileConfigHover() { "java.lang.StringValue: http://localhost:9081/data/client/service"; //mover cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, "microprofile-config.properties", UIBotTestUtils.PopupType.DOCUMENTATION); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, Constants.MPG_PROPERTIES, UIBotTestUtils.PopupType.DOCUMENTATION); String hoverFoundOutcome = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DOCUMENTATION); // if the LS has not yet poulated the popup, re-get the popup data @@ -261,16 +262,16 @@ public void testDiagnosticInMicroProfileConfigProperties() { String expectedHoverData = "Type mismatch: boolean expected. By default, this value will be interpreted as 'false'"; // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, "microprofile-config.properties"); + UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.MPG_PROPERTIES); // Save the current content. UIBotTestUtils.copyWindowContent(remoteRobot); try { - UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, "microprofile-config.properties", MPCfgSnippet, MPCfgNameChooserSnippet, incorrectValue, false); + UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, Constants.MPG_PROPERTIES, MPCfgSnippet, MPCfgNameChooserSnippet, incorrectValue, false); //move cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, incorrectValue, "microprofile-config.properties", UIBotTestUtils.PopupType.DIAGNOSTIC); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, incorrectValue, Constants.MPG_PROPERTIES, UIBotTestUtils.PopupType.DIAGNOSTIC); String foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC); TestUtils.validateHoverData(expectedHoverData, foundHoverData); } finally { @@ -294,19 +295,19 @@ public void testQuickFixInMicroProfileConfigProperties() { String correctedValue = "mp.health.disable-default-procedures=true"; String expectedHoverData = "Type mismatch: boolean expected. By default, this value will be interpreted as 'false'"; - Path pathToMpCfgProperties = Paths.get(projectsPath, projectName,"src", "main", "resources", "META-INF", "microprofile-config.properties"); + Path pathToMpCfgProperties = Paths.get(projectsPath, projectName,"src", "main", "resources", "META-INF", Constants.MPG_PROPERTIES); // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, "microprofile-config.properties"); + UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.MPG_PROPERTIES); // Save the current content. UIBotTestUtils.copyWindowContent(remoteRobot); try { - UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, "microprofile-config.properties", MPCfgSnippet, MPCfgNameChooserSnippet, incorrectValue, false); + UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, Constants.MPG_PROPERTIES, MPCfgSnippet, MPCfgNameChooserSnippet, incorrectValue, false); //move cursor to hover point - UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, incorrectValue, "microprofile-config.properties", quickfixChooserString); + UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, incorrectValue, Constants.MPG_PROPERTIES, quickfixChooserString); UIBotTestUtils.chooseQuickFix(remoteRobot, quickfixChooserString); TestUtils.validateStanzaInConfigFile(pathToMpCfgProperties.toString(), correctedValue); @@ -332,7 +333,7 @@ public static void prepareEnv(String projectPath, String projectName) { UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); UIBotTestUtils.openProjectView(remoteRobot); if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, Constants.COMPACT_MODE, 3); } // IntelliJ does not start building and indexing until the Project View is open UIBotTestUtils.waitForIndexing(remoteRobot); @@ -344,7 +345,7 @@ public static void prepareEnv(String projectPath, String projectName) { JTreeFixture projTree = projectFrame.getProjectViewJTree(projectName); UIBotTestUtils.openFile(remoteRobot, projectName, "ServiceLiveHealthCheck", projectName, "src", "main", "java", "io.openliberty.mp.sample", "health"); - UIBotTestUtils.openFile(remoteRobot, projectName, "microprofile-config.properties", projectName, "src", "main", "resources", "META-INF"); + UIBotTestUtils.openFile(remoteRobot, projectName, Constants.MPG_PROPERTIES, projectName, "src", "main", "resources", "META-INF"); // Removes the build tool window if it is opened. This prevents text to be hidden by it. UIBotTestUtils.removeToolWindow(remoteRobot, "Build:"); From 02c2113fd02dbaad1575f071efff34d7ff67d10c Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Tue, 17 Dec 2024 19:45:08 +0530 Subject: [PATCH 03/28] SingleModMPProjectTestCommon file --- .../io/openliberty/tools/intellij/util/Constants.java | 3 +-- .../tools/intellij/it/SingleModMPProjectTestCommon.java | 9 +++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/openliberty/tools/intellij/util/Constants.java b/src/main/java/io/openliberty/tools/intellij/util/Constants.java index c878e8324..5e7f6aec6 100644 --- a/src/main/java/io/openliberty/tools/intellij/util/Constants.java +++ b/src/main/java/io/openliberty/tools/intellij/util/Constants.java @@ -110,6 +110,5 @@ public final class Constants { public static final String SERVICE_LIVE_HEALTH_CHECK_JAVA = "ServiceLiveHealthCheck.java"; public static final String MPG_PROPERTIES = "microprofile-config.properties"; - - + public static final String CLOSE_ALL_TABS = "Close All Tabs"; } diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java index c794fea80..4388b7fac 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java @@ -14,6 +14,7 @@ import com.intellij.remoterobot.fixtures.ComponentFixture; import com.intellij.remoterobot.utils.Keyboard; import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture; +import io.openliberty.tools.intellij.util.Constants; import org.junit.jupiter.api.*; import org.junit.jupiter.api.condition.EnabledOnOs; import org.junit.jupiter.api.condition.OS; @@ -294,8 +295,8 @@ public static void cleanup() { */ protected static void closeProjectView() { if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Close All Tabs", 3); - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, Constants.CLOSE_ALL_TABS, 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, Constants.COMPACT_MODE, 3); } UIBotTestUtils.closeLibertyToolWindow(remoteRobot); UIBotTestUtils.closeProjectView(remoteRobot); @@ -1139,7 +1140,7 @@ public static void prepareEnv(String projectPath, String projectName) { UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); UIBotTestUtils.openProjectView(remoteRobot); if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, Constants.COMPACT_MODE, 3); } // IntelliJ does not start building and indexing until the Project View is open UIBotTestUtils.waitForIndexing(remoteRobot); @@ -1157,7 +1158,7 @@ public static void prepareEnv(String projectPath, String projectName) { UIBotTestUtils.closeAllEditorTabs(remoteRobot); } else { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Close All Tabs", 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, Constants.CLOSE_ALL_TABS, 3); } TestUtils.printTrace(TestUtils.TraceSevLevel.INFO, From da9f216e425e6bcccb6d62bf178309f5ee83d749 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Tue, 17 Dec 2024 19:47:06 +0530 Subject: [PATCH 04/28] SingleModNLTRestProjectTestCommon file --- .../intellij/it/SingleModNLTRestProjectTestCommon.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java index 5fb15e38c..2115ac29e 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java @@ -11,6 +11,7 @@ import com.automation.remarks.junit5.Video; import com.intellij.remoterobot.RemoteRobot; +import io.openliberty.tools.intellij.util.Constants; import org.junit.jupiter.api.*; import java.nio.file.Files; @@ -85,7 +86,7 @@ public void afterEach(TestInfo info) { @AfterAll public static void cleanup() { if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, Constants.COMPACT_MODE, 3); } UIBotTestUtils.closeLibertyToolWindow(remoteRobot); UIBotTestUtils.closeProjectView(remoteRobot); @@ -194,8 +195,8 @@ public void testsRefreshProjectWithServerXmlOnly() { UIBotTestUtils.waitForLTWNoProjectDetectedMsg(remoteRobot, 10); // Copy a valid server.xml file to this project's src/main/liberty/config directory. - Path validServerXml = Paths.get(getHelperFilesDirPath(), "server.xml"); - Path destination = Paths.get(getProjectsDirPath(), getSmNLTRestProjectName(), "src", "main", "liberty", "config", "server.xml"); + Path validServerXml = Paths.get(getHelperFilesDirPath(), Constants.SERVER_XML); + Path destination = Paths.get(getProjectsDirPath(), getSmNLTRestProjectName(), "src", "main", "liberty", "config", Constants.SERVER_XML); try { Files.copy(validServerXml, destination, StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING); @@ -302,7 +303,7 @@ public static void prepareEnv(String projectPath, String projectName) { UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); UIBotTestUtils.openProjectView(remoteRobot); if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, Constants.COMPACT_MODE, 3); } // IntelliJ does not start building and indexing until the Project View is open UIBotTestUtils.waitForIndexing(remoteRobot); From daa70969d379939acb34d78c2ceaa708bfa59c89 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Tue, 17 Dec 2024 19:53:45 +0530 Subject: [PATCH 05/28] modified other strings to constants --- .../openliberty/tools/intellij/it/TestUtils.java | 3 ++- .../tools/intellij/it/UIBotTestUtils.java | 15 ++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java index 4aba7ee90..2d76e7e17 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java @@ -9,6 +9,7 @@ *******************************************************************************/ package io.openliberty.tools.intellij.it; +import io.openliberty.tools.intellij.util.Constants; import org.junit.jupiter.api.Assertions; import java.io.*; @@ -541,7 +542,7 @@ public static boolean isServerStopNeeded(String wlpInstallPath) { */ public static void checkDebugPort(String absoluteWLPPath, int debugPort) throws IOException { // Retrieve the WLP server.env file path - Path serverEnvPath = Paths.get(absoluteWLPPath, "wlp", "usr", "servers", "defaultServer", "server.env"); + Path serverEnvPath = Paths.get(absoluteWLPPath, "wlp", "usr", "servers", "defaultServer", Constants.SERVER_ENV); // Read all lines from server.env List lines = Files.readAllLines(serverEnvPath); // Check if Debug Port is set to the specified port diff --git a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java index 1ba7103b2..4bc6a0bed 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java @@ -20,6 +20,7 @@ import io.openliberty.tools.intellij.it.fixtures.DialogFixture; import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture; import io.openliberty.tools.intellij.it.fixtures.WelcomeFrameFixture; +import io.openliberty.tools.intellij.util.Constants; import org.assertj.swing.core.MouseButton; import org.junit.Assert; import org.junit.jupiter.api.Assertions; @@ -761,7 +762,7 @@ public static void closeFileEditorTab(RemoteRobot remoteRobot, String editorTabN */ public static void closeAllEditorTabs(RemoteRobot remoteRobot) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); - projectFrame.clickOnMainMenuWithActions(remoteRobot, "Window", "Editor Tabs", "Close All Tabs"); + projectFrame.clickOnMainMenuWithActions(remoteRobot, "Window", "Editor Tabs", Constants.CLOSE_ALL_TABS); } /** @@ -829,7 +830,7 @@ public static void hoverInAppServerCfgFile(RemoteRobot remoteRobot, String hover // Find the target text on the editor and move the move to it. editorNew.findText(contains(hoverTarget)).moveMouse(); // clear and "lightbulb" icons? - if (!hoverFile.equals("server.xml")) { + if (!hoverFile.equals(Constants.SERVER_XML)) { keyboard.hotKey(VK_ESCAPE); } @@ -1207,7 +1208,7 @@ else if (fileName.equals("bootstrap.properties")) { public static void insertStanzaInAppServerXML(RemoteRobot remoteRobot, String stanzaSnippet, int line, int col, InsertionType type, boolean completeWithPopup) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(30)); - clickOnFileTab(remoteRobot, "server.xml"); + clickOnFileTab(remoteRobot, Constants.SERVER_XML); Locator locator = byXpath("//div[@class='EditorCompositePanel']//div[@class='EditorComponentImpl']"); EditorFixture editorNew = remoteRobot.find(EditorFixture.class, locator, Duration.ofSeconds(20)); editorNew.click(); @@ -1740,14 +1741,14 @@ public static void runActionFromSearchEverywherePanel(RemoteRobot remoteRobot, S } /* - * We throw a RuntimeException with error only if the action is not "Close All Tabs" .The "Close All Tabs" action + * We throw a RuntimeException with error only if the action is not Constants.CLOSE_ALL_TABS .The Constants.CLOSE_ALL_TABS action * is used as part of the cleanup process in the @AfterAll-annotated method within the SingleModMPProjectTestCommon class. * * When running individual tests in this class, it is not always guaranteed that at least one file tab will be open in the Editor Window. - * If we are not specify a condition check for "Close All Tabs" action when no file tabs are open, the runActionFromSearchEverywherePanel method + * If we are not specify a condition check for Constants.CLOSE_ALL_TABS action when no file tabs are open, the runActionFromSearchEverywherePanel method * will throw a RuntimeException, causing the test to fail. */ - if (error != null && !action.equals("Close All Tabs")) { + if (error != null && !action.equals(Constants.CLOSE_ALL_TABS)) { throw new RuntimeException("Failed to run the " + action + " action using the search everywhere option", error); } } @@ -2677,7 +2678,7 @@ public static void findWelcomeFrame(RemoteRobot remoteRobot) { UIBotTestUtils.closeAllEditorTabs(remoteRobot); } else { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Close All Tabs", 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, Constants.CLOSE_ALL_TABS, 3); } UIBotTestUtils.closeProjectView(remoteRobot); UIBotTestUtils.closeProjectFrame(remoteRobot); From 769d3d37da61a57f53df53f237be3d046d0cf32a Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Thu, 19 Dec 2024 10:19:39 +0530 Subject: [PATCH 06/28] Moved into constants file under the test directory --- .../tools/intellij/util/Constants.java | 17 ----- .../it/SingleModJakartaLSTestCommon.java | 36 +++++----- .../it/SingleModLibertyLSTestCommon.java | 70 +++++++++---------- .../intellij/it/SingleModMPLSTestCommon.java | 56 +++++++-------- .../it/SingleModMPProjectTestCommon.java | 10 +-- .../it/SingleModNLTRestProjectTestCommon.java | 10 +-- .../tools/intellij/it/TestUtils.java | 4 +- .../tools/intellij/it/UIBotTestUtils.java | 16 ++--- .../tools/intellij/it/Utils/ItConstants.java | 22 ++++++ 9 files changed, 123 insertions(+), 118 deletions(-) create mode 100644 src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java diff --git a/src/main/java/io/openliberty/tools/intellij/util/Constants.java b/src/main/java/io/openliberty/tools/intellij/util/Constants.java index 5e7f6aec6..275899b57 100644 --- a/src/main/java/io/openliberty/tools/intellij/util/Constants.java +++ b/src/main/java/io/openliberty/tools/intellij/util/Constants.java @@ -94,21 +94,4 @@ public final class Constants { public static final String JAKARTA_LANG_SERVER="Eclipse LSP4Jakarta"; public static final String MICROPROFILE_SERVER="Eclipse LSP4MP"; - /** - * Constants for Integration testing - */ - public static final String SYSTEM_RESOURCE_JAVA = "SystemResource.java"; - public static final String SYSTEM_RESOURCE_2_JAVA = "SystemResource2.java"; - public static final String SYSTEM_RESOURCE = "SystemResource"; - public static final String SYSTEM_RESOURCE_2 = "SystemResource2"; - - public static final String SERVER_XML = "server.xml"; - public static final String SERVER_ENV = "server.env"; - public static final String BOOTSTRAP_PROPERTIES = "bootstrap.properties"; - public static final String COMPACT_MODE = "Compact Mode"; - - public static final String SERVICE_LIVE_HEALTH_CHECK_JAVA = "ServiceLiveHealthCheck.java"; - public static final String MPG_PROPERTIES = "microprofile-config.properties"; - - public static final String CLOSE_ALL_TABS = "Close All Tabs"; } diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java index 7f1a40952..309c55e84 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java @@ -12,8 +12,8 @@ import com.automation.remarks.junit5.Video; import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.fixtures.JTreeFixture; +import io.openliberty.tools.intellij.it.Utils.ItConstants; import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture; -import io.openliberty.tools.intellij.util.Constants; import org.junit.jupiter.api.*; import java.nio.file.Path; @@ -62,8 +62,8 @@ public void afterEach(TestInfo info) { public static void cleanup() { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2)); - UIBotTestUtils.closeFileEditorTab(remoteRobot, Constants.SYSTEM_RESOURCE_JAVA, "5"); - UIBotTestUtils.closeFileEditorTab(remoteRobot, Constants.SYSTEM_RESOURCE_2_JAVA, "5"); + UIBotTestUtils.closeFileEditorTab(remoteRobot, ItConstants.SYSTEM_RESOURCE_JAVA, "5"); + UIBotTestUtils.closeFileEditorTab(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA, "5"); UIBotTestUtils.closeProjectView(remoteRobot); UIBotTestUtils.closeProjectFrame(remoteRobot); @@ -81,7 +81,7 @@ public void testInsertJakartaCodeSnippetIntoJavaPart() { String insertedCode = "public String methodname() {"; // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SYSTEM_RESOURCE_JAVA); + UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SYSTEM_RESOURCE_JAVA); // Save the current content. UIBotTestUtils.copyWindowContent(remoteRobot); @@ -91,8 +91,8 @@ public void testInsertJakartaCodeSnippetIntoJavaPart() { // Insert a code snippet into java part try { - UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, Constants.SYSTEM_RESOURCE_JAVA, snippetStr, snippetChooser); - Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "system", Constants.SYSTEM_RESOURCE_JAVA); + UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, ItConstants.SYSTEM_RESOURCE_JAVA, snippetStr, snippetChooser); + Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "system", ItConstants.SYSTEM_RESOURCE_JAVA); TestUtils.validateCodeInJavaSrc(pathToSrc.toString(), insertedCode); } finally { @@ -110,28 +110,28 @@ public void testJakartaDiagnosticsInJavaPart() { String privateString = "private Response getProperties() {"; String flaggedString = "getProperties"; String expectedHoverData = "Only public methods can be exposed as resource methods"; - Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "system", Constants.SYSTEM_RESOURCE_2_JAVA); + Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "system", ItConstants.SYSTEM_RESOURCE_2_JAVA); // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SYSTEM_RESOURCE_2_JAVA); + UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA); // Modify the method signature - UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, Constants.SYSTEM_RESOURCE_2_JAVA, publicString, privateString); + UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA, publicString, privateString); try { // validate the method signature is no longer set to public TestUtils.validateStringNotInFile(pathToSrc.toString(), publicString); //there should be a diagnostic for "private" on method signature - move cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, Constants.SYSTEM_RESOURCE_2_JAVA, UIBotTestUtils.PopupType.DIAGNOSTIC); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, ItConstants.SYSTEM_RESOURCE_2_JAVA, UIBotTestUtils.PopupType.DIAGNOSTIC); String foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC); TestUtils.validateHoverData(expectedHoverData, foundHoverData); - UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SYSTEM_RESOURCE_2_JAVA); + UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA); } finally { // Replace modified content with the original content - UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, Constants.SYSTEM_RESOURCE_2_JAVA, privateString, publicString); + UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA, privateString, publicString); } } @@ -145,24 +145,24 @@ public void testJakartaQuickFixInJavaPart() { String privateString = "private Response getProperties() {"; String flaggedString = "getProperties"; - Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "system", Constants.SYSTEM_RESOURCE_2_JAVA); + Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "system", ItConstants.SYSTEM_RESOURCE_2_JAVA); String quickfixChooserString = "Make method public"; // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SYSTEM_RESOURCE_2_JAVA); + UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA); // Save the current content. UIBotTestUtils.copyWindowContent(remoteRobot); // Modify the method signature - UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, Constants.SYSTEM_RESOURCE_2_JAVA, publicString, privateString); + UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA, publicString, privateString); try { // validate public signature no longer found in java part TestUtils.validateStringNotInFile(pathToSrc.toString(), publicString); //there should be a diagnostic - move cursor to hover point - UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, Constants.SYSTEM_RESOURCE_2_JAVA, quickfixChooserString); + UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, ItConstants.SYSTEM_RESOURCE_2_JAVA, quickfixChooserString); // trigger and use the quickfix popup attached to the diagnostic UIBotTestUtils.chooseQuickFix(remoteRobot, quickfixChooserString); @@ -201,8 +201,8 @@ public static void prepareEnv(String projectPath, String projectName) { // must be expanded here before trying to open specific files projTree.expand(projectName, "src", "main", "java", "io.openliberty.mp.sample", "system"); - UIBotTestUtils.openFile(remoteRobot, projectName, Constants.SYSTEM_RESOURCE, projectName, "src", "main", "java", "io.openliberty.mp.sample", "system"); - UIBotTestUtils.openFile(remoteRobot, projectName, Constants.SYSTEM_RESOURCE_2, projectName, "src", "main", "java", "io.openliberty.mp.sample", "system"); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE, projectName, "src", "main", "java", "io.openliberty.mp.sample", "system"); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE_2, projectName, "src", "main", "java", "io.openliberty.mp.sample", "system"); // Removes the build tool window if it is opened. This prevents text to be hidden by it. diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java index 8c496339b..cdfc60127 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -12,9 +12,9 @@ import com.automation.remarks.junit5.Video; import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.fixtures.JTreeFixture; +import io.openliberty.tools.intellij.it.Utils.ItConstants; import com.intellij.remoterobot.utils.Keyboard; import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture; -import io.openliberty.tools.intellij.util.Constants; import org.junit.jupiter.api.*; import java.nio.file.Path; @@ -65,11 +65,11 @@ public void afterEach(TestInfo info) { */ @AfterAll public static void cleanup() { - UIBotTestUtils.closeFileEditorTab(remoteRobot, Constants.SERVER_XML, "5"); - UIBotTestUtils.closeFileEditorTab(remoteRobot, Constants.SERVER_ENV, "5"); - UIBotTestUtils.closeFileEditorTab(remoteRobot, Constants.BOOTSTRAP_PROPERTIES, "5"); + UIBotTestUtils.closeFileEditorTab(remoteRobot, ItConstants.SERVER_XML, "5"); + UIBotTestUtils.closeFileEditorTab(remoteRobot, ItConstants.SERVER_ENV, "5"); + UIBotTestUtils.closeFileEditorTab(remoteRobot, ItConstants.BOOTSTRAP_PROPERTIES, "5"); if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, Constants.COMPACT_MODE, 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, ItConstants.COMPACT_MODE, 3); } UIBotTestUtils.closeProjectView(remoteRobot); UIBotTestUtils.closeProjectFrame(remoteRobot); @@ -87,7 +87,7 @@ public void testServerXMLFeatureHover() { String hoverExpectedOutcome = "This feature provides support for the MicroProfile Health specification."; //mover cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, Constants.SERVER_XML, UIBotTestUtils.PopupType.DOCUMENTATION); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, ItConstants.SERVER_XML, UIBotTestUtils.PopupType.DOCUMENTATION); String hoverFoundOutcome = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DOCUMENTATION); // Validate that the hover action raised the expected hint text @@ -105,7 +105,7 @@ public void testServerXMLNonFeatureHover() { String hoverExpectedOutcome = "Configuration properties for an HTTP endpoint."; //mover cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, Constants.SERVER_XML, UIBotTestUtils.PopupType.DOCUMENTATION); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, ItConstants.SERVER_XML, UIBotTestUtils.PopupType.DOCUMENTATION); String hoverFoundOutcome = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DOCUMENTATION); // Validate that the hover action raised the expected hint text @@ -123,7 +123,7 @@ public void testInsertFeatureIntoServerXML() { String insertedFeature = "el-3.0"; // get focus on server.xml tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SERVER_XML); + UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVER_XML); // Save the current server.xml content. UIBotTestUtils.copyWindowContent(remoteRobot); @@ -131,7 +131,7 @@ public void testInsertFeatureIntoServerXML() { // Insert a new element in server.xml. try { UIBotTestUtils.insertStanzaInAppServerXML(remoteRobot, stanzaSnippet, 18, 40, UIBotTestUtils.InsertionType.FEATURE, true); - Path pathToServerXML = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", Constants.SERVER_XML); + Path pathToServerXML = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", ItConstants.SERVER_XML); TestUtils.validateStanzaInConfigFile(pathToServerXML.toString(), insertedFeature); } finally { // Replace server.xml content with the original content @@ -150,7 +150,7 @@ public void testInsertLibertyConfigElementIntoServerXML() { String insertedConfig = ""; // get focus on server.xml tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SERVER_XML); + UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVER_XML); // Save the current server.xml content. UIBotTestUtils.copyWindowContent(remoteRobot); @@ -159,7 +159,7 @@ public void testInsertLibertyConfigElementIntoServerXML() { try { UIBotTestUtils.insertStanzaInAppServerXML(remoteRobot, stanzaSnippet, 20, 0, UIBotTestUtils.InsertionType.ELEMENT, true); TestUtils.sleepAndIgnoreException(2); // wait for editor to update - Path pathToServerXML = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", Constants.SERVER_XML); + Path pathToServerXML = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", ItConstants.SERVER_XML); TestUtils.validateStanzaInConfigFile(pathToServerXML.toString(), insertedConfig); } finally { // Replace server.xml content with the original content @@ -181,14 +181,14 @@ public void testInsertLibertyConfigIntoServerEnvForCapitalCase() { String expectedServerEnvString = "WLP_LOGGING_CONSOLE_FORMAT=SIMPLE"; // get focus on server.env tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SERVER_ENV); + UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVER_ENV); // Save the current server.env content. UIBotTestUtils.copyWindowContent(remoteRobot); try { - UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, Constants.SERVER_ENV, envCfgSnippet, envCfgNameChooserSnippet, envCfgValueSnippet, true); - Path pathToServerEnv = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", Constants.SERVER_ENV); + UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, ItConstants.SERVER_ENV, envCfgSnippet, envCfgNameChooserSnippet, envCfgValueSnippet, true); + Path pathToServerEnv = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", ItConstants.SERVER_ENV); TestUtils.validateStringInFile(pathToServerEnv.toString(), expectedServerEnvString); } finally { // Replace server.xml content with the original content @@ -266,14 +266,14 @@ public void testInsertLibertyConfigIntoBootstrapPropsForLowerCase() { String expectedBootstrapPropsString = "com.ibm.ws.logging.console.format=TBASIC"; // get focus on bootstrap.properties tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.BOOTSTRAP_PROPERTIES); + UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.BOOTSTRAP_PROPERTIES); // Save the current bootstrap.properties content. UIBotTestUtils.copyWindowContent(remoteRobot); try { - UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, Constants.BOOTSTRAP_PROPERTIES, configNameSnippet, configNameChooserSnippet, configValueSnippet, true); - Path pathToBootstrapProps = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", Constants.BOOTSTRAP_PROPERTIES); + UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, ItConstants.BOOTSTRAP_PROPERTIES, configNameSnippet, configNameChooserSnippet, configValueSnippet, true); + Path pathToBootstrapProps = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", ItConstants.BOOTSTRAP_PROPERTIES); TestUtils.validateStringInFile(pathToBootstrapProps.toString(), expectedBootstrapPropsString); } finally { // Replace server.xml content with the original content @@ -368,7 +368,7 @@ public void testServerEnvCfgHover() { String hoverExpectedOutcome = "This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default."; //mover cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, Constants.SERVER_ENV, UIBotTestUtils.PopupType.DOCUMENTATION); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, ItConstants.SERVER_ENV, UIBotTestUtils.PopupType.DOCUMENTATION); String hoverFoundOutcome = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DOCUMENTATION); // Validate that the hover action raised the expected hint text @@ -387,7 +387,7 @@ public void testBootstrapPropsCfgHover() { String hoverExpectedOutcome = "This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default."; //mover cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, Constants.BOOTSTRAP_PROPERTIES, UIBotTestUtils.PopupType.DOCUMENTATION); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, ItConstants.BOOTSTRAP_PROPERTIES, UIBotTestUtils.PopupType.DOCUMENTATION); String hoverFoundOutcome = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DOCUMENTATION); // Validate that the hover action raised the expected hint text @@ -406,10 +406,10 @@ public void testDiagnosticInServerXML() { String expectedHoverData = "cvc-datatype-valid.1.2.3: 'wrong' is not a valid value of union type 'booleanType'."; Path pathToServerXML = null; - pathToServerXML = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", Constants.SERVER_XML); + pathToServerXML = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", ItConstants.SERVER_XML); // get focus on server.xml tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SERVER_XML); + UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVER_XML); // Save the current server.xml content. UIBotTestUtils.copyWindowContent(remoteRobot); @@ -418,7 +418,7 @@ public void testDiagnosticInServerXML() { UIBotTestUtils.insertStanzaInAppServerXML(remoteRobot, stanzaSnippet, 20, 0, UIBotTestUtils.InsertionType.ELEMENT, false); //move cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, Constants.SERVER_XML, UIBotTestUtils.PopupType.DIAGNOSTIC); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, ItConstants.SERVER_XML, UIBotTestUtils.PopupType.DIAGNOSTIC); String foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC); TestUtils.validateHoverData(expectedHoverData, foundHoverData); @@ -442,10 +442,10 @@ public void testQuickFixInServerXML() { String expectedHoverData = "cvc-datatype-valid.1.2.3: 'wrong' is not a valid value of union type 'booleanType'."; Path pathToServerXML = null; - pathToServerXML = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", Constants.SERVER_XML); + pathToServerXML = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", ItConstants.SERVER_XML); // get focus on server.xml tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SERVER_XML); + UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVER_XML); // Save the current server.xml content. UIBotTestUtils.copyWindowContent(remoteRobot); @@ -454,7 +454,7 @@ public void testQuickFixInServerXML() { UIBotTestUtils.insertStanzaInAppServerXML(remoteRobot, stanzaSnippet, 20, 0, UIBotTestUtils.InsertionType.ELEMENT, false); //there should be a diagnostic - move cursor to hover point - UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, Constants.SERVER_XML, quickfixChooserString); + UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, ItConstants.SERVER_XML, quickfixChooserString); UIBotTestUtils.chooseQuickFix(remoteRobot, quickfixChooserString); TestUtils.validateStanzaInConfigFile(pathToServerXML.toString(), correctedStanza); @@ -477,15 +477,15 @@ public void testDiagnosticInServerEnv() { String expectedHoverData = "The value `NONE` is not valid for the variable `WLP_LOGGING_CONSOLE_FORMAT`."; // get focus on server.env tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SERVER_ENV); + UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVER_ENV); // Save the current server.env content. UIBotTestUtils.copyWindowContent(remoteRobot); try { - UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, Constants.SERVER_ENV, envCfgSnippet, envCfgNameChooserSnippet, incorrectValue, false); + UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, ItConstants.SERVER_ENV, envCfgSnippet, envCfgNameChooserSnippet, incorrectValue, false); //move cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, "NONE", Constants.SERVER_ENV, UIBotTestUtils.PopupType.DIAGNOSTIC); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, "NONE", ItConstants.SERVER_ENV, UIBotTestUtils.PopupType.DIAGNOSTIC); String foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC); TestUtils.validateHoverData(expectedHoverData, foundHoverData); @@ -507,16 +507,16 @@ public void testDiagnosticInBootstrapProperties() { String expectedHoverData = "The value `none` is not valid for the property `com.ibm.ws.logging.console.format`."; // get focus on bootstrap.properties tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.BOOTSTRAP_PROPERTIES); + UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.BOOTSTRAP_PROPERTIES); // Save the current bootstrap.properties content. UIBotTestUtils.copyWindowContent(remoteRobot); try { - UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, Constants.BOOTSTRAP_PROPERTIES, configNameSnippet, configNameChooserSnippet, incorrectValue, false); + UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, ItConstants.BOOTSTRAP_PROPERTIES, configNameSnippet, configNameChooserSnippet, incorrectValue, false); //move cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, "none", Constants.BOOTSTRAP_PROPERTIES, UIBotTestUtils.PopupType.DIAGNOSTIC); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, "none", ItConstants.BOOTSTRAP_PROPERTIES, UIBotTestUtils.PopupType.DIAGNOSTIC); String foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC); TestUtils.validateHoverData(expectedHoverData, foundHoverData); } finally { @@ -582,7 +582,7 @@ public static void prepareEnv(String projectPath, String projectName) { UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); UIBotTestUtils.openProjectView(remoteRobot); if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, Constants.COMPACT_MODE, 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, ItConstants.COMPACT_MODE, 3); } // IntelliJ does not start building and indexing until the Project View is open UIBotTestUtils.waitForIndexing(remoteRobot); @@ -595,13 +595,13 @@ public static void prepareEnv(String projectPath, String projectName) { projTree.expand(projectName, "src", "main", "liberty", "config"); // open server.xml file - UIBotTestUtils.openFile(remoteRobot, projectName, Constants.SERVER_XML, projectName, "src", "main", "liberty", "config"); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVER_XML, projectName, "src", "main", "liberty", "config"); // open server.env file - UIBotTestUtils.openFile(remoteRobot, projectName, Constants.SERVER_ENV, projectName, "src", "main", "liberty", "config"); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVER_ENV, projectName, "src", "main", "liberty", "config"); // open bootstrap.properties file - UIBotTestUtils.openFile(remoteRobot, projectName, Constants.BOOTSTRAP_PROPERTIES, projectName, "src", "main", "liberty", "config"); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.BOOTSTRAP_PROPERTIES, projectName, "src", "main", "liberty", "config"); // Removes the build tool window if it is opened. This prevents text to be hidden by it. UIBotTestUtils.removeToolWindow(remoteRobot, "Build:"); diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java index ae0568407..fcbab12f6 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java @@ -12,8 +12,8 @@ import com.automation.remarks.junit5.Video; import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.fixtures.JTreeFixture; +import io.openliberty.tools.intellij.it.Utils.ItConstants; import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture; -import io.openliberty.tools.intellij.util.Constants; import org.junit.jupiter.api.*; import java.nio.file.Path; @@ -65,10 +65,10 @@ public static void cleanup() { projectFrame.findText("META-INF").doubleClick(); projectFrame.findText("resources").doubleClick(); - UIBotTestUtils.closeFileEditorTab(remoteRobot, Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA, "5"); - UIBotTestUtils.closeFileEditorTab(remoteRobot, Constants.MPG_PROPERTIES, "5"); + UIBotTestUtils.closeFileEditorTab(remoteRobot, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA, "5"); + UIBotTestUtils.closeFileEditorTab(remoteRobot, ItConstants.MPG_PROPERTIES, "5"); if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, Constants.COMPACT_MODE, 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, ItConstants.COMPACT_MODE, 3); } UIBotTestUtils.closeProjectView(remoteRobot); UIBotTestUtils.closeProjectFrame(remoteRobot); @@ -86,7 +86,7 @@ public void testInsertCodeSnippetIntoJavaPart() { String insertedCode = "public class ServiceLiveHealthCheck implements HealthCheck {"; // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA); + UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); // Save the current content. UIBotTestUtils.copyWindowContent(remoteRobot); @@ -96,8 +96,8 @@ public void testInsertCodeSnippetIntoJavaPart() { // Insert a code snippet into java part try { - UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA, snippetStr, snippetChooser); - Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "health",Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA); + UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA, snippetStr, snippetChooser); + Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "health",ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); TestUtils.validateCodeInJavaSrc(pathToSrc.toString(), insertedCode); } finally { // Replace modified content with the original content @@ -117,14 +117,14 @@ public void testMPDiagnosticsInJavaPart() { String expectedHoverData = "The class `io.openliberty.mp.sample.health.ServiceLiveHealthCheck` implementing the HealthCheck interface should use the @Liveness, @Readiness or @Health annotation."; // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA); + UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); // Save the current content. UIBotTestUtils.copyWindowContent(remoteRobot); // Delete the liveness annotation - UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot, Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA, livenessString); - Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "health", Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA); + UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA, livenessString); + Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "health", ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); try { // validate @Liveness no longer found in java part @@ -135,7 +135,7 @@ public void testMPDiagnosticsInJavaPart() { int maxWait = 60, delay = 5; // in some cases it can take 35s for the diagnostic to appear for (int i = 0; i <= maxWait; i += delay) { //there should be a diagnostic - move cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA, UIBotTestUtils.PopupType.DIAGNOSTIC); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA, UIBotTestUtils.PopupType.DIAGNOSTIC); foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC); if (!foundHoverData.isBlank()) { @@ -163,21 +163,21 @@ public void testMPQuickFixInJavaFile() { String mainQuickFixActionStr = "Generate OpenAPI Annotations for 'ServiceLiveHealthCheck'"; // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA); + UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); // Save the current content. UIBotTestUtils.copyWindowContent(remoteRobot); // Delete the liveness annotation - UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot,Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA, livenessString); - Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "health", Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA); + UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot,ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA, livenessString); + Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "health", ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); try { // validate @Liveness no longer found in java part TestUtils.validateStringNotInFile(pathToSrc.toString(), livenessString); //there should be a diagnostic - move cursor to hover point - UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA, quickfixChooserString); + UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA, quickfixChooserString); // trigger and use the quickfix popup attached to the diagnostic UIBotTestUtils.chooseQuickFix(remoteRobot, quickfixChooserString); @@ -202,14 +202,14 @@ public void testInsertMicroProfileProperty() { String expectedMpCfgPropertiesString = "mp.health.disable-default-procedures=true"; // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.MPG_PROPERTIES); + UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.MPG_PROPERTIES); // Save the current microprofile-config.properties content. UIBotTestUtils.copyWindowContent(remoteRobot); try { - UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, Constants.MPG_PROPERTIES, cfgSnippet, cfgNameChooserSnippet, cfgValueSnippet, true); - Path pathToMpCfgProperties = Paths.get(projectsPath, projectName, "src", "main", "resources", "META-INF", Constants.MPG_PROPERTIES); + UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, ItConstants.MPG_PROPERTIES, cfgSnippet, cfgNameChooserSnippet, cfgValueSnippet, true); + Path pathToMpCfgProperties = Paths.get(projectsPath, projectName, "src", "main", "resources", "META-INF", ItConstants.MPG_PROPERTIES); TestUtils.validateStringInFile(pathToMpCfgProperties.toString(), expectedMpCfgPropertiesString); } finally { // Replace modified microprofile-config.properties with the original content @@ -232,7 +232,7 @@ public void testMicroProfileConfigHover() { "java.lang.StringValue: http://localhost:9081/data/client/service"; //mover cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, Constants.MPG_PROPERTIES, UIBotTestUtils.PopupType.DOCUMENTATION); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, ItConstants.MPG_PROPERTIES, UIBotTestUtils.PopupType.DOCUMENTATION); String hoverFoundOutcome = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DOCUMENTATION); // if the LS has not yet poulated the popup, re-get the popup data @@ -262,16 +262,16 @@ public void testDiagnosticInMicroProfileConfigProperties() { String expectedHoverData = "Type mismatch: boolean expected. By default, this value will be interpreted as 'false'"; // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.MPG_PROPERTIES); + UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.MPG_PROPERTIES); // Save the current content. UIBotTestUtils.copyWindowContent(remoteRobot); try { - UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, Constants.MPG_PROPERTIES, MPCfgSnippet, MPCfgNameChooserSnippet, incorrectValue, false); + UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, ItConstants.MPG_PROPERTIES, MPCfgSnippet, MPCfgNameChooserSnippet, incorrectValue, false); //move cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, incorrectValue, Constants.MPG_PROPERTIES, UIBotTestUtils.PopupType.DIAGNOSTIC); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, incorrectValue, ItConstants.MPG_PROPERTIES, UIBotTestUtils.PopupType.DIAGNOSTIC); String foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC); TestUtils.validateHoverData(expectedHoverData, foundHoverData); } finally { @@ -295,19 +295,19 @@ public void testQuickFixInMicroProfileConfigProperties() { String correctedValue = "mp.health.disable-default-procedures=true"; String expectedHoverData = "Type mismatch: boolean expected. By default, this value will be interpreted as 'false'"; - Path pathToMpCfgProperties = Paths.get(projectsPath, projectName,"src", "main", "resources", "META-INF", Constants.MPG_PROPERTIES); + Path pathToMpCfgProperties = Paths.get(projectsPath, projectName,"src", "main", "resources", "META-INF", ItConstants.MPG_PROPERTIES); // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.MPG_PROPERTIES); + UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.MPG_PROPERTIES); // Save the current content. UIBotTestUtils.copyWindowContent(remoteRobot); try { - UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, Constants.MPG_PROPERTIES, MPCfgSnippet, MPCfgNameChooserSnippet, incorrectValue, false); + UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, ItConstants.MPG_PROPERTIES, MPCfgSnippet, MPCfgNameChooserSnippet, incorrectValue, false); //move cursor to hover point - UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, incorrectValue, Constants.MPG_PROPERTIES, quickfixChooserString); + UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, incorrectValue, ItConstants.MPG_PROPERTIES, quickfixChooserString); UIBotTestUtils.chooseQuickFix(remoteRobot, quickfixChooserString); TestUtils.validateStanzaInConfigFile(pathToMpCfgProperties.toString(), correctedValue); @@ -333,7 +333,7 @@ public static void prepareEnv(String projectPath, String projectName) { UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); UIBotTestUtils.openProjectView(remoteRobot); if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, Constants.COMPACT_MODE, 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, ItConstants.COMPACT_MODE, 3); } // IntelliJ does not start building and indexing until the Project View is open UIBotTestUtils.waitForIndexing(remoteRobot); @@ -345,7 +345,7 @@ public static void prepareEnv(String projectPath, String projectName) { JTreeFixture projTree = projectFrame.getProjectViewJTree(projectName); UIBotTestUtils.openFile(remoteRobot, projectName, "ServiceLiveHealthCheck", projectName, "src", "main", "java", "io.openliberty.mp.sample", "health"); - UIBotTestUtils.openFile(remoteRobot, projectName, Constants.MPG_PROPERTIES, projectName, "src", "main", "resources", "META-INF"); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.MPG_PROPERTIES, projectName, "src", "main", "resources", "META-INF"); // Removes the build tool window if it is opened. This prevents text to be hidden by it. UIBotTestUtils.removeToolWindow(remoteRobot, "Build:"); diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java index 4388b7fac..63d9da7c2 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java @@ -13,8 +13,8 @@ import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.fixtures.ComponentFixture; import com.intellij.remoterobot.utils.Keyboard; +import io.openliberty.tools.intellij.it.Utils.ItConstants; import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture; -import io.openliberty.tools.intellij.util.Constants; import org.junit.jupiter.api.*; import org.junit.jupiter.api.condition.EnabledOnOs; import org.junit.jupiter.api.condition.OS; @@ -295,8 +295,8 @@ public static void cleanup() { */ protected static void closeProjectView() { if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, Constants.CLOSE_ALL_TABS, 3); - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, Constants.COMPACT_MODE, 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, ItConstants.CLOSE_ALL_TABS, 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, ItConstants.COMPACT_MODE, 3); } UIBotTestUtils.closeLibertyToolWindow(remoteRobot); UIBotTestUtils.closeProjectView(remoteRobot); @@ -1140,7 +1140,7 @@ public static void prepareEnv(String projectPath, String projectName) { UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); UIBotTestUtils.openProjectView(remoteRobot); if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, Constants.COMPACT_MODE, 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, ItConstants.COMPACT_MODE, 3); } // IntelliJ does not start building and indexing until the Project View is open UIBotTestUtils.waitForIndexing(remoteRobot); @@ -1158,7 +1158,7 @@ public static void prepareEnv(String projectPath, String projectName) { UIBotTestUtils.closeAllEditorTabs(remoteRobot); } else { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, Constants.CLOSE_ALL_TABS, 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, ItConstants.CLOSE_ALL_TABS, 3); } TestUtils.printTrace(TestUtils.TraceSevLevel.INFO, diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java index 2115ac29e..f0302691b 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java @@ -11,7 +11,7 @@ import com.automation.remarks.junit5.Video; import com.intellij.remoterobot.RemoteRobot; -import io.openliberty.tools.intellij.util.Constants; +import io.openliberty.tools.intellij.it.Utils.ItConstants; import org.junit.jupiter.api.*; import java.nio.file.Files; @@ -86,7 +86,7 @@ public void afterEach(TestInfo info) { @AfterAll public static void cleanup() { if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, Constants.COMPACT_MODE, 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, ItConstants.COMPACT_MODE, 3); } UIBotTestUtils.closeLibertyToolWindow(remoteRobot); UIBotTestUtils.closeProjectView(remoteRobot); @@ -195,8 +195,8 @@ public void testsRefreshProjectWithServerXmlOnly() { UIBotTestUtils.waitForLTWNoProjectDetectedMsg(remoteRobot, 10); // Copy a valid server.xml file to this project's src/main/liberty/config directory. - Path validServerXml = Paths.get(getHelperFilesDirPath(), Constants.SERVER_XML); - Path destination = Paths.get(getProjectsDirPath(), getSmNLTRestProjectName(), "src", "main", "liberty", "config", Constants.SERVER_XML); + Path validServerXml = Paths.get(getHelperFilesDirPath(), ItConstants.SERVER_XML); + Path destination = Paths.get(getProjectsDirPath(), getSmNLTRestProjectName(), "src", "main", "liberty", "config", ItConstants.SERVER_XML); try { Files.copy(validServerXml, destination, StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING); @@ -303,7 +303,7 @@ public static void prepareEnv(String projectPath, String projectName) { UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); UIBotTestUtils.openProjectView(remoteRobot); if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, Constants.COMPACT_MODE, 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, ItConstants.COMPACT_MODE, 3); } // IntelliJ does not start building and indexing until the Project View is open UIBotTestUtils.waitForIndexing(remoteRobot); diff --git a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java index 2d76e7e17..906f59e1e 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java @@ -9,7 +9,7 @@ *******************************************************************************/ package io.openliberty.tools.intellij.it; -import io.openliberty.tools.intellij.util.Constants; +import io.openliberty.tools.intellij.it.Utils.ItConstants; import org.junit.jupiter.api.Assertions; import java.io.*; @@ -542,7 +542,7 @@ public static boolean isServerStopNeeded(String wlpInstallPath) { */ public static void checkDebugPort(String absoluteWLPPath, int debugPort) throws IOException { // Retrieve the WLP server.env file path - Path serverEnvPath = Paths.get(absoluteWLPPath, "wlp", "usr", "servers", "defaultServer", Constants.SERVER_ENV); + Path serverEnvPath = Paths.get(absoluteWLPPath, "wlp", "usr", "servers", "defaultServer", ItConstants.SERVER_ENV); // Read all lines from server.env List lines = Files.readAllLines(serverEnvPath); // Check if Debug Port is set to the specified port diff --git a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java index 4bc6a0bed..6e3b07a78 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java @@ -17,10 +17,10 @@ import com.intellij.remoterobot.utils.Keyboard; import com.intellij.remoterobot.utils.RepeatUtilsKt; import com.intellij.remoterobot.utils.WaitForConditionTimeoutException; +import io.openliberty.tools.intellij.it.Utils.ItConstants; import io.openliberty.tools.intellij.it.fixtures.DialogFixture; import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture; import io.openliberty.tools.intellij.it.fixtures.WelcomeFrameFixture; -import io.openliberty.tools.intellij.util.Constants; import org.assertj.swing.core.MouseButton; import org.junit.Assert; import org.junit.jupiter.api.Assertions; @@ -762,7 +762,7 @@ public static void closeFileEditorTab(RemoteRobot remoteRobot, String editorTabN */ public static void closeAllEditorTabs(RemoteRobot remoteRobot) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); - projectFrame.clickOnMainMenuWithActions(remoteRobot, "Window", "Editor Tabs", Constants.CLOSE_ALL_TABS); + projectFrame.clickOnMainMenuWithActions(remoteRobot, "Window", "Editor Tabs", ItConstants.CLOSE_ALL_TABS); } /** @@ -830,7 +830,7 @@ public static void hoverInAppServerCfgFile(RemoteRobot remoteRobot, String hover // Find the target text on the editor and move the move to it. editorNew.findText(contains(hoverTarget)).moveMouse(); // clear and "lightbulb" icons? - if (!hoverFile.equals(Constants.SERVER_XML)) { + if (!hoverFile.equals(ItConstants.SERVER_XML)) { keyboard.hotKey(VK_ESCAPE); } @@ -1208,7 +1208,7 @@ else if (fileName.equals("bootstrap.properties")) { public static void insertStanzaInAppServerXML(RemoteRobot remoteRobot, String stanzaSnippet, int line, int col, InsertionType type, boolean completeWithPopup) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(30)); - clickOnFileTab(remoteRobot, Constants.SERVER_XML); + clickOnFileTab(remoteRobot, ItConstants.SERVER_XML); Locator locator = byXpath("//div[@class='EditorCompositePanel']//div[@class='EditorComponentImpl']"); EditorFixture editorNew = remoteRobot.find(EditorFixture.class, locator, Duration.ofSeconds(20)); editorNew.click(); @@ -1741,14 +1741,14 @@ public static void runActionFromSearchEverywherePanel(RemoteRobot remoteRobot, S } /* - * We throw a RuntimeException with error only if the action is not Constants.CLOSE_ALL_TABS .The Constants.CLOSE_ALL_TABS action + * We throw a RuntimeException with error only if the action is not "Close All Tabs" .The "Close All Tabs" action * is used as part of the cleanup process in the @AfterAll-annotated method within the SingleModMPProjectTestCommon class. * * When running individual tests in this class, it is not always guaranteed that at least one file tab will be open in the Editor Window. - * If we are not specify a condition check for Constants.CLOSE_ALL_TABS action when no file tabs are open, the runActionFromSearchEverywherePanel method + * If we are not specify a condition check for "Close All Tabs" action when no file tabs are open, the runActionFromSearchEverywherePanel method * will throw a RuntimeException, causing the test to fail. */ - if (error != null && !action.equals(Constants.CLOSE_ALL_TABS)) { + if (error != null && !action.equals(ItConstants.CLOSE_ALL_TABS)) { throw new RuntimeException("Failed to run the " + action + " action using the search everywhere option", error); } } @@ -2678,7 +2678,7 @@ public static void findWelcomeFrame(RemoteRobot remoteRobot) { UIBotTestUtils.closeAllEditorTabs(remoteRobot); } else { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, Constants.CLOSE_ALL_TABS, 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, ItConstants.CLOSE_ALL_TABS, 3); } UIBotTestUtils.closeProjectView(remoteRobot); UIBotTestUtils.closeProjectFrame(remoteRobot); diff --git a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java new file mode 100644 index 000000000..3a88a4313 --- /dev/null +++ b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java @@ -0,0 +1,22 @@ +package io.openliberty.tools.intellij.it.Utils; + +public class ItConstants { + + /** + * Constants for Integration testing + */ + public static final String SYSTEM_RESOURCE_JAVA = "SystemResource.java"; + public static final String SYSTEM_RESOURCE_2_JAVA = "SystemResource2.java"; + public static final String SYSTEM_RESOURCE = "SystemResource"; + public static final String SYSTEM_RESOURCE_2 = "SystemResource2"; + + public static final String SERVER_XML = "server.xml"; + public static final String SERVER_ENV = "server.env"; + public static final String BOOTSTRAP_PROPERTIES = "bootstrap.properties"; + public static final String COMPACT_MODE = "Compact Mode"; + + public static final String SERVICE_LIVE_HEALTH_CHECK_JAVA = "ServiceLiveHealthCheck.java"; + public static final String MPG_PROPERTIES = "microprofile-config.properties"; + + public static final String CLOSE_ALL_TABS = "Close All Tabs"; +} From fcac98e854f6605aaa0aeb0d17cae88d5d6178c9 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Thu, 2 Jan 2025 11:34:45 +0530 Subject: [PATCH 07/28] Changed copyright year --- src/main/java/io/openliberty/tools/intellij/util/Constants.java | 2 +- .../tools/intellij/it/SingleModJakartaLSTestCommon.java | 2 +- .../openliberty/tools/intellij/it/SingleModMPLSTestCommon.java | 2 +- .../tools/intellij/it/SingleModMPProjectTestCommon.java | 2 +- .../tools/intellij/it/SingleModNLTRestProjectTestCommon.java | 2 +- src/test/java/io/openliberty/tools/intellij/it/TestUtils.java | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/openliberty/tools/intellij/util/Constants.java b/src/main/java/io/openliberty/tools/intellij/util/Constants.java index 275899b57..6ad35a05c 100644 --- a/src/main/java/io/openliberty/tools/intellij/util/Constants.java +++ b/src/main/java/io/openliberty/tools/intellij/util/Constants.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2024 IBM Corporation. + * Copyright (c) 2020, 2025 IBM Corporation. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java index 309c55e84..776344f61 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023, 2024 IBM Corporation. + * Copyright (c) 2023, 2025 IBM Corporation. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java index fcbab12f6..2c8a9b352 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023, 2024 IBM Corporation. + * Copyright (c) 2023, 2025 IBM Corporation. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java index 63d9da7c2..f5c8cb838 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023, 2024 IBM Corporation. + * Copyright (c) 2023, 2025 IBM Corporation. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java index f0302691b..f88a21847 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023, 2024 IBM Corporation. + * Copyright (c) 2023, 2025 IBM Corporation. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at diff --git a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java index 906f59e1e..510394c28 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023, 2024 IBM Corporation. + * Copyright (c) 2023, 2025 IBM Corporation. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at From 02a2265808ca3af66c8e168f571b44c70982ff07 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Thu, 2 Jan 2025 11:35:07 +0530 Subject: [PATCH 08/28] copyright header added --- .../openliberty/tools/intellij/it/Utils/ItConstants.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java index 3a88a4313..fb723ec70 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java +++ b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java @@ -1,3 +1,12 @@ +/******************************************************************************* + * Copyright (c) 2025 IBM Corporation. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ package io.openliberty.tools.intellij.it.Utils; public class ItConstants { From ce6261409d0c099360262310bbc677dd092ff27f Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Wed, 8 Jan 2025 10:28:02 +0530 Subject: [PATCH 09/28] SingleModJakartaLSTestCommon class --- .../intellij/it/SingleModJakartaLSTestCommon.java | 12 ++++++------ .../tools/intellij/it/Utils/ItConstants.java | 4 ++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java index 776344f61..c27cb167b 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java @@ -92,7 +92,7 @@ public void testInsertJakartaCodeSnippetIntoJavaPart() { // Insert a code snippet into java part try { UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, ItConstants.SYSTEM_RESOURCE_JAVA, snippetStr, snippetChooser); - Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "system", ItConstants.SYSTEM_RESOURCE_JAVA); + Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.SYSTEM_DIR_PATH, ItConstants.SYSTEM_RESOURCE_JAVA); TestUtils.validateCodeInJavaSrc(pathToSrc.toString(), insertedCode); } finally { @@ -110,7 +110,7 @@ public void testJakartaDiagnosticsInJavaPart() { String privateString = "private Response getProperties() {"; String flaggedString = "getProperties"; String expectedHoverData = "Only public methods can be exposed as resource methods"; - Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "system", ItConstants.SYSTEM_RESOURCE_2_JAVA); + Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.SYSTEM_DIR_PATH, ItConstants.SYSTEM_RESOURCE_2_JAVA); // get focus on file tab prior to copy UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA); @@ -145,7 +145,7 @@ public void testJakartaQuickFixInJavaPart() { String privateString = "private Response getProperties() {"; String flaggedString = "getProperties"; - Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "system", ItConstants.SYSTEM_RESOURCE_2_JAVA); + Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.SYSTEM_DIR_PATH, ItConstants.SYSTEM_RESOURCE_2_JAVA); String quickfixChooserString = "Make method public"; // get focus on file tab prior to copy @@ -199,10 +199,10 @@ public static void prepareEnv(String projectPath, String projectName) { // expand project directories that are specific to this test app being used by these testcases // must be expanded here before trying to open specific files - projTree.expand(projectName, "src", "main", "java", "io.openliberty.mp.sample", "system"); + projTree.expand(projectName, ItConstants.SYSTEM_DIR_PATH); - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE, projectName, "src", "main", "java", "io.openliberty.mp.sample", "system"); - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE_2, projectName, "src", "main", "java", "io.openliberty.mp.sample", "system"); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE, projectName, ItConstants.SYSTEM_DIR_PATH); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE_2, projectName, ItConstants.SYSTEM_DIR_PATH); // Removes the build tool window if it is opened. This prevents text to be hidden by it. diff --git a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java index fb723ec70..9cdf2b21d 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java +++ b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java @@ -19,6 +19,10 @@ public class ItConstants { public static final String SYSTEM_RESOURCE = "SystemResource"; public static final String SYSTEM_RESOURCE_2 = "SystemResource2"; + public static final String CONFIG_DIR_PATH = "src/main/liberty/config"; + public static final String SYSTEM_DIR_PATH = "src/main/java/io/openliberty/mp/sample/system"; + public static final String HEALTH_DIR_PATH = "src/main/java/io/openliberty/mp/sample/health"; + public static final String META_INF_DIR_PATH = "src/main/resources/META-INF"; public static final String SERVER_XML = "server.xml"; public static final String SERVER_ENV = "server.env"; public static final String BOOTSTRAP_PROPERTIES = "bootstrap.properties"; From 42261b6ed2fa112a32176e60a01099163d345cac Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Wed, 8 Jan 2025 10:28:10 +0530 Subject: [PATCH 10/28] SingleModLibertyLSTestCommon class --- .../it/SingleModLibertyLSTestCommon.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java index cdfc60127..e359d0f1e 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -131,7 +131,7 @@ public void testInsertFeatureIntoServerXML() { // Insert a new element in server.xml. try { UIBotTestUtils.insertStanzaInAppServerXML(remoteRobot, stanzaSnippet, 18, 40, UIBotTestUtils.InsertionType.FEATURE, true); - Path pathToServerXML = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", ItConstants.SERVER_XML); + Path pathToServerXML = Paths.get(projectsPath, projectName, ItConstants.CONFIG_DIR_PATH, ItConstants.SERVER_XML); TestUtils.validateStanzaInConfigFile(pathToServerXML.toString(), insertedFeature); } finally { // Replace server.xml content with the original content @@ -159,7 +159,7 @@ public void testInsertLibertyConfigElementIntoServerXML() { try { UIBotTestUtils.insertStanzaInAppServerXML(remoteRobot, stanzaSnippet, 20, 0, UIBotTestUtils.InsertionType.ELEMENT, true); TestUtils.sleepAndIgnoreException(2); // wait for editor to update - Path pathToServerXML = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", ItConstants.SERVER_XML); + Path pathToServerXML = Paths.get(projectsPath, projectName, ItConstants.CONFIG_DIR_PATH, ItConstants.SERVER_XML); TestUtils.validateStanzaInConfigFile(pathToServerXML.toString(), insertedConfig); } finally { // Replace server.xml content with the original content @@ -188,7 +188,7 @@ public void testInsertLibertyConfigIntoServerEnvForCapitalCase() { try { UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, ItConstants.SERVER_ENV, envCfgSnippet, envCfgNameChooserSnippet, envCfgValueSnippet, true); - Path pathToServerEnv = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", ItConstants.SERVER_ENV); + Path pathToServerEnv = Paths.get(projectsPath, projectName, ItConstants.CONFIG_DIR_PATH, ItConstants.SERVER_ENV); TestUtils.validateStringInFile(pathToServerEnv.toString(), expectedServerEnvString); } finally { // Replace server.xml content with the original content @@ -273,7 +273,7 @@ public void testInsertLibertyConfigIntoBootstrapPropsForLowerCase() { try { UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, ItConstants.BOOTSTRAP_PROPERTIES, configNameSnippet, configNameChooserSnippet, configValueSnippet, true); - Path pathToBootstrapProps = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", ItConstants.BOOTSTRAP_PROPERTIES); + Path pathToBootstrapProps = Paths.get(projectsPath, projectName, ItConstants.CONFIG_DIR_PATH, ItConstants.BOOTSTRAP_PROPERTIES); TestUtils.validateStringInFile(pathToBootstrapProps.toString(), expectedBootstrapPropsString); } finally { // Replace server.xml content with the original content @@ -406,7 +406,7 @@ public void testDiagnosticInServerXML() { String expectedHoverData = "cvc-datatype-valid.1.2.3: 'wrong' is not a valid value of union type 'booleanType'."; Path pathToServerXML = null; - pathToServerXML = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", ItConstants.SERVER_XML); + pathToServerXML = Paths.get(projectsPath, projectName, ItConstants.CONFIG_DIR_PATH, ItConstants.SERVER_XML); // get focus on server.xml tab prior to copy UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVER_XML); @@ -442,7 +442,7 @@ public void testQuickFixInServerXML() { String expectedHoverData = "cvc-datatype-valid.1.2.3: 'wrong' is not a valid value of union type 'booleanType'."; Path pathToServerXML = null; - pathToServerXML = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", ItConstants.SERVER_XML); + pathToServerXML = Paths.get(projectsPath, projectName, ItConstants.CONFIG_DIR_PATH, ItConstants.SERVER_XML); // get focus on server.xml tab prior to copy UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVER_XML); @@ -592,16 +592,16 @@ public static void prepareEnv(String projectPath, String projectName) { // get a JTreeFixture reference to the file project viewer entry ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2)); JTreeFixture projTree = projectFrame.getProjectViewJTree(projectName); - projTree.expand(projectName, "src", "main", "liberty", "config"); + projTree.expand(projectName, ItConstants.CONFIG_DIR_PATH); // open server.xml file - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVER_XML, projectName, "src", "main", "liberty", "config"); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVER_XML, projectName, ItConstants.CONFIG_DIR_PATH); // open server.env file - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVER_ENV, projectName, "src", "main", "liberty", "config"); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVER_ENV, projectName, ItConstants.CONFIG_DIR_PATH); // open bootstrap.properties file - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.BOOTSTRAP_PROPERTIES, projectName, "src", "main", "liberty", "config"); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.BOOTSTRAP_PROPERTIES, projectName, ItConstants.CONFIG_DIR_PATH); // Removes the build tool window if it is opened. This prevents text to be hidden by it. UIBotTestUtils.removeToolWindow(remoteRobot, "Build:"); From 4fc023b68f264491c418cf12982b8c24be8f1d5f Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Wed, 8 Jan 2025 10:28:21 +0530 Subject: [PATCH 11/28] SingleModMPLSTestCommon class --- .../tools/intellij/it/SingleModMPLSTestCommon.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java index 2c8a9b352..a4eba38d1 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java @@ -97,7 +97,7 @@ public void testInsertCodeSnippetIntoJavaPart() { // Insert a code snippet into java part try { UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA, snippetStr, snippetChooser); - Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "health",ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); + Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.HEALTH_DIR_PATH, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); TestUtils.validateCodeInJavaSrc(pathToSrc.toString(), insertedCode); } finally { // Replace modified content with the original content @@ -124,7 +124,7 @@ public void testMPDiagnosticsInJavaPart() { // Delete the liveness annotation UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA, livenessString); - Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "health", ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); + Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.HEALTH_DIR_PATH, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); try { // validate @Liveness no longer found in java part @@ -170,7 +170,7 @@ public void testMPQuickFixInJavaFile() { // Delete the liveness annotation UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot,ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA, livenessString); - Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "health", ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); + Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.HEALTH_DIR_PATH, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); try { // validate @Liveness no longer found in java part @@ -209,7 +209,7 @@ public void testInsertMicroProfileProperty() { try { UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, ItConstants.MPG_PROPERTIES, cfgSnippet, cfgNameChooserSnippet, cfgValueSnippet, true); - Path pathToMpCfgProperties = Paths.get(projectsPath, projectName, "src", "main", "resources", "META-INF", ItConstants.MPG_PROPERTIES); + Path pathToMpCfgProperties = Paths.get(projectsPath, projectName, ItConstants.META_INF_DIR_PATH, ItConstants.MPG_PROPERTIES); TestUtils.validateStringInFile(pathToMpCfgProperties.toString(), expectedMpCfgPropertiesString); } finally { // Replace modified microprofile-config.properties with the original content @@ -295,7 +295,7 @@ public void testQuickFixInMicroProfileConfigProperties() { String correctedValue = "mp.health.disable-default-procedures=true"; String expectedHoverData = "Type mismatch: boolean expected. By default, this value will be interpreted as 'false'"; - Path pathToMpCfgProperties = Paths.get(projectsPath, projectName,"src", "main", "resources", "META-INF", ItConstants.MPG_PROPERTIES); + Path pathToMpCfgProperties = Paths.get(projectsPath, projectName,ItConstants.META_INF_DIR_PATH, ItConstants.MPG_PROPERTIES); // get focus on file tab prior to copy UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.MPG_PROPERTIES); @@ -344,8 +344,8 @@ public static void prepareEnv(String projectPath, String projectName) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2)); JTreeFixture projTree = projectFrame.getProjectViewJTree(projectName); - UIBotTestUtils.openFile(remoteRobot, projectName, "ServiceLiveHealthCheck", projectName, "src", "main", "java", "io.openliberty.mp.sample", "health"); - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.MPG_PROPERTIES, projectName, "src", "main", "resources", "META-INF"); + UIBotTestUtils.openFile(remoteRobot, projectName, "ServiceLiveHealthCheck", projectName, ItConstants.HEALTH_DIR_PATH); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.MPG_PROPERTIES, projectName, ItConstants.META_INF_DIR_PATH); // Removes the build tool window if it is opened. This prevents text to be hidden by it. UIBotTestUtils.removeToolWindow(remoteRobot, "Build:"); From 92e9776ed9e5fc5ff23cf532aab66ec8929d97bb Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Wed, 8 Jan 2025 10:30:47 +0530 Subject: [PATCH 12/28] SingleModNLTRestProjectTestCommon class --- .../tools/intellij/it/SingleModNLTRestProjectTestCommon.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java index f88a21847..970423362 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java @@ -196,7 +196,7 @@ public void testsRefreshProjectWithServerXmlOnly() { // Copy a valid server.xml file to this project's src/main/liberty/config directory. Path validServerXml = Paths.get(getHelperFilesDirPath(), ItConstants.SERVER_XML); - Path destination = Paths.get(getProjectsDirPath(), getSmNLTRestProjectName(), "src", "main", "liberty", "config", ItConstants.SERVER_XML); + Path destination = Paths.get(getProjectsDirPath(), getSmNLTRestProjectName(), ItConstants.CONFIG_DIR_PATH, ItConstants.SERVER_XML); try { Files.copy(validServerXml, destination, StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING); From 2bf831ce7892ebb6ee77ed219391422cabc740a6 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Wed, 8 Jan 2025 11:21:00 +0530 Subject: [PATCH 13/28] TestUtils class --- src/test/java/io/openliberty/tools/intellij/it/TestUtils.java | 4 ++-- .../io/openliberty/tools/intellij/it/Utils/ItConstants.java | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java index 510394c28..d929faf70 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java @@ -28,7 +28,7 @@ public class TestUtils { /** * WLP messages.log path. */ - public static final Path WLP_MSGLOG_PATH = Paths.get("wlp", "usr", "servers", "defaultServer", "logs", "messages.log"); + public static final Path WLP_MSGLOG_PATH = Paths.get(ItConstants.DEFAULT_SERVER_PATH, "logs", "messages.log"); /** * Liberty server stopped message: @@ -542,7 +542,7 @@ public static boolean isServerStopNeeded(String wlpInstallPath) { */ public static void checkDebugPort(String absoluteWLPPath, int debugPort) throws IOException { // Retrieve the WLP server.env file path - Path serverEnvPath = Paths.get(absoluteWLPPath, "wlp", "usr", "servers", "defaultServer", ItConstants.SERVER_ENV); + Path serverEnvPath = Paths.get(absoluteWLPPath, ItConstants.DEFAULT_SERVER_PATH, ItConstants.SERVER_ENV); // Read all lines from server.env List lines = Files.readAllLines(serverEnvPath); // Check if Debug Port is set to the specified port diff --git a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java index 9cdf2b21d..679624dc8 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java +++ b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java @@ -23,6 +23,7 @@ public class ItConstants { public static final String SYSTEM_DIR_PATH = "src/main/java/io/openliberty/mp/sample/system"; public static final String HEALTH_DIR_PATH = "src/main/java/io/openliberty/mp/sample/health"; public static final String META_INF_DIR_PATH = "src/main/resources/META-INF"; + public static final String DEFAULT_SERVER_PATH = "wlp/usr/servers/defaultServer"; public static final String SERVER_XML = "server.xml"; public static final String SERVER_ENV = "server.env"; public static final String BOOTSTRAP_PROPERTIES = "bootstrap.properties"; From 0618396edeb14f3523f5b9c1988970dd2c41c26c Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Wed, 8 Jan 2025 19:27:20 +0530 Subject: [PATCH 14/28] Update ItConstants.java --- .../tools/intellij/it/Utils/ItConstants.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java index 679624dc8..7f84a2bd8 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java +++ b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java @@ -9,6 +9,8 @@ *******************************************************************************/ package io.openliberty.tools.intellij.it.Utils; +import java.nio.file.Paths; + public class ItConstants { /** @@ -19,11 +21,11 @@ public class ItConstants { public static final String SYSTEM_RESOURCE = "SystemResource"; public static final String SYSTEM_RESOURCE_2 = "SystemResource2"; - public static final String CONFIG_DIR_PATH = "src/main/liberty/config"; - public static final String SYSTEM_DIR_PATH = "src/main/java/io/openliberty/mp/sample/system"; - public static final String HEALTH_DIR_PATH = "src/main/java/io/openliberty/mp/sample/health"; - public static final String META_INF_DIR_PATH = "src/main/resources/META-INF"; - public static final String DEFAULT_SERVER_PATH = "wlp/usr/servers/defaultServer"; + public static final String CONFIG_DIR_PATH = Paths.get("src", "main", "liberty", "config").toString(); + public static final String SYSTEM_DIR_PATH = Paths.get("src", "main", "java", "io", "openliberty", "mp", "sample", "system").toString(); + public static final String HEALTH_DIR_PATH = Paths.get("src", "main", "java", "io", "openliberty", "mp", "sample", "health").toString(); + public static final String META_INF_DIR_PATH = Paths.get("src", "main", "resources", "META-INF").toString(); + public static final String DEFAULT_SERVER_PATH = Paths.get("wlp", "usr", "servers", "defaultServer").toString(); public static final String SERVER_XML = "server.xml"; public static final String SERVER_ENV = "server.env"; public static final String BOOTSTRAP_PROPERTIES = "bootstrap.properties"; From 0588eba8907d66eefb1d69e1deeb247fb8a950b3 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Mon, 13 Jan 2025 19:34:42 +0530 Subject: [PATCH 15/28] changed the path to / seperated --- .../tools/intellij/it/Utils/ItConstants.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java index 7f84a2bd8..570e4c8cd 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java +++ b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java @@ -21,11 +21,11 @@ public class ItConstants { public static final String SYSTEM_RESOURCE = "SystemResource"; public static final String SYSTEM_RESOURCE_2 = "SystemResource2"; - public static final String CONFIG_DIR_PATH = Paths.get("src", "main", "liberty", "config").toString(); - public static final String SYSTEM_DIR_PATH = Paths.get("src", "main", "java", "io", "openliberty", "mp", "sample", "system").toString(); - public static final String HEALTH_DIR_PATH = Paths.get("src", "main", "java", "io", "openliberty", "mp", "sample", "health").toString(); - public static final String META_INF_DIR_PATH = Paths.get("src", "main", "resources", "META-INF").toString(); - public static final String DEFAULT_SERVER_PATH = Paths.get("wlp", "usr", "servers", "defaultServer").toString(); + public static final String CONFIG_DIR_PATH = "src/main/liberty/config"; + public static final String SYSTEM_DIR_PATH = "src/main/java/io/openliberty/mp/sample/system"; + public static final String HEALTH_DIR_PATH = "src/main/java/io/openliberty/mp/sample/health"; + public static final String META_INF_DIR_PATH = "src/main/resources/META-INF"; + public static final String DEFAULT_SERVER_PATH = "wlp/usr/servers/defaultServer"; public static final String SERVER_XML = "server.xml"; public static final String SERVER_ENV = "server.env"; public static final String BOOTSTRAP_PROPERTIES = "bootstrap.properties"; From b34d02a398105ab58bb220e9bb18f1b09c62bdfa Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Mon, 13 Jan 2025 19:54:52 +0530 Subject: [PATCH 16/28] SingleModMPLSTestCommon class updated --- .../tools/intellij/it/SingleModJakartaLSTestCommon.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java index c27cb167b..f92666e89 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java @@ -201,8 +201,8 @@ public static void prepareEnv(String projectPath, String projectName) { // must be expanded here before trying to open specific files projTree.expand(projectName, ItConstants.SYSTEM_DIR_PATH); - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE, projectName, ItConstants.SYSTEM_DIR_PATH); - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE_2, projectName, ItConstants.SYSTEM_DIR_PATH); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE, projectName, "src", "main", "java", "io.openliberty.mp.sample", "system"); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE_2, projectName, "src", "main", "java", "io.openliberty.mp.sample", "system"); // Removes the build tool window if it is opened. This prevents text to be hidden by it. From 4761fe1b9e49e1c2e3ad0fe4b6d11b7d58c54125 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Mon, 13 Jan 2025 19:55:00 +0530 Subject: [PATCH 17/28] SingleModLibertyLSTestCommon updated --- .../tools/intellij/it/SingleModLibertyLSTestCommon.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java index e359d0f1e..cb3f54547 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -595,13 +595,13 @@ public static void prepareEnv(String projectPath, String projectName) { projTree.expand(projectName, ItConstants.CONFIG_DIR_PATH); // open server.xml file - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVER_XML, projectName, ItConstants.CONFIG_DIR_PATH); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVER_XML, projectName, "src", "main", "liberty", "config"); // open server.env file - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVER_ENV, projectName, ItConstants.CONFIG_DIR_PATH); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVER_ENV, projectName, "src", "main", "liberty", "config"); // open bootstrap.properties file - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.BOOTSTRAP_PROPERTIES, projectName, ItConstants.CONFIG_DIR_PATH); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.BOOTSTRAP_PROPERTIES, projectName, "src", "main", "liberty", "config"); // Removes the build tool window if it is opened. This prevents text to be hidden by it. UIBotTestUtils.removeToolWindow(remoteRobot, "Build:"); From 698703dd34984a11772c518e0f85ac393f058677 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Mon, 13 Jan 2025 19:55:09 +0530 Subject: [PATCH 18/28] SingleModMPLSTestCommon updated --- .../tools/intellij/it/SingleModMPLSTestCommon.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java index a4eba38d1..af91eed66 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java @@ -344,8 +344,8 @@ public static void prepareEnv(String projectPath, String projectName) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2)); JTreeFixture projTree = projectFrame.getProjectViewJTree(projectName); - UIBotTestUtils.openFile(remoteRobot, projectName, "ServiceLiveHealthCheck", projectName, ItConstants.HEALTH_DIR_PATH); - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.MPG_PROPERTIES, projectName, ItConstants.META_INF_DIR_PATH); + UIBotTestUtils.openFile(remoteRobot, projectName, "ServiceLiveHealthCheck", projectName, "src", "main", "java", "io.openliberty.mp.sample", "health"); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.MPG_PROPERTIES, projectName, "src", "main", "resources", "META-INF"); // Removes the build tool window if it is opened. This prevents text to be hidden by it. UIBotTestUtils.removeToolWindow(remoteRobot, "Build:"); From 6f5f2f5daad0cf12e0103eea8912e41a0588b66c Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Mon, 13 Jan 2025 20:07:59 +0530 Subject: [PATCH 19/28] removed extra imports --- .../io/openliberty/tools/intellij/it/Utils/ItConstants.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java index 570e4c8cd..679624dc8 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java +++ b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java @@ -9,8 +9,6 @@ *******************************************************************************/ package io.openliberty.tools.intellij.it.Utils; -import java.nio.file.Paths; - public class ItConstants { /** From 97eac05d7164965f19a5b557ae0ff4f586d40731 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Wed, 15 Jan 2025 11:45:41 +0530 Subject: [PATCH 20/28] messages.log path --- src/test/java/io/openliberty/tools/intellij/it/TestUtils.java | 2 +- .../io/openliberty/tools/intellij/it/Utils/ItConstants.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java index d929faf70..23aaed82f 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java @@ -28,7 +28,7 @@ public class TestUtils { /** * WLP messages.log path. */ - public static final Path WLP_MSGLOG_PATH = Paths.get(ItConstants.DEFAULT_SERVER_PATH, "logs", "messages.log"); + public static final Path WLP_MSGLOG_PATH = Paths.get(ItConstants.MESSAGES_LOG_PATH, "messages.log"); /** * Liberty server stopped message: diff --git a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java index 679624dc8..5662ca5fc 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java +++ b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java @@ -24,6 +24,7 @@ public class ItConstants { public static final String HEALTH_DIR_PATH = "src/main/java/io/openliberty/mp/sample/health"; public static final String META_INF_DIR_PATH = "src/main/resources/META-INF"; public static final String DEFAULT_SERVER_PATH = "wlp/usr/servers/defaultServer"; + public static final String MESSAGES_LOG_PATH = "wlp/usr/servers/defaultServer/logs"; public static final String SERVER_XML = "server.xml"; public static final String SERVER_ENV = "server.env"; public static final String BOOTSTRAP_PROPERTIES = "bootstrap.properties"; From e64cdbd8baba49b5dfcedf018871255bd71a5220 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Fri, 17 Jan 2025 15:52:27 +0530 Subject: [PATCH 21/28] path changed to string array --- .../it/SingleModJakartaLSTestCommon.java | 20 +++++++++++------- .../it/SingleModLibertyLSTestCommon.java | 21 ++++++++++--------- .../intellij/it/SingleModMPLSTestCommon.java | 21 ++++++++++++------- .../it/SingleModNLTRestProjectTestCommon.java | 3 ++- .../tools/intellij/it/TestUtils.java | 11 ++++++++-- .../tools/intellij/it/Utils/ItConstants.java | 15 +++++++------ 6 files changed, 58 insertions(+), 33 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java index f92666e89..a683914b2 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java @@ -16,9 +16,13 @@ import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture; import org.junit.jupiter.api.*; +import java.io.File; import java.nio.file.Path; import java.nio.file.Paths; import java.time.Duration; +import java.util.Arrays; +import java.util.stream.Collectors; +import java.util.stream.Stream; import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitForIgnoringError; @@ -92,7 +96,8 @@ public void testInsertJakartaCodeSnippetIntoJavaPart() { // Insert a code snippet into java part try { UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, ItConstants.SYSTEM_RESOURCE_JAVA, snippetStr, snippetChooser); - Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.SYSTEM_DIR_PATH, ItConstants.SYSTEM_RESOURCE_JAVA); + String systemDirPath = Arrays.stream(ItConstants.SYSTEM_DIR_PATH).map(s -> s.replace(".", "/")).collect(Collectors.joining("/")); + Path pathToSrc = Paths.get(projectsPath, projectName, systemDirPath, ItConstants.SYSTEM_RESOURCE_JAVA); TestUtils.validateCodeInJavaSrc(pathToSrc.toString(), insertedCode); } finally { @@ -110,7 +115,8 @@ public void testJakartaDiagnosticsInJavaPart() { String privateString = "private Response getProperties() {"; String flaggedString = "getProperties"; String expectedHoverData = "Only public methods can be exposed as resource methods"; - Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.SYSTEM_DIR_PATH, ItConstants.SYSTEM_RESOURCE_2_JAVA); + String systemDirPath = Arrays.stream(ItConstants.SYSTEM_DIR_PATH).map(s -> s.replace(".", "/")).collect(Collectors.joining("/")); + Path pathToSrc = Paths.get(projectsPath, projectName, systemDirPath, ItConstants.SYSTEM_RESOURCE_2_JAVA); // get focus on file tab prior to copy UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA); @@ -145,7 +151,8 @@ public void testJakartaQuickFixInJavaPart() { String privateString = "private Response getProperties() {"; String flaggedString = "getProperties"; - Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.SYSTEM_DIR_PATH, ItConstants.SYSTEM_RESOURCE_2_JAVA); + String systemDirPath = Arrays.stream(ItConstants.SYSTEM_DIR_PATH).map(s -> s.replace(".", "/")).collect(Collectors.joining("/")); + Path pathToSrc = Paths.get(projectsPath, projectName, systemDirPath, ItConstants.SYSTEM_RESOURCE_2_JAVA); String quickfixChooserString = "Make method public"; // get focus on file tab prior to copy @@ -199,11 +206,10 @@ public static void prepareEnv(String projectPath, String projectName) { // expand project directories that are specific to this test app being used by these testcases // must be expanded here before trying to open specific files - projTree.expand(projectName, ItConstants.SYSTEM_DIR_PATH); - - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE, projectName, "src", "main", "java", "io.openliberty.mp.sample", "system"); - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE_2, projectName, "src", "main", "java", "io.openliberty.mp.sample", "system"); + projTree.expand(projectName, String.join(File.separator, ItConstants.SYSTEM_DIR_PATH)); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE, TestUtils.combinePath(projectName, ItConstants.SYSTEM_DIR_PATH)); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE_2, TestUtils.combinePath(projectName, ItConstants.SYSTEM_DIR_PATH)); // Removes the build tool window if it is opened. This prevents text to be hidden by it. UIBotTestUtils.removeToolWindow(remoteRobot, "Build:"); diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java index cb3f54547..23f468c18 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -17,6 +17,7 @@ import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture; import org.junit.jupiter.api.*; +import java.io.File; import java.nio.file.Path; import java.nio.file.Paths; import java.time.Duration; @@ -131,7 +132,7 @@ public void testInsertFeatureIntoServerXML() { // Insert a new element in server.xml. try { UIBotTestUtils.insertStanzaInAppServerXML(remoteRobot, stanzaSnippet, 18, 40, UIBotTestUtils.InsertionType.FEATURE, true); - Path pathToServerXML = Paths.get(projectsPath, projectName, ItConstants.CONFIG_DIR_PATH, ItConstants.SERVER_XML); + Path pathToServerXML = Paths.get(projectsPath, projectName, String.join(File.separator, ItConstants.CONFIG_DIR_PATH), ItConstants.SERVER_XML); TestUtils.validateStanzaInConfigFile(pathToServerXML.toString(), insertedFeature); } finally { // Replace server.xml content with the original content @@ -159,7 +160,7 @@ public void testInsertLibertyConfigElementIntoServerXML() { try { UIBotTestUtils.insertStanzaInAppServerXML(remoteRobot, stanzaSnippet, 20, 0, UIBotTestUtils.InsertionType.ELEMENT, true); TestUtils.sleepAndIgnoreException(2); // wait for editor to update - Path pathToServerXML = Paths.get(projectsPath, projectName, ItConstants.CONFIG_DIR_PATH, ItConstants.SERVER_XML); + Path pathToServerXML = Paths.get(projectsPath, projectName, String.join(File.separator, ItConstants.CONFIG_DIR_PATH), ItConstants.SERVER_XML); TestUtils.validateStanzaInConfigFile(pathToServerXML.toString(), insertedConfig); } finally { // Replace server.xml content with the original content @@ -188,7 +189,7 @@ public void testInsertLibertyConfigIntoServerEnvForCapitalCase() { try { UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, ItConstants.SERVER_ENV, envCfgSnippet, envCfgNameChooserSnippet, envCfgValueSnippet, true); - Path pathToServerEnv = Paths.get(projectsPath, projectName, ItConstants.CONFIG_DIR_PATH, ItConstants.SERVER_ENV); + Path pathToServerEnv = Paths.get(projectsPath, projectName, String.join(File.separator, ItConstants.CONFIG_DIR_PATH), ItConstants.SERVER_ENV); TestUtils.validateStringInFile(pathToServerEnv.toString(), expectedServerEnvString); } finally { // Replace server.xml content with the original content @@ -273,7 +274,7 @@ public void testInsertLibertyConfigIntoBootstrapPropsForLowerCase() { try { UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, ItConstants.BOOTSTRAP_PROPERTIES, configNameSnippet, configNameChooserSnippet, configValueSnippet, true); - Path pathToBootstrapProps = Paths.get(projectsPath, projectName, ItConstants.CONFIG_DIR_PATH, ItConstants.BOOTSTRAP_PROPERTIES); + Path pathToBootstrapProps = Paths.get(projectsPath, projectName, String.join(File.separator, ItConstants.CONFIG_DIR_PATH), ItConstants.BOOTSTRAP_PROPERTIES); TestUtils.validateStringInFile(pathToBootstrapProps.toString(), expectedBootstrapPropsString); } finally { // Replace server.xml content with the original content @@ -406,7 +407,7 @@ public void testDiagnosticInServerXML() { String expectedHoverData = "cvc-datatype-valid.1.2.3: 'wrong' is not a valid value of union type 'booleanType'."; Path pathToServerXML = null; - pathToServerXML = Paths.get(projectsPath, projectName, ItConstants.CONFIG_DIR_PATH, ItConstants.SERVER_XML); + pathToServerXML = Paths.get(projectsPath, projectName, String.join(File.separator, ItConstants.CONFIG_DIR_PATH), ItConstants.SERVER_XML); // get focus on server.xml tab prior to copy UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVER_XML); @@ -442,7 +443,7 @@ public void testQuickFixInServerXML() { String expectedHoverData = "cvc-datatype-valid.1.2.3: 'wrong' is not a valid value of union type 'booleanType'."; Path pathToServerXML = null; - pathToServerXML = Paths.get(projectsPath, projectName, ItConstants.CONFIG_DIR_PATH, ItConstants.SERVER_XML); + pathToServerXML = Paths.get(projectsPath, projectName, String.join(File.separator, ItConstants.CONFIG_DIR_PATH), ItConstants.SERVER_XML); // get focus on server.xml tab prior to copy UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVER_XML); @@ -592,16 +593,16 @@ public static void prepareEnv(String projectPath, String projectName) { // get a JTreeFixture reference to the file project viewer entry ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2)); JTreeFixture projTree = projectFrame.getProjectViewJTree(projectName); - projTree.expand(projectName, ItConstants.CONFIG_DIR_PATH); + projTree.expand(projectName, String.join(File.separator, ItConstants.CONFIG_DIR_PATH)); // open server.xml file - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVER_XML, projectName, "src", "main", "liberty", "config"); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVER_XML, TestUtils.combinePath(projectName, ItConstants.CONFIG_DIR_PATH)); // open server.env file - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVER_ENV, projectName, "src", "main", "liberty", "config"); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVER_ENV, TestUtils.combinePath(projectName, ItConstants.CONFIG_DIR_PATH)); // open bootstrap.properties file - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.BOOTSTRAP_PROPERTIES, projectName, "src", "main", "liberty", "config"); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.BOOTSTRAP_PROPERTIES, TestUtils.combinePath(projectName, ItConstants.CONFIG_DIR_PATH)); // Removes the build tool window if it is opened. This prevents text to be hidden by it. UIBotTestUtils.removeToolWindow(remoteRobot, "Build:"); diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java index af91eed66..8ea1475b2 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java @@ -19,6 +19,8 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.time.Duration; +import java.util.Arrays; +import java.util.stream.Collectors; import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitForIgnoringError; @@ -97,7 +99,8 @@ public void testInsertCodeSnippetIntoJavaPart() { // Insert a code snippet into java part try { UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA, snippetStr, snippetChooser); - Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.HEALTH_DIR_PATH, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); + String healthDirPath = Arrays.stream(ItConstants.HEALTH_DIR_PATH).map(s -> s.replace(".", "/")).collect(Collectors.joining("/")); + Path pathToSrc = Paths.get(projectsPath, projectName, healthDirPath, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); TestUtils.validateCodeInJavaSrc(pathToSrc.toString(), insertedCode); } finally { // Replace modified content with the original content @@ -124,7 +127,8 @@ public void testMPDiagnosticsInJavaPart() { // Delete the liveness annotation UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA, livenessString); - Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.HEALTH_DIR_PATH, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); + String healthDirPath = Arrays.stream(ItConstants.HEALTH_DIR_PATH).map(s -> s.replace(".", "/")).collect(Collectors.joining("/")); + Path pathToSrc = Paths.get(projectsPath, projectName, healthDirPath, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); try { // validate @Liveness no longer found in java part @@ -170,7 +174,8 @@ public void testMPQuickFixInJavaFile() { // Delete the liveness annotation UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot,ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA, livenessString); - Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.HEALTH_DIR_PATH, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); + String healthDirPath = Arrays.stream(ItConstants.HEALTH_DIR_PATH).map(s -> s.replace(".", "/")).collect(Collectors.joining("/")); + Path pathToSrc = Paths.get(projectsPath, projectName, healthDirPath, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); try { // validate @Liveness no longer found in java part @@ -209,7 +214,8 @@ public void testInsertMicroProfileProperty() { try { UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, ItConstants.MPG_PROPERTIES, cfgSnippet, cfgNameChooserSnippet, cfgValueSnippet, true); - Path pathToMpCfgProperties = Paths.get(projectsPath, projectName, ItConstants.META_INF_DIR_PATH, ItConstants.MPG_PROPERTIES); + String metaInfDirPath = Arrays.stream(ItConstants.META_INF_DIR_PATH).map(s -> s.replace(".", "/")).collect(Collectors.joining("/")); + Path pathToMpCfgProperties = Paths.get(projectsPath, projectName, metaInfDirPath, ItConstants.MPG_PROPERTIES); TestUtils.validateStringInFile(pathToMpCfgProperties.toString(), expectedMpCfgPropertiesString); } finally { // Replace modified microprofile-config.properties with the original content @@ -295,7 +301,8 @@ public void testQuickFixInMicroProfileConfigProperties() { String correctedValue = "mp.health.disable-default-procedures=true"; String expectedHoverData = "Type mismatch: boolean expected. By default, this value will be interpreted as 'false'"; - Path pathToMpCfgProperties = Paths.get(projectsPath, projectName,ItConstants.META_INF_DIR_PATH, ItConstants.MPG_PROPERTIES); + String metaInfDirPath = Arrays.stream(ItConstants.META_INF_DIR_PATH).map(s -> s.replace(".", "/")).collect(Collectors.joining("/")); + Path pathToMpCfgProperties = Paths.get(projectsPath, projectName, metaInfDirPath, ItConstants.MPG_PROPERTIES); // get focus on file tab prior to copy UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.MPG_PROPERTIES); @@ -344,8 +351,8 @@ public static void prepareEnv(String projectPath, String projectName) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2)); JTreeFixture projTree = projectFrame.getProjectViewJTree(projectName); - UIBotTestUtils.openFile(remoteRobot, projectName, "ServiceLiveHealthCheck", projectName, "src", "main", "java", "io.openliberty.mp.sample", "health"); - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.MPG_PROPERTIES, projectName, "src", "main", "resources", "META-INF"); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVICE_LIVEHEALTH_CHECK, TestUtils.combinePath(projectName, ItConstants.HEALTH_DIR_PATH)); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.MPG_PROPERTIES, TestUtils.combinePath(projectName, ItConstants.META_INF_DIR_PATH)); // Removes the build tool window if it is opened. This prevents text to be hidden by it. UIBotTestUtils.removeToolWindow(remoteRobot, "Build:"); diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java index 970423362..da2daea63 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java @@ -14,6 +14,7 @@ import io.openliberty.tools.intellij.it.Utils.ItConstants; import org.junit.jupiter.api.*; +import java.io.File; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -196,7 +197,7 @@ public void testsRefreshProjectWithServerXmlOnly() { // Copy a valid server.xml file to this project's src/main/liberty/config directory. Path validServerXml = Paths.get(getHelperFilesDirPath(), ItConstants.SERVER_XML); - Path destination = Paths.get(getProjectsDirPath(), getSmNLTRestProjectName(), ItConstants.CONFIG_DIR_PATH, ItConstants.SERVER_XML); + Path destination = Paths.get(getProjectsDirPath(), getSmNLTRestProjectName(), String.join(File.separator, ItConstants.CONFIG_DIR_PATH), ItConstants.SERVER_XML); try { Files.copy(validServerXml, destination, StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING); diff --git a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java index 23aaed82f..3653561b9 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java @@ -18,7 +18,9 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Arrays; import java.util.List; +import java.util.stream.Stream; /** * Test utilities. @@ -28,7 +30,7 @@ public class TestUtils { /** * WLP messages.log path. */ - public static final Path WLP_MSGLOG_PATH = Paths.get(ItConstants.MESSAGES_LOG_PATH, "messages.log"); + public static final Path WLP_MSGLOG_PATH = Paths.get(String.join(File.separator, ItConstants.MESSAGES_LOG_PATH), "messages.log"); /** * Liberty server stopped message: @@ -542,7 +544,7 @@ public static boolean isServerStopNeeded(String wlpInstallPath) { */ public static void checkDebugPort(String absoluteWLPPath, int debugPort) throws IOException { // Retrieve the WLP server.env file path - Path serverEnvPath = Paths.get(absoluteWLPPath, ItConstants.DEFAULT_SERVER_PATH, ItConstants.SERVER_ENV); + Path serverEnvPath = Paths.get(absoluteWLPPath, String.join(File.separator, ItConstants.DEFAULT_SERVER_PATH), ItConstants.SERVER_ENV); // Read all lines from server.env List lines = Files.readAllLines(serverEnvPath); // Check if Debug Port is set to the specified port @@ -599,4 +601,9 @@ public static void detectFatalError() { throw new RuntimeException(e); } } + + public static String[] combinePath(String projectName, String[] pathArray) { + return Stream.concat(Stream.of(projectName), Arrays.stream(pathArray)) + .toArray(String[]::new); + } } diff --git a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java index 5662ca5fc..8f41d76c2 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java +++ b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java @@ -18,13 +18,16 @@ public class ItConstants { public static final String SYSTEM_RESOURCE_2_JAVA = "SystemResource2.java"; public static final String SYSTEM_RESOURCE = "SystemResource"; public static final String SYSTEM_RESOURCE_2 = "SystemResource2"; + public static final String SERVICE_LIVEHEALTH_CHECK = "ServiceLiveHealthCheck"; + + public static final String[] CONFIG_DIR_PATH = { "src", "main", "liberty", "config" }; + public static final String[] SYSTEM_DIR_PATH = { "src", "main", "java", "io.openliberty.mp.sample", "system"}; + public static final String[] HEALTH_DIR_PATH = { "src", "main", "java", "io.openliberty.mp.sample", "health" }; + public static final String[] META_INF_DIR_PATH = { "src", "main", "resources", "META-INF" }; + public static final String[] DEFAULT_SERVER_PATH = { "wlp", "usr", "servers", "defaultServer" }; + public static final String[] MESSAGES_LOG_PATH = { "wlp", "usr", "servers", "defaultServer", "logs" }; + - public static final String CONFIG_DIR_PATH = "src/main/liberty/config"; - public static final String SYSTEM_DIR_PATH = "src/main/java/io/openliberty/mp/sample/system"; - public static final String HEALTH_DIR_PATH = "src/main/java/io/openliberty/mp/sample/health"; - public static final String META_INF_DIR_PATH = "src/main/resources/META-INF"; - public static final String DEFAULT_SERVER_PATH = "wlp/usr/servers/defaultServer"; - public static final String MESSAGES_LOG_PATH = "wlp/usr/servers/defaultServer/logs"; public static final String SERVER_XML = "server.xml"; public static final String SERVER_ENV = "server.env"; public static final String BOOTSTRAP_PROPERTIES = "bootstrap.properties"; From 64b7a81e6ea9110735b0e884df068ee9d35619c3 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Fri, 17 Jan 2025 15:53:13 +0530 Subject: [PATCH 22/28] Update Constants.java --- src/main/java/io/openliberty/tools/intellij/util/Constants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/openliberty/tools/intellij/util/Constants.java b/src/main/java/io/openliberty/tools/intellij/util/Constants.java index 6ad35a05c..275899b57 100644 --- a/src/main/java/io/openliberty/tools/intellij/util/Constants.java +++ b/src/main/java/io/openliberty/tools/intellij/util/Constants.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2025 IBM Corporation. + * Copyright (c) 2020, 2024 IBM Corporation. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at From f1d400d857504e30f357085e181a39088a4ab4b4 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Fri, 17 Jan 2025 16:08:52 +0530 Subject: [PATCH 23/28] Update SingleModMPLSTestCommon.java --- .../tools/intellij/it/SingleModMPLSTestCommon.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java index 8ea1475b2..1d0598281 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java @@ -16,6 +16,7 @@ import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture; import org.junit.jupiter.api.*; +import java.io.File; import java.nio.file.Path; import java.nio.file.Paths; import java.time.Duration; @@ -214,8 +215,7 @@ public void testInsertMicroProfileProperty() { try { UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, ItConstants.MPG_PROPERTIES, cfgSnippet, cfgNameChooserSnippet, cfgValueSnippet, true); - String metaInfDirPath = Arrays.stream(ItConstants.META_INF_DIR_PATH).map(s -> s.replace(".", "/")).collect(Collectors.joining("/")); - Path pathToMpCfgProperties = Paths.get(projectsPath, projectName, metaInfDirPath, ItConstants.MPG_PROPERTIES); + Path pathToMpCfgProperties = Paths.get(projectsPath, projectName, String.join(File.separator, ItConstants.META_INF_DIR_PATH), ItConstants.MPG_PROPERTIES); TestUtils.validateStringInFile(pathToMpCfgProperties.toString(), expectedMpCfgPropertiesString); } finally { // Replace modified microprofile-config.properties with the original content @@ -301,8 +301,7 @@ public void testQuickFixInMicroProfileConfigProperties() { String correctedValue = "mp.health.disable-default-procedures=true"; String expectedHoverData = "Type mismatch: boolean expected. By default, this value will be interpreted as 'false'"; - String metaInfDirPath = Arrays.stream(ItConstants.META_INF_DIR_PATH).map(s -> s.replace(".", "/")).collect(Collectors.joining("/")); - Path pathToMpCfgProperties = Paths.get(projectsPath, projectName, metaInfDirPath, ItConstants.MPG_PROPERTIES); + Path pathToMpCfgProperties = Paths.get(projectsPath, projectName, String.join(File.separator, ItConstants.META_INF_DIR_PATH), ItConstants.MPG_PROPERTIES); // get focus on file tab prior to copy UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.MPG_PROPERTIES); From 31ca81d24e0fa459a7e88450577482aaa6407b45 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Wed, 22 Jan 2025 12:41:59 +0530 Subject: [PATCH 24/28] addressed review comments --- .../it/SingleModJakartaLSTestCommon.java | 20 ++++++---------- .../it/SingleModLibertyLSTestCommon.java | 23 ++++++++++--------- .../intellij/it/SingleModMPLSTestCommon.java | 13 ++++------- .../it/SingleModNLTRestProjectTestCommon.java | 3 +-- .../tools/intellij/it/TestUtils.java | 14 ++++------- .../tools/intellij/it/Utils/ItConstants.java | 13 +++++++---- 6 files changed, 37 insertions(+), 49 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java index a683914b2..75bc27ade 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java @@ -16,13 +16,9 @@ import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture; import org.junit.jupiter.api.*; -import java.io.File; import java.nio.file.Path; import java.nio.file.Paths; import java.time.Duration; -import java.util.Arrays; -import java.util.stream.Collectors; -import java.util.stream.Stream; import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitForIgnoringError; @@ -96,8 +92,7 @@ public void testInsertJakartaCodeSnippetIntoJavaPart() { // Insert a code snippet into java part try { UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, ItConstants.SYSTEM_RESOURCE_JAVA, snippetStr, snippetChooser); - String systemDirPath = Arrays.stream(ItConstants.SYSTEM_DIR_PATH).map(s -> s.replace(".", "/")).collect(Collectors.joining("/")); - Path pathToSrc = Paths.get(projectsPath, projectName, systemDirPath, ItConstants.SYSTEM_RESOURCE_JAVA); + Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.SYSTEM_DIR_PATH, ItConstants.SYSTEM_RESOURCE_JAVA); TestUtils.validateCodeInJavaSrc(pathToSrc.toString(), insertedCode); } finally { @@ -115,8 +110,7 @@ public void testJakartaDiagnosticsInJavaPart() { String privateString = "private Response getProperties() {"; String flaggedString = "getProperties"; String expectedHoverData = "Only public methods can be exposed as resource methods"; - String systemDirPath = Arrays.stream(ItConstants.SYSTEM_DIR_PATH).map(s -> s.replace(".", "/")).collect(Collectors.joining("/")); - Path pathToSrc = Paths.get(projectsPath, projectName, systemDirPath, ItConstants.SYSTEM_RESOURCE_2_JAVA); + Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.SYSTEM_DIR_PATH, ItConstants.SYSTEM_RESOURCE_2_JAVA); // get focus on file tab prior to copy UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA); @@ -151,8 +145,7 @@ public void testJakartaQuickFixInJavaPart() { String privateString = "private Response getProperties() {"; String flaggedString = "getProperties"; - String systemDirPath = Arrays.stream(ItConstants.SYSTEM_DIR_PATH).map(s -> s.replace(".", "/")).collect(Collectors.joining("/")); - Path pathToSrc = Paths.get(projectsPath, projectName, systemDirPath, ItConstants.SYSTEM_RESOURCE_2_JAVA); + Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.SYSTEM_DIR_PATH, ItConstants.SYSTEM_RESOURCE_2_JAVA); String quickfixChooserString = "Make method public"; // get focus on file tab prior to copy @@ -206,10 +199,11 @@ public static void prepareEnv(String projectPath, String projectName) { // expand project directories that are specific to this test app being used by these testcases // must be expanded here before trying to open specific files - projTree.expand(projectName, String.join(File.separator, ItConstants.SYSTEM_DIR_PATH)); + projTree.expand(projectName, ItConstants.SYSTEM_DIR_PATH); - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE, TestUtils.combinePath(projectName, ItConstants.SYSTEM_DIR_PATH)); - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE_2, TestUtils.combinePath(projectName, ItConstants.SYSTEM_DIR_PATH)); + String[] systemDirPath = TestUtils.combinePath(projectName, ItConstants.SYSTEM_DIR_PATH_ARR); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE, systemDirPath); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE_2, systemDirPath); // Removes the build tool window if it is opened. This prevents text to be hidden by it. UIBotTestUtils.removeToolWindow(remoteRobot, "Build:"); diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java index 23f468c18..ccbd15e41 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -17,7 +17,6 @@ import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture; import org.junit.jupiter.api.*; -import java.io.File; import java.nio.file.Path; import java.nio.file.Paths; import java.time.Duration; @@ -132,7 +131,7 @@ public void testInsertFeatureIntoServerXML() { // Insert a new element in server.xml. try { UIBotTestUtils.insertStanzaInAppServerXML(remoteRobot, stanzaSnippet, 18, 40, UIBotTestUtils.InsertionType.FEATURE, true); - Path pathToServerXML = Paths.get(projectsPath, projectName, String.join(File.separator, ItConstants.CONFIG_DIR_PATH), ItConstants.SERVER_XML); + Path pathToServerXML = Paths.get(projectsPath, projectName, ItConstants.CONFIG_DIR_PATH, ItConstants.SERVER_XML); TestUtils.validateStanzaInConfigFile(pathToServerXML.toString(), insertedFeature); } finally { // Replace server.xml content with the original content @@ -160,7 +159,7 @@ public void testInsertLibertyConfigElementIntoServerXML() { try { UIBotTestUtils.insertStanzaInAppServerXML(remoteRobot, stanzaSnippet, 20, 0, UIBotTestUtils.InsertionType.ELEMENT, true); TestUtils.sleepAndIgnoreException(2); // wait for editor to update - Path pathToServerXML = Paths.get(projectsPath, projectName, String.join(File.separator, ItConstants.CONFIG_DIR_PATH), ItConstants.SERVER_XML); + Path pathToServerXML = Paths.get(projectsPath, projectName, ItConstants.CONFIG_DIR_PATH, ItConstants.SERVER_XML); TestUtils.validateStanzaInConfigFile(pathToServerXML.toString(), insertedConfig); } finally { // Replace server.xml content with the original content @@ -189,7 +188,7 @@ public void testInsertLibertyConfigIntoServerEnvForCapitalCase() { try { UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, ItConstants.SERVER_ENV, envCfgSnippet, envCfgNameChooserSnippet, envCfgValueSnippet, true); - Path pathToServerEnv = Paths.get(projectsPath, projectName, String.join(File.separator, ItConstants.CONFIG_DIR_PATH), ItConstants.SERVER_ENV); + Path pathToServerEnv = Paths.get(projectsPath, projectName, ItConstants.CONFIG_DIR_PATH, ItConstants.SERVER_ENV); TestUtils.validateStringInFile(pathToServerEnv.toString(), expectedServerEnvString); } finally { // Replace server.xml content with the original content @@ -274,7 +273,7 @@ public void testInsertLibertyConfigIntoBootstrapPropsForLowerCase() { try { UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, ItConstants.BOOTSTRAP_PROPERTIES, configNameSnippet, configNameChooserSnippet, configValueSnippet, true); - Path pathToBootstrapProps = Paths.get(projectsPath, projectName, String.join(File.separator, ItConstants.CONFIG_DIR_PATH), ItConstants.BOOTSTRAP_PROPERTIES); + Path pathToBootstrapProps = Paths.get(projectsPath, projectName, ItConstants.CONFIG_DIR_PATH, ItConstants.BOOTSTRAP_PROPERTIES); TestUtils.validateStringInFile(pathToBootstrapProps.toString(), expectedBootstrapPropsString); } finally { // Replace server.xml content with the original content @@ -407,7 +406,7 @@ public void testDiagnosticInServerXML() { String expectedHoverData = "cvc-datatype-valid.1.2.3: 'wrong' is not a valid value of union type 'booleanType'."; Path pathToServerXML = null; - pathToServerXML = Paths.get(projectsPath, projectName, String.join(File.separator, ItConstants.CONFIG_DIR_PATH), ItConstants.SERVER_XML); + pathToServerXML = Paths.get(projectsPath, projectName, ItConstants.CONFIG_DIR_PATH, ItConstants.SERVER_XML); // get focus on server.xml tab prior to copy UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVER_XML); @@ -443,7 +442,7 @@ public void testQuickFixInServerXML() { String expectedHoverData = "cvc-datatype-valid.1.2.3: 'wrong' is not a valid value of union type 'booleanType'."; Path pathToServerXML = null; - pathToServerXML = Paths.get(projectsPath, projectName, String.join(File.separator, ItConstants.CONFIG_DIR_PATH), ItConstants.SERVER_XML); + pathToServerXML = Paths.get(projectsPath, projectName, ItConstants.CONFIG_DIR_PATH, ItConstants.SERVER_XML); // get focus on server.xml tab prior to copy UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVER_XML); @@ -593,16 +592,18 @@ public static void prepareEnv(String projectPath, String projectName) { // get a JTreeFixture reference to the file project viewer entry ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2)); JTreeFixture projTree = projectFrame.getProjectViewJTree(projectName); - projTree.expand(projectName, String.join(File.separator, ItConstants.CONFIG_DIR_PATH)); + projTree.expand(projectName, ItConstants.CONFIG_DIR_PATH); + + String[] configDirPath = TestUtils.combinePath(projectName, ItConstants.CONFIG_DIR_PATH_ARR); // open server.xml file - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVER_XML, TestUtils.combinePath(projectName, ItConstants.CONFIG_DIR_PATH)); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVER_XML, configDirPath); // open server.env file - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVER_ENV, TestUtils.combinePath(projectName, ItConstants.CONFIG_DIR_PATH)); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVER_ENV, configDirPath); // open bootstrap.properties file - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.BOOTSTRAP_PROPERTIES, TestUtils.combinePath(projectName, ItConstants.CONFIG_DIR_PATH)); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.BOOTSTRAP_PROPERTIES, configDirPath); // Removes the build tool window if it is opened. This prevents text to be hidden by it. UIBotTestUtils.removeToolWindow(remoteRobot, "Build:"); diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java index 1d0598281..aa94a2e2b 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java @@ -20,8 +20,6 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.time.Duration; -import java.util.Arrays; -import java.util.stream.Collectors; import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitForIgnoringError; @@ -100,8 +98,7 @@ public void testInsertCodeSnippetIntoJavaPart() { // Insert a code snippet into java part try { UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA, snippetStr, snippetChooser); - String healthDirPath = Arrays.stream(ItConstants.HEALTH_DIR_PATH).map(s -> s.replace(".", "/")).collect(Collectors.joining("/")); - Path pathToSrc = Paths.get(projectsPath, projectName, healthDirPath, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); + Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.HEALTH_DIR_PATH, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); TestUtils.validateCodeInJavaSrc(pathToSrc.toString(), insertedCode); } finally { // Replace modified content with the original content @@ -128,8 +125,7 @@ public void testMPDiagnosticsInJavaPart() { // Delete the liveness annotation UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA, livenessString); - String healthDirPath = Arrays.stream(ItConstants.HEALTH_DIR_PATH).map(s -> s.replace(".", "/")).collect(Collectors.joining("/")); - Path pathToSrc = Paths.get(projectsPath, projectName, healthDirPath, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); + Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.HEALTH_DIR_PATH, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); try { // validate @Liveness no longer found in java part @@ -175,8 +171,7 @@ public void testMPQuickFixInJavaFile() { // Delete the liveness annotation UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot,ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA, livenessString); - String healthDirPath = Arrays.stream(ItConstants.HEALTH_DIR_PATH).map(s -> s.replace(".", "/")).collect(Collectors.joining("/")); - Path pathToSrc = Paths.get(projectsPath, projectName, healthDirPath, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); + Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.HEALTH_DIR_PATH, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); try { // validate @Liveness no longer found in java part @@ -350,7 +345,7 @@ public static void prepareEnv(String projectPath, String projectName) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2)); JTreeFixture projTree = projectFrame.getProjectViewJTree(projectName); - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVICE_LIVEHEALTH_CHECK, TestUtils.combinePath(projectName, ItConstants.HEALTH_DIR_PATH)); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVICE_LIVEHEALTH_CHECK, TestUtils.combinePath(projectName, ItConstants.HEALTH_DIR_PATH_ARR)); UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.MPG_PROPERTIES, TestUtils.combinePath(projectName, ItConstants.META_INF_DIR_PATH)); // Removes the build tool window if it is opened. This prevents text to be hidden by it. diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java index da2daea63..970423362 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java @@ -14,7 +14,6 @@ import io.openliberty.tools.intellij.it.Utils.ItConstants; import org.junit.jupiter.api.*; -import java.io.File; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -197,7 +196,7 @@ public void testsRefreshProjectWithServerXmlOnly() { // Copy a valid server.xml file to this project's src/main/liberty/config directory. Path validServerXml = Paths.get(getHelperFilesDirPath(), ItConstants.SERVER_XML); - Path destination = Paths.get(getProjectsDirPath(), getSmNLTRestProjectName(), String.join(File.separator, ItConstants.CONFIG_DIR_PATH), ItConstants.SERVER_XML); + Path destination = Paths.get(getProjectsDirPath(), getSmNLTRestProjectName(), ItConstants.CONFIG_DIR_PATH, ItConstants.SERVER_XML); try { Files.copy(validServerXml, destination, StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING); diff --git a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java index 3653561b9..cad40dd27 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java @@ -27,10 +27,6 @@ */ public class TestUtils { - /** - * WLP messages.log path. - */ - public static final Path WLP_MSGLOG_PATH = Paths.get(String.join(File.separator, ItConstants.MESSAGES_LOG_PATH), "messages.log"); /** * Liberty server stopped message: @@ -63,7 +59,7 @@ public static void validateLibertyServerStopped(String testName, String wlpInsta public static void validateLibertyServerStopped(String testName, String wlpInstallPath, int maxAttempts, boolean failOnNoStop) { printTrace(TraceSevLevel.INFO, testName + ":validateLibertyServerStopped: Entry."); - String wlpMsgLogPath = Paths.get(wlpInstallPath, WLP_MSGLOG_PATH.toString()).toString(); + String wlpMsgLogPath = Paths.get(wlpInstallPath, ItConstants.MESSAGES_LOG_PATH).toString(); int retryIntervalSecs = 5; boolean foundStoppedMsg = false; Exception error = null; @@ -171,7 +167,7 @@ public static void validateProjectStarted(String testName, String resourceURI, i // If we are here, the expected outcome was not found. Print the Liberty server's messages.log and fail. String msg = testName + ":validateProjectStarted: Timed out while waiting for project with resource URI " + resourceURI + "and port " + port + " to become available."; printTrace(TraceSevLevel.ERROR, msg); - String wlpMsgLogPath = Paths.get(wlpInstallPath, WLP_MSGLOG_PATH.toString()).toString(); + String wlpMsgLogPath = Paths.get(wlpInstallPath, ItConstants.MESSAGES_LOG_PATH).toString(); String msgHeader = "Message log for failed test: " + testName + ":validateProjectStarted"; printLibertyMessagesLogFile(msgHeader, wlpMsgLogPath); Assertions.fail(msg); @@ -277,7 +273,7 @@ public static void validateProjectStopped(String testName, String projUrl, Strin // If we are here, the expected outcome was not found. Print the Liberty server's messages.log and fail. String msg = testName + ":validateProjectStopped: Timed out while waiting for project under URL: " + projUrl + " to stop."; printTrace(TraceSevLevel.ERROR, msg); - String wlpMsgLogPath = Paths.get(wlpInstallPath, WLP_MSGLOG_PATH.toString()).toString(); + String wlpMsgLogPath = Paths.get(wlpInstallPath, ItConstants.MESSAGES_LOG_PATH).toString(); String msgHeader = "Message log for failed test: " + testName + ":validateProjectStopped"; printLibertyMessagesLogFile(msgHeader, wlpMsgLogPath); Assertions.fail(msg); @@ -519,7 +515,7 @@ public static void sleepAndIgnoreException(int seconds) { */ public static boolean isServerStopNeeded(String wlpInstallPath) { boolean stopServer = false; - Path msgLogPath = Paths.get(wlpInstallPath, WLP_MSGLOG_PATH.toString()); + Path msgLogPath = Paths.get(wlpInstallPath, ItConstants.MESSAGES_LOG_PATH); if (fileExists(msgLogPath)) { try { // The file maybe an old log. For now, check for the message indicating @@ -544,7 +540,7 @@ public static boolean isServerStopNeeded(String wlpInstallPath) { */ public static void checkDebugPort(String absoluteWLPPath, int debugPort) throws IOException { // Retrieve the WLP server.env file path - Path serverEnvPath = Paths.get(absoluteWLPPath, String.join(File.separator, ItConstants.DEFAULT_SERVER_PATH), ItConstants.SERVER_ENV); + Path serverEnvPath = Paths.get(absoluteWLPPath, ItConstants.DEFAULT_SERVER_PATH, ItConstants.SERVER_ENV); // Read all lines from server.env List lines = Files.readAllLines(serverEnvPath); // Check if Debug Port is set to the specified port diff --git a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java index 8f41d76c2..e3eac5f78 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java +++ b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java @@ -20,12 +20,15 @@ public class ItConstants { public static final String SYSTEM_RESOURCE_2 = "SystemResource2"; public static final String SERVICE_LIVEHEALTH_CHECK = "ServiceLiveHealthCheck"; - public static final String[] CONFIG_DIR_PATH = { "src", "main", "liberty", "config" }; - public static final String[] SYSTEM_DIR_PATH = { "src", "main", "java", "io.openliberty.mp.sample", "system"}; - public static final String[] HEALTH_DIR_PATH = { "src", "main", "java", "io.openliberty.mp.sample", "health" }; + public static final String CONFIG_DIR_PATH = "src/main/liberty/config"; + public static final String[] CONFIG_DIR_PATH_ARR = { "src", "main", "liberty", "config" }; + public static final String SYSTEM_DIR_PATH = "src/main/java/io/openliberty/mp/sample/system"; + public static final String[] SYSTEM_DIR_PATH_ARR = { "src", "main", "java", "io.openliberty.mp.sample", "system"}; + public static final String HEALTH_DIR_PATH = "src/main/java/io/openliberty/mp/sample/system"; + public static final String[] HEALTH_DIR_PATH_ARR = { "src", "main", "java", "io.openliberty.mp.sample", "health" }; public static final String[] META_INF_DIR_PATH = { "src", "main", "resources", "META-INF" }; - public static final String[] DEFAULT_SERVER_PATH = { "wlp", "usr", "servers", "defaultServer" }; - public static final String[] MESSAGES_LOG_PATH = { "wlp", "usr", "servers", "defaultServer", "logs" }; + public static final String DEFAULT_SERVER_PATH = "wlp/usr/servers/defaultServer"; + public static final String MESSAGES_LOG_PATH = "wlp/usr/servers/defaultServer/logs/messages.log"; public static final String SERVER_XML = "server.xml"; From 3f1b7b3f36692b794f5760192055f520f580a7cb Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Thu, 23 Jan 2025 12:04:51 +0530 Subject: [PATCH 25/28] Updates - MPG_PROPERTIES changed to MPCFG_PROPERTIES - concatenate the Strings for wlpMsgLogPath --- .../intellij/it/SingleModMPLSTestCommon.java | 26 +++++++++---------- .../tools/intellij/it/TestUtils.java | 6 ++--- .../tools/intellij/it/Utils/ItConstants.java | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java index aa94a2e2b..73942e752 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java @@ -67,7 +67,7 @@ public static void cleanup() { projectFrame.findText("resources").doubleClick(); UIBotTestUtils.closeFileEditorTab(remoteRobot, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA, "5"); - UIBotTestUtils.closeFileEditorTab(remoteRobot, ItConstants.MPG_PROPERTIES, "5"); + UIBotTestUtils.closeFileEditorTab(remoteRobot, ItConstants.MPCFG_PROPERTIES, "5"); if (!remoteRobot.isMac()) { UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, ItConstants.COMPACT_MODE, 3); } @@ -203,14 +203,14 @@ public void testInsertMicroProfileProperty() { String expectedMpCfgPropertiesString = "mp.health.disable-default-procedures=true"; // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.MPG_PROPERTIES); + UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.MPCFG_PROPERTIES); // Save the current microprofile-config.properties content. UIBotTestUtils.copyWindowContent(remoteRobot); try { - UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, ItConstants.MPG_PROPERTIES, cfgSnippet, cfgNameChooserSnippet, cfgValueSnippet, true); - Path pathToMpCfgProperties = Paths.get(projectsPath, projectName, String.join(File.separator, ItConstants.META_INF_DIR_PATH), ItConstants.MPG_PROPERTIES); + UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, ItConstants.MPCFG_PROPERTIES, cfgSnippet, cfgNameChooserSnippet, cfgValueSnippet, true); + Path pathToMpCfgProperties = Paths.get(projectsPath, projectName, String.join(File.separator, ItConstants.META_INF_DIR_PATH), ItConstants.MPCFG_PROPERTIES); TestUtils.validateStringInFile(pathToMpCfgProperties.toString(), expectedMpCfgPropertiesString); } finally { // Replace modified microprofile-config.properties with the original content @@ -233,7 +233,7 @@ public void testMicroProfileConfigHover() { "java.lang.StringValue: http://localhost:9081/data/client/service"; //mover cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, ItConstants.MPG_PROPERTIES, UIBotTestUtils.PopupType.DOCUMENTATION); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, ItConstants.MPCFG_PROPERTIES, UIBotTestUtils.PopupType.DOCUMENTATION); String hoverFoundOutcome = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DOCUMENTATION); // if the LS has not yet poulated the popup, re-get the popup data @@ -263,16 +263,16 @@ public void testDiagnosticInMicroProfileConfigProperties() { String expectedHoverData = "Type mismatch: boolean expected. By default, this value will be interpreted as 'false'"; // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.MPG_PROPERTIES); + UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.MPCFG_PROPERTIES); // Save the current content. UIBotTestUtils.copyWindowContent(remoteRobot); try { - UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, ItConstants.MPG_PROPERTIES, MPCfgSnippet, MPCfgNameChooserSnippet, incorrectValue, false); + UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, ItConstants.MPCFG_PROPERTIES, MPCfgSnippet, MPCfgNameChooserSnippet, incorrectValue, false); //move cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, incorrectValue, ItConstants.MPG_PROPERTIES, UIBotTestUtils.PopupType.DIAGNOSTIC); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, incorrectValue, ItConstants.MPCFG_PROPERTIES, UIBotTestUtils.PopupType.DIAGNOSTIC); String foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC); TestUtils.validateHoverData(expectedHoverData, foundHoverData); } finally { @@ -296,19 +296,19 @@ public void testQuickFixInMicroProfileConfigProperties() { String correctedValue = "mp.health.disable-default-procedures=true"; String expectedHoverData = "Type mismatch: boolean expected. By default, this value will be interpreted as 'false'"; - Path pathToMpCfgProperties = Paths.get(projectsPath, projectName, String.join(File.separator, ItConstants.META_INF_DIR_PATH), ItConstants.MPG_PROPERTIES); + Path pathToMpCfgProperties = Paths.get(projectsPath, projectName, String.join(File.separator, ItConstants.META_INF_DIR_PATH), ItConstants.MPCFG_PROPERTIES); // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.MPG_PROPERTIES); + UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.MPCFG_PROPERTIES); // Save the current content. UIBotTestUtils.copyWindowContent(remoteRobot); try { - UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, ItConstants.MPG_PROPERTIES, MPCfgSnippet, MPCfgNameChooserSnippet, incorrectValue, false); + UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, ItConstants.MPCFG_PROPERTIES, MPCfgSnippet, MPCfgNameChooserSnippet, incorrectValue, false); //move cursor to hover point - UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, incorrectValue, ItConstants.MPG_PROPERTIES, quickfixChooserString); + UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, incorrectValue, ItConstants.MPCFG_PROPERTIES, quickfixChooserString); UIBotTestUtils.chooseQuickFix(remoteRobot, quickfixChooserString); TestUtils.validateStanzaInConfigFile(pathToMpCfgProperties.toString(), correctedValue); @@ -346,7 +346,7 @@ public static void prepareEnv(String projectPath, String projectName) { JTreeFixture projTree = projectFrame.getProjectViewJTree(projectName); UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVICE_LIVEHEALTH_CHECK, TestUtils.combinePath(projectName, ItConstants.HEALTH_DIR_PATH_ARR)); - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.MPG_PROPERTIES, TestUtils.combinePath(projectName, ItConstants.META_INF_DIR_PATH)); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.MPCFG_PROPERTIES, TestUtils.combinePath(projectName, ItConstants.META_INF_DIR_PATH)); // Removes the build tool window if it is opened. This prevents text to be hidden by it. UIBotTestUtils.removeToolWindow(remoteRobot, "Build:"); diff --git a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java index cad40dd27..8e61e08f4 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java @@ -59,7 +59,7 @@ public static void validateLibertyServerStopped(String testName, String wlpInsta public static void validateLibertyServerStopped(String testName, String wlpInstallPath, int maxAttempts, boolean failOnNoStop) { printTrace(TraceSevLevel.INFO, testName + ":validateLibertyServerStopped: Entry."); - String wlpMsgLogPath = Paths.get(wlpInstallPath, ItConstants.MESSAGES_LOG_PATH).toString(); + String wlpMsgLogPath = wlpInstallPath + "/" + ItConstants.MESSAGES_LOG_PATH; int retryIntervalSecs = 5; boolean foundStoppedMsg = false; Exception error = null; @@ -167,7 +167,7 @@ public static void validateProjectStarted(String testName, String resourceURI, i // If we are here, the expected outcome was not found. Print the Liberty server's messages.log and fail. String msg = testName + ":validateProjectStarted: Timed out while waiting for project with resource URI " + resourceURI + "and port " + port + " to become available."; printTrace(TraceSevLevel.ERROR, msg); - String wlpMsgLogPath = Paths.get(wlpInstallPath, ItConstants.MESSAGES_LOG_PATH).toString(); + String wlpMsgLogPath = wlpInstallPath + "/" + ItConstants.MESSAGES_LOG_PATH; String msgHeader = "Message log for failed test: " + testName + ":validateProjectStarted"; printLibertyMessagesLogFile(msgHeader, wlpMsgLogPath); Assertions.fail(msg); @@ -273,7 +273,7 @@ public static void validateProjectStopped(String testName, String projUrl, Strin // If we are here, the expected outcome was not found. Print the Liberty server's messages.log and fail. String msg = testName + ":validateProjectStopped: Timed out while waiting for project under URL: " + projUrl + " to stop."; printTrace(TraceSevLevel.ERROR, msg); - String wlpMsgLogPath = Paths.get(wlpInstallPath, ItConstants.MESSAGES_LOG_PATH).toString(); + String wlpMsgLogPath = wlpInstallPath + "/" + ItConstants.MESSAGES_LOG_PATH; String msgHeader = "Message log for failed test: " + testName + ":validateProjectStopped"; printLibertyMessagesLogFile(msgHeader, wlpMsgLogPath); Assertions.fail(msg); diff --git a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java index e3eac5f78..d73fe26c1 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java +++ b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java @@ -37,7 +37,7 @@ public class ItConstants { public static final String COMPACT_MODE = "Compact Mode"; public static final String SERVICE_LIVE_HEALTH_CHECK_JAVA = "ServiceLiveHealthCheck.java"; - public static final String MPG_PROPERTIES = "microprofile-config.properties"; + public static final String MPCFG_PROPERTIES = "microprofile-config.properties"; public static final String CLOSE_ALL_TABS = "Close All Tabs"; } From 229e73e4961cd5231c52de834b59639694b8ddea Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Thu, 23 Jan 2025 17:57:52 +0530 Subject: [PATCH 26/28] Changed into String[] --- .../it/SingleModJakartaLSTestCommon.java | 10 ++++---- .../it/SingleModLibertyLSTestCommon.java | 16 ++++++------ .../intellij/it/SingleModMPLSTestCommon.java | 13 +++++----- .../it/SingleModNLTRestProjectTestCommon.java | 2 +- .../tools/intellij/it/TestUtils.java | 16 +++++++++--- .../tools/intellij/it/Utils/ItConstants.java | 25 +++++++++++-------- 6 files changed, 47 insertions(+), 35 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java index 75bc27ade..93c812ec8 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java @@ -92,7 +92,7 @@ public void testInsertJakartaCodeSnippetIntoJavaPart() { // Insert a code snippet into java part try { UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, ItConstants.SYSTEM_RESOURCE_JAVA, snippetStr, snippetChooser); - Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.SYSTEM_DIR_PATH, ItConstants.SYSTEM_RESOURCE_JAVA); + Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.SYSTEM_RESOURCE_PATH)); TestUtils.validateCodeInJavaSrc(pathToSrc.toString(), insertedCode); } finally { @@ -110,7 +110,7 @@ public void testJakartaDiagnosticsInJavaPart() { String privateString = "private Response getProperties() {"; String flaggedString = "getProperties"; String expectedHoverData = "Only public methods can be exposed as resource methods"; - Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.SYSTEM_DIR_PATH, ItConstants.SYSTEM_RESOURCE_2_JAVA); + Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.SYSTEM_RESOURCE_2_PATH)); // get focus on file tab prior to copy UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA); @@ -145,7 +145,7 @@ public void testJakartaQuickFixInJavaPart() { String privateString = "private Response getProperties() {"; String flaggedString = "getProperties"; - Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.SYSTEM_DIR_PATH, ItConstants.SYSTEM_RESOURCE_2_JAVA); + Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.SYSTEM_RESOURCE_2_PATH)); String quickfixChooserString = "Make method public"; // get focus on file tab prior to copy @@ -199,9 +199,9 @@ public static void prepareEnv(String projectPath, String projectName) { // expand project directories that are specific to this test app being used by these testcases // must be expanded here before trying to open specific files - projTree.expand(projectName, ItConstants.SYSTEM_DIR_PATH); + projTree.expand(TestUtils.combinePath(projectName, ItConstants.SYSTEM_DIR_PATH)); - String[] systemDirPath = TestUtils.combinePath(projectName, ItConstants.SYSTEM_DIR_PATH_ARR); + String[] systemDirPath = TestUtils.combinePath(projectName, ItConstants.SYSTEM_DIR_PATH); UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE, systemDirPath); UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE_2, systemDirPath); diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java index ccbd15e41..d64e7e810 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -131,7 +131,7 @@ public void testInsertFeatureIntoServerXML() { // Insert a new element in server.xml. try { UIBotTestUtils.insertStanzaInAppServerXML(remoteRobot, stanzaSnippet, 18, 40, UIBotTestUtils.InsertionType.FEATURE, true); - Path pathToServerXML = Paths.get(projectsPath, projectName, ItConstants.CONFIG_DIR_PATH, ItConstants.SERVER_XML); + Path pathToServerXML = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.SERVER_XML_PATH)); TestUtils.validateStanzaInConfigFile(pathToServerXML.toString(), insertedFeature); } finally { // Replace server.xml content with the original content @@ -159,7 +159,7 @@ public void testInsertLibertyConfigElementIntoServerXML() { try { UIBotTestUtils.insertStanzaInAppServerXML(remoteRobot, stanzaSnippet, 20, 0, UIBotTestUtils.InsertionType.ELEMENT, true); TestUtils.sleepAndIgnoreException(2); // wait for editor to update - Path pathToServerXML = Paths.get(projectsPath, projectName, ItConstants.CONFIG_DIR_PATH, ItConstants.SERVER_XML); + Path pathToServerXML = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.SERVER_XML_PATH)); TestUtils.validateStanzaInConfigFile(pathToServerXML.toString(), insertedConfig); } finally { // Replace server.xml content with the original content @@ -188,7 +188,7 @@ public void testInsertLibertyConfigIntoServerEnvForCapitalCase() { try { UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, ItConstants.SERVER_ENV, envCfgSnippet, envCfgNameChooserSnippet, envCfgValueSnippet, true); - Path pathToServerEnv = Paths.get(projectsPath, projectName, ItConstants.CONFIG_DIR_PATH, ItConstants.SERVER_ENV); + Path pathToServerEnv = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.SERVER_ENV_PATH)); TestUtils.validateStringInFile(pathToServerEnv.toString(), expectedServerEnvString); } finally { // Replace server.xml content with the original content @@ -273,7 +273,7 @@ public void testInsertLibertyConfigIntoBootstrapPropsForLowerCase() { try { UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, ItConstants.BOOTSTRAP_PROPERTIES, configNameSnippet, configNameChooserSnippet, configValueSnippet, true); - Path pathToBootstrapProps = Paths.get(projectsPath, projectName, ItConstants.CONFIG_DIR_PATH, ItConstants.BOOTSTRAP_PROPERTIES); + Path pathToBootstrapProps = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.BOOTSTRAP_PROPERTIES_PATH)); TestUtils.validateStringInFile(pathToBootstrapProps.toString(), expectedBootstrapPropsString); } finally { // Replace server.xml content with the original content @@ -406,7 +406,7 @@ public void testDiagnosticInServerXML() { String expectedHoverData = "cvc-datatype-valid.1.2.3: 'wrong' is not a valid value of union type 'booleanType'."; Path pathToServerXML = null; - pathToServerXML = Paths.get(projectsPath, projectName, ItConstants.CONFIG_DIR_PATH, ItConstants.SERVER_XML); + pathToServerXML = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.SERVER_XML_PATH)); // get focus on server.xml tab prior to copy UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVER_XML); @@ -442,7 +442,7 @@ public void testQuickFixInServerXML() { String expectedHoverData = "cvc-datatype-valid.1.2.3: 'wrong' is not a valid value of union type 'booleanType'."; Path pathToServerXML = null; - pathToServerXML = Paths.get(projectsPath, projectName, ItConstants.CONFIG_DIR_PATH, ItConstants.SERVER_XML); + pathToServerXML = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.SERVER_XML_PATH)); // get focus on server.xml tab prior to copy UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVER_XML); @@ -592,9 +592,9 @@ public static void prepareEnv(String projectPath, String projectName) { // get a JTreeFixture reference to the file project viewer entry ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2)); JTreeFixture projTree = projectFrame.getProjectViewJTree(projectName); - projTree.expand(projectName, ItConstants.CONFIG_DIR_PATH); + projTree.expand(TestUtils.combinePath(projectName, ItConstants.CONFIG_DIR_PATH)); - String[] configDirPath = TestUtils.combinePath(projectName, ItConstants.CONFIG_DIR_PATH_ARR); + String[] configDirPath = TestUtils.combinePath(projectName, ItConstants.CONFIG_DIR_PATH); // open server.xml file UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVER_XML, configDirPath); diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java index 73942e752..2ca140ad6 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java @@ -16,7 +16,6 @@ import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture; import org.junit.jupiter.api.*; -import java.io.File; import java.nio.file.Path; import java.nio.file.Paths; import java.time.Duration; @@ -98,7 +97,7 @@ public void testInsertCodeSnippetIntoJavaPart() { // Insert a code snippet into java part try { UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA, snippetStr, snippetChooser); - Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.HEALTH_DIR_PATH, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); + Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.SERVICE_LIVE_HEALTHCHECK_PATH)); TestUtils.validateCodeInJavaSrc(pathToSrc.toString(), insertedCode); } finally { // Replace modified content with the original content @@ -125,7 +124,7 @@ public void testMPDiagnosticsInJavaPart() { // Delete the liveness annotation UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA, livenessString); - Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.HEALTH_DIR_PATH, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); + Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.SERVICE_LIVE_HEALTHCHECK_PATH)); try { // validate @Liveness no longer found in java part @@ -171,7 +170,7 @@ public void testMPQuickFixInJavaFile() { // Delete the liveness annotation UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot,ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA, livenessString); - Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.HEALTH_DIR_PATH, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); + Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.SERVICE_LIVE_HEALTHCHECK_PATH)); try { // validate @Liveness no longer found in java part @@ -210,7 +209,7 @@ public void testInsertMicroProfileProperty() { try { UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, ItConstants.MPCFG_PROPERTIES, cfgSnippet, cfgNameChooserSnippet, cfgValueSnippet, true); - Path pathToMpCfgProperties = Paths.get(projectsPath, projectName, String.join(File.separator, ItConstants.META_INF_DIR_PATH), ItConstants.MPCFG_PROPERTIES); + Path pathToMpCfgProperties = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.MPCFG_PATH)); TestUtils.validateStringInFile(pathToMpCfgProperties.toString(), expectedMpCfgPropertiesString); } finally { // Replace modified microprofile-config.properties with the original content @@ -296,7 +295,7 @@ public void testQuickFixInMicroProfileConfigProperties() { String correctedValue = "mp.health.disable-default-procedures=true"; String expectedHoverData = "Type mismatch: boolean expected. By default, this value will be interpreted as 'false'"; - Path pathToMpCfgProperties = Paths.get(projectsPath, projectName, String.join(File.separator, ItConstants.META_INF_DIR_PATH), ItConstants.MPCFG_PROPERTIES); + Path pathToMpCfgProperties = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.MPCFG_PATH)); // get focus on file tab prior to copy UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.MPCFG_PROPERTIES); @@ -345,7 +344,7 @@ public static void prepareEnv(String projectPath, String projectName) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2)); JTreeFixture projTree = projectFrame.getProjectViewJTree(projectName); - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVICE_LIVEHEALTH_CHECK, TestUtils.combinePath(projectName, ItConstants.HEALTH_DIR_PATH_ARR)); + UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVICE_LIVEHEALTH_CHECK, TestUtils.combinePath(projectName, ItConstants.HEALTH_DIR_PATH)); UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.MPCFG_PROPERTIES, TestUtils.combinePath(projectName, ItConstants.META_INF_DIR_PATH)); // Removes the build tool window if it is opened. This prevents text to be hidden by it. diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java index 970423362..5f2516e6d 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java @@ -196,7 +196,7 @@ public void testsRefreshProjectWithServerXmlOnly() { // Copy a valid server.xml file to this project's src/main/liberty/config directory. Path validServerXml = Paths.get(getHelperFilesDirPath(), ItConstants.SERVER_XML); - Path destination = Paths.get(getProjectsDirPath(), getSmNLTRestProjectName(), ItConstants.CONFIG_DIR_PATH, ItConstants.SERVER_XML); + Path destination = Paths.get(getProjectsDirPath(), TestUtils.combinePath(getSmNLTRestProjectName(), ItConstants.SERVER_XML_PATH)); try { Files.copy(validServerXml, destination, StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING); diff --git a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java index 8e61e08f4..82a1909f4 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java @@ -59,7 +59,7 @@ public static void validateLibertyServerStopped(String testName, String wlpInsta public static void validateLibertyServerStopped(String testName, String wlpInstallPath, int maxAttempts, boolean failOnNoStop) { printTrace(TraceSevLevel.INFO, testName + ":validateLibertyServerStopped: Entry."); - String wlpMsgLogPath = wlpInstallPath + "/" + ItConstants.MESSAGES_LOG_PATH; + String wlpMsgLogPath = Paths.get(wlpInstallPath, ItConstants.MESSAGES_LOG_PATH).toString(); int retryIntervalSecs = 5; boolean foundStoppedMsg = false; Exception error = null; @@ -167,7 +167,7 @@ public static void validateProjectStarted(String testName, String resourceURI, i // If we are here, the expected outcome was not found. Print the Liberty server's messages.log and fail. String msg = testName + ":validateProjectStarted: Timed out while waiting for project with resource URI " + resourceURI + "and port " + port + " to become available."; printTrace(TraceSevLevel.ERROR, msg); - String wlpMsgLogPath = wlpInstallPath + "/" + ItConstants.MESSAGES_LOG_PATH; + String wlpMsgLogPath = Paths.get(wlpInstallPath, ItConstants.MESSAGES_LOG_PATH).toString(); String msgHeader = "Message log for failed test: " + testName + ":validateProjectStarted"; printLibertyMessagesLogFile(msgHeader, wlpMsgLogPath); Assertions.fail(msg); @@ -273,7 +273,7 @@ public static void validateProjectStopped(String testName, String projUrl, Strin // If we are here, the expected outcome was not found. Print the Liberty server's messages.log and fail. String msg = testName + ":validateProjectStopped: Timed out while waiting for project under URL: " + projUrl + " to stop."; printTrace(TraceSevLevel.ERROR, msg); - String wlpMsgLogPath = wlpInstallPath + "/" + ItConstants.MESSAGES_LOG_PATH; + String wlpMsgLogPath = Paths.get(wlpInstallPath, ItConstants.MESSAGES_LOG_PATH).toString(); String msgHeader = "Message log for failed test: " + testName + ":validateProjectStopped"; printLibertyMessagesLogFile(msgHeader, wlpMsgLogPath); Assertions.fail(msg); @@ -540,7 +540,7 @@ public static boolean isServerStopNeeded(String wlpInstallPath) { */ public static void checkDebugPort(String absoluteWLPPath, int debugPort) throws IOException { // Retrieve the WLP server.env file path - Path serverEnvPath = Paths.get(absoluteWLPPath, ItConstants.DEFAULT_SERVER_PATH, ItConstants.SERVER_ENV); + Path serverEnvPath = Paths.get(absoluteWLPPath, ItConstants.DEFAULT_SERVER_ENV_PATH); // Read all lines from server.env List lines = Files.readAllLines(serverEnvPath); // Check if Debug Port is set to the specified port @@ -598,6 +598,14 @@ public static void detectFatalError() { } } + + /** + * Combines the project name with a given array of paths. + * + * @param projectName the name of the project to prepend + * @param pathArray an array of paths to append to the project name + * @return a new array with the project name as the first element followed by the original paths + */ public static String[] combinePath(String projectName, String[] pathArray) { return Stream.concat(Stream.of(projectName), Arrays.stream(pathArray)) .toArray(String[]::new); diff --git a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java index d73fe26c1..84aa63463 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java +++ b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java @@ -19,16 +19,22 @@ public class ItConstants { public static final String SYSTEM_RESOURCE = "SystemResource"; public static final String SYSTEM_RESOURCE_2 = "SystemResource2"; public static final String SERVICE_LIVEHEALTH_CHECK = "ServiceLiveHealthCheck"; + public static final String SERVICE_LIVE_HEALTH_CHECK_JAVA = "ServiceLiveHealthCheck.java"; + public static final String MPCFG_PROPERTIES = "microprofile-config.properties"; - public static final String CONFIG_DIR_PATH = "src/main/liberty/config"; - public static final String[] CONFIG_DIR_PATH_ARR = { "src", "main", "liberty", "config" }; - public static final String SYSTEM_DIR_PATH = "src/main/java/io/openliberty/mp/sample/system"; - public static final String[] SYSTEM_DIR_PATH_ARR = { "src", "main", "java", "io.openliberty.mp.sample", "system"}; - public static final String HEALTH_DIR_PATH = "src/main/java/io/openliberty/mp/sample/system"; - public static final String[] HEALTH_DIR_PATH_ARR = { "src", "main", "java", "io.openliberty.mp.sample", "health" }; + public static final String[] CONFIG_DIR_PATH = { "src", "main", "liberty", "config" }; + public static final String[] SERVER_XML_PATH = { "src", "main", "liberty", "config", "server.xml" }; + public static final String[] SERVER_ENV_PATH = { "src", "main", "liberty", "config", "server.env" }; + public static final String[] BOOTSTRAP_PROPERTIES_PATH = { "src", "main", "liberty", "config", "bootstrap.properties" }; + public static final String[] SYSTEM_RESOURCE_PATH = { "src", "main", "java", "io", "openliberty", "mp", "sample", "system", "SystemResource.java"}; + public static final String[] SYSTEM_RESOURCE_2_PATH = { "src", "main", "java", "io", "openliberty", "mp", "sample", "system", "SystemResource2.java"}; + public static final String[] SYSTEM_DIR_PATH = { "src", "main", "java", "io.openliberty.mp.sample", "system"}; + public static final String[] SERVICE_LIVE_HEALTHCHECK_PATH = { "src", "main", "java", "io", "openliberty", "mp", "sample", "health", "ServiceLiveHealthCheck.java" }; + public static final String[] HEALTH_DIR_PATH = { "src", "main", "java", "io.openliberty.mp.sample", "health" }; + public static final String[] MPCFG_PATH = { "src", "main", "resources", "META-INF", "microprofile-config.properties" }; public static final String[] META_INF_DIR_PATH = { "src", "main", "resources", "META-INF" }; - public static final String DEFAULT_SERVER_PATH = "wlp/usr/servers/defaultServer"; - public static final String MESSAGES_LOG_PATH = "wlp/usr/servers/defaultServer/logs/messages.log"; + public static final String[] DEFAULT_SERVER_ENV_PATH = { "wlp","usr","servers","defaultServer" }; + public static final String[] MESSAGES_LOG_PATH = { "wlp","usr","servers","defaultServer", "logs", "messages.log" }; public static final String SERVER_XML = "server.xml"; @@ -36,8 +42,7 @@ public class ItConstants { public static final String BOOTSTRAP_PROPERTIES = "bootstrap.properties"; public static final String COMPACT_MODE = "Compact Mode"; - public static final String SERVICE_LIVE_HEALTH_CHECK_JAVA = "ServiceLiveHealthCheck.java"; - public static final String MPCFG_PROPERTIES = "microprofile-config.properties"; + public static final String CLOSE_ALL_TABS = "Close All Tabs"; } From 41a8522149f1312e1d286b0c957df94ac5f5d4f5 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Fri, 24 Jan 2025 11:51:03 +0530 Subject: [PATCH 27/28] server.env added to path --- .../tools/intellij/it/Utils/ItConstants.java | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java index 84aa63463..369470172 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java +++ b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java @@ -22,27 +22,24 @@ public class ItConstants { public static final String SERVICE_LIVE_HEALTH_CHECK_JAVA = "ServiceLiveHealthCheck.java"; public static final String MPCFG_PROPERTIES = "microprofile-config.properties"; - public static final String[] CONFIG_DIR_PATH = { "src", "main", "liberty", "config" }; - public static final String[] SERVER_XML_PATH = { "src", "main", "liberty", "config", "server.xml" }; - public static final String[] SERVER_ENV_PATH = { "src", "main", "liberty", "config", "server.env" }; - public static final String[] BOOTSTRAP_PROPERTIES_PATH = { "src", "main", "liberty", "config", "bootstrap.properties" }; - public static final String[] SYSTEM_RESOURCE_PATH = { "src", "main", "java", "io", "openliberty", "mp", "sample", "system", "SystemResource.java"}; - public static final String[] SYSTEM_RESOURCE_2_PATH = { "src", "main", "java", "io", "openliberty", "mp", "sample", "system", "SystemResource2.java"}; - public static final String[] SYSTEM_DIR_PATH = { "src", "main", "java", "io.openliberty.mp.sample", "system"}; - public static final String[] SERVICE_LIVE_HEALTHCHECK_PATH = { "src", "main", "java", "io", "openliberty", "mp", "sample", "health", "ServiceLiveHealthCheck.java" }; - public static final String[] HEALTH_DIR_PATH = { "src", "main", "java", "io.openliberty.mp.sample", "health" }; - public static final String[] MPCFG_PATH = { "src", "main", "resources", "META-INF", "microprofile-config.properties" }; - public static final String[] META_INF_DIR_PATH = { "src", "main", "resources", "META-INF" }; - public static final String[] DEFAULT_SERVER_ENV_PATH = { "wlp","usr","servers","defaultServer" }; - public static final String[] MESSAGES_LOG_PATH = { "wlp","usr","servers","defaultServer", "logs", "messages.log" }; - + public static final String[] CONFIG_DIR_PATH = {"src", "main", "liberty", "config"}; + public static final String[] SERVER_XML_PATH = {"src", "main", "liberty", "config", "server.xml"}; + public static final String[] SERVER_ENV_PATH = {"src", "main", "liberty", "config", "server.env"}; + public static final String[] BOOTSTRAP_PROPERTIES_PATH = {"src", "main", "liberty", "config", "bootstrap.properties"}; + public static final String[] SYSTEM_RESOURCE_PATH = {"src", "main", "java", "io", "openliberty", "mp", "sample", "system", "SystemResource.java"}; + public static final String[] SYSTEM_RESOURCE_2_PATH = {"src", "main", "java", "io", "openliberty", "mp", "sample", "system", "SystemResource2.java"}; + public static final String[] SYSTEM_DIR_PATH = {"src", "main", "java", "io.openliberty.mp.sample", "system"}; + public static final String[] SERVICE_LIVE_HEALTHCHECK_PATH = {"src", "main", "java", "io", "openliberty", "mp", "sample", "health", "ServiceLiveHealthCheck.java"}; + public static final String[] HEALTH_DIR_PATH = {"src", "main", "java", "io.openliberty.mp.sample", "health"}; + public static final String[] MPCFG_PATH = {"src", "main", "resources", "META-INF", "microprofile-config.properties"}; + public static final String[] META_INF_DIR_PATH = {"src", "main", "resources", "META-INF"}; + public static final String[] DEFAULT_SERVER_ENV_PATH = {"wlp", "usr", "servers", "defaultServer", "server.env"}; + public static final String[] MESSAGES_LOG_PATH = {"wlp", "usr", "servers", "defaultServer", "logs", "messages.log"}; public static final String SERVER_XML = "server.xml"; public static final String SERVER_ENV = "server.env"; public static final String BOOTSTRAP_PROPERTIES = "bootstrap.properties"; public static final String COMPACT_MODE = "Compact Mode"; - - public static final String CLOSE_ALL_TABS = "Close All Tabs"; } From 682853cc7da9511727e147ceceb78a0655fd1bd4 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Fri, 24 Jan 2025 12:00:17 +0530 Subject: [PATCH 28/28] imported static Itconstants --- .../it/SingleModJakartaLSTestCommon.java | 40 +++++----- .../it/SingleModLibertyLSTestCommon.java | 74 +++++++++---------- .../intellij/it/SingleModMPLSTestCommon.java | 58 +++++++-------- .../it/SingleModMPProjectTestCommon.java | 10 +-- .../it/SingleModNLTRestProjectTestCommon.java | 10 +-- .../tools/intellij/it/TestUtils.java | 13 ++-- .../tools/intellij/it/UIBotTestUtils.java | 12 +-- 7 files changed, 109 insertions(+), 108 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java index 93c812ec8..fab7d96c5 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java @@ -12,7 +12,6 @@ import com.automation.remarks.junit5.Video; import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.fixtures.JTreeFixture; -import io.openliberty.tools.intellij.it.Utils.ItConstants; import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture; import org.junit.jupiter.api.*; @@ -21,6 +20,7 @@ import java.time.Duration; import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitForIgnoringError; +import static io.openliberty.tools.intellij.it.Utils.ItConstants.*; public abstract class SingleModJakartaLSTestCommon { public static final String REMOTEBOT_URL = "http://localhost:8082"; @@ -62,8 +62,8 @@ public void afterEach(TestInfo info) { public static void cleanup() { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2)); - UIBotTestUtils.closeFileEditorTab(remoteRobot, ItConstants.SYSTEM_RESOURCE_JAVA, "5"); - UIBotTestUtils.closeFileEditorTab(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA, "5"); + UIBotTestUtils.closeFileEditorTab(remoteRobot, SYSTEM_RESOURCE_JAVA, "5"); + UIBotTestUtils.closeFileEditorTab(remoteRobot, SYSTEM_RESOURCE_2_JAVA, "5"); UIBotTestUtils.closeProjectView(remoteRobot); UIBotTestUtils.closeProjectFrame(remoteRobot); @@ -81,7 +81,7 @@ public void testInsertJakartaCodeSnippetIntoJavaPart() { String insertedCode = "public String methodname() {"; // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SYSTEM_RESOURCE_JAVA); + UIBotTestUtils.clickOnFileTab(remoteRobot, SYSTEM_RESOURCE_JAVA); // Save the current content. UIBotTestUtils.copyWindowContent(remoteRobot); @@ -91,8 +91,8 @@ public void testInsertJakartaCodeSnippetIntoJavaPart() { // Insert a code snippet into java part try { - UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, ItConstants.SYSTEM_RESOURCE_JAVA, snippetStr, snippetChooser); - Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.SYSTEM_RESOURCE_PATH)); + UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, SYSTEM_RESOURCE_JAVA, snippetStr, snippetChooser); + Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, SYSTEM_RESOURCE_PATH)); TestUtils.validateCodeInJavaSrc(pathToSrc.toString(), insertedCode); } finally { @@ -110,28 +110,28 @@ public void testJakartaDiagnosticsInJavaPart() { String privateString = "private Response getProperties() {"; String flaggedString = "getProperties"; String expectedHoverData = "Only public methods can be exposed as resource methods"; - Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.SYSTEM_RESOURCE_2_PATH)); + Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, SYSTEM_RESOURCE_2_PATH)); // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA); + UIBotTestUtils.clickOnFileTab(remoteRobot, SYSTEM_RESOURCE_2_JAVA); // Modify the method signature - UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA, publicString, privateString); + UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, SYSTEM_RESOURCE_2_JAVA, publicString, privateString); try { // validate the method signature is no longer set to public TestUtils.validateStringNotInFile(pathToSrc.toString(), publicString); //there should be a diagnostic for "private" on method signature - move cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, ItConstants.SYSTEM_RESOURCE_2_JAVA, UIBotTestUtils.PopupType.DIAGNOSTIC); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, SYSTEM_RESOURCE_2_JAVA, UIBotTestUtils.PopupType.DIAGNOSTIC); String foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC); TestUtils.validateHoverData(expectedHoverData, foundHoverData); - UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA); + UIBotTestUtils.clickOnFileTab(remoteRobot, SYSTEM_RESOURCE_2_JAVA); } finally { // Replace modified content with the original content - UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA, privateString, publicString); + UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, SYSTEM_RESOURCE_2_JAVA, privateString, publicString); } } @@ -145,24 +145,24 @@ public void testJakartaQuickFixInJavaPart() { String privateString = "private Response getProperties() {"; String flaggedString = "getProperties"; - Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.SYSTEM_RESOURCE_2_PATH)); + Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, SYSTEM_RESOURCE_2_PATH)); String quickfixChooserString = "Make method public"; // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA); + UIBotTestUtils.clickOnFileTab(remoteRobot, SYSTEM_RESOURCE_2_JAVA); // Save the current content. UIBotTestUtils.copyWindowContent(remoteRobot); // Modify the method signature - UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA, publicString, privateString); + UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, SYSTEM_RESOURCE_2_JAVA, publicString, privateString); try { // validate public signature no longer found in java part TestUtils.validateStringNotInFile(pathToSrc.toString(), publicString); //there should be a diagnostic - move cursor to hover point - UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, ItConstants.SYSTEM_RESOURCE_2_JAVA, quickfixChooserString); + UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, SYSTEM_RESOURCE_2_JAVA, quickfixChooserString); // trigger and use the quickfix popup attached to the diagnostic UIBotTestUtils.chooseQuickFix(remoteRobot, quickfixChooserString); @@ -199,11 +199,11 @@ public static void prepareEnv(String projectPath, String projectName) { // expand project directories that are specific to this test app being used by these testcases // must be expanded here before trying to open specific files - projTree.expand(TestUtils.combinePath(projectName, ItConstants.SYSTEM_DIR_PATH)); + projTree.expand(TestUtils.combinePath(projectName, SYSTEM_DIR_PATH)); - String[] systemDirPath = TestUtils.combinePath(projectName, ItConstants.SYSTEM_DIR_PATH); - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE, systemDirPath); - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE_2, systemDirPath); + String[] systemDirPath = TestUtils.combinePath(projectName, SYSTEM_DIR_PATH); + UIBotTestUtils.openFile(remoteRobot, projectName, SYSTEM_RESOURCE, systemDirPath); + UIBotTestUtils.openFile(remoteRobot, projectName, SYSTEM_RESOURCE_2, systemDirPath); // Removes the build tool window if it is opened. This prevents text to be hidden by it. UIBotTestUtils.removeToolWindow(remoteRobot, "Build:"); diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java index d64e7e810..8b53b7064 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -12,7 +12,6 @@ import com.automation.remarks.junit5.Video; import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.fixtures.JTreeFixture; -import io.openliberty.tools.intellij.it.Utils.ItConstants; import com.intellij.remoterobot.utils.Keyboard; import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture; import org.junit.jupiter.api.*; @@ -26,6 +25,7 @@ import static java.awt.event.KeyEvent.VK_SPACE; import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitForIgnoringError; +import static io.openliberty.tools.intellij.it.Utils.ItConstants.*; public abstract class SingleModLibertyLSTestCommon { public static final String REMOTEBOT_URL = "http://localhost:8082"; @@ -65,11 +65,11 @@ public void afterEach(TestInfo info) { */ @AfterAll public static void cleanup() { - UIBotTestUtils.closeFileEditorTab(remoteRobot, ItConstants.SERVER_XML, "5"); - UIBotTestUtils.closeFileEditorTab(remoteRobot, ItConstants.SERVER_ENV, "5"); - UIBotTestUtils.closeFileEditorTab(remoteRobot, ItConstants.BOOTSTRAP_PROPERTIES, "5"); + UIBotTestUtils.closeFileEditorTab(remoteRobot, SERVER_XML, "5"); + UIBotTestUtils.closeFileEditorTab(remoteRobot, SERVER_ENV, "5"); + UIBotTestUtils.closeFileEditorTab(remoteRobot, BOOTSTRAP_PROPERTIES, "5"); if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, ItConstants.COMPACT_MODE, 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, COMPACT_MODE, 3); } UIBotTestUtils.closeProjectView(remoteRobot); UIBotTestUtils.closeProjectFrame(remoteRobot); @@ -87,7 +87,7 @@ public void testServerXMLFeatureHover() { String hoverExpectedOutcome = "This feature provides support for the MicroProfile Health specification."; //mover cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, ItConstants.SERVER_XML, UIBotTestUtils.PopupType.DOCUMENTATION); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, SERVER_XML, UIBotTestUtils.PopupType.DOCUMENTATION); String hoverFoundOutcome = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DOCUMENTATION); // Validate that the hover action raised the expected hint text @@ -105,7 +105,7 @@ public void testServerXMLNonFeatureHover() { String hoverExpectedOutcome = "Configuration properties for an HTTP endpoint."; //mover cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, ItConstants.SERVER_XML, UIBotTestUtils.PopupType.DOCUMENTATION); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, SERVER_XML, UIBotTestUtils.PopupType.DOCUMENTATION); String hoverFoundOutcome = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DOCUMENTATION); // Validate that the hover action raised the expected hint text @@ -123,7 +123,7 @@ public void testInsertFeatureIntoServerXML() { String insertedFeature = "el-3.0"; // get focus on server.xml tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVER_XML); + UIBotTestUtils.clickOnFileTab(remoteRobot, SERVER_XML); // Save the current server.xml content. UIBotTestUtils.copyWindowContent(remoteRobot); @@ -131,7 +131,7 @@ public void testInsertFeatureIntoServerXML() { // Insert a new element in server.xml. try { UIBotTestUtils.insertStanzaInAppServerXML(remoteRobot, stanzaSnippet, 18, 40, UIBotTestUtils.InsertionType.FEATURE, true); - Path pathToServerXML = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.SERVER_XML_PATH)); + Path pathToServerXML = Paths.get(projectsPath, TestUtils.combinePath(projectName, SERVER_XML_PATH)); TestUtils.validateStanzaInConfigFile(pathToServerXML.toString(), insertedFeature); } finally { // Replace server.xml content with the original content @@ -150,7 +150,7 @@ public void testInsertLibertyConfigElementIntoServerXML() { String insertedConfig = ""; // get focus on server.xml tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVER_XML); + UIBotTestUtils.clickOnFileTab(remoteRobot, SERVER_XML); // Save the current server.xml content. UIBotTestUtils.copyWindowContent(remoteRobot); @@ -159,7 +159,7 @@ public void testInsertLibertyConfigElementIntoServerXML() { try { UIBotTestUtils.insertStanzaInAppServerXML(remoteRobot, stanzaSnippet, 20, 0, UIBotTestUtils.InsertionType.ELEMENT, true); TestUtils.sleepAndIgnoreException(2); // wait for editor to update - Path pathToServerXML = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.SERVER_XML_PATH)); + Path pathToServerXML = Paths.get(projectsPath, TestUtils.combinePath(projectName, SERVER_XML_PATH)); TestUtils.validateStanzaInConfigFile(pathToServerXML.toString(), insertedConfig); } finally { // Replace server.xml content with the original content @@ -181,14 +181,14 @@ public void testInsertLibertyConfigIntoServerEnvForCapitalCase() { String expectedServerEnvString = "WLP_LOGGING_CONSOLE_FORMAT=SIMPLE"; // get focus on server.env tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVER_ENV); + UIBotTestUtils.clickOnFileTab(remoteRobot, SERVER_ENV); // Save the current server.env content. UIBotTestUtils.copyWindowContent(remoteRobot); try { - UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, ItConstants.SERVER_ENV, envCfgSnippet, envCfgNameChooserSnippet, envCfgValueSnippet, true); - Path pathToServerEnv = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.SERVER_ENV_PATH)); + UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, SERVER_ENV, envCfgSnippet, envCfgNameChooserSnippet, envCfgValueSnippet, true); + Path pathToServerEnv = Paths.get(projectsPath, TestUtils.combinePath(projectName, SERVER_ENV_PATH)); TestUtils.validateStringInFile(pathToServerEnv.toString(), expectedServerEnvString); } finally { // Replace server.xml content with the original content @@ -266,14 +266,14 @@ public void testInsertLibertyConfigIntoBootstrapPropsForLowerCase() { String expectedBootstrapPropsString = "com.ibm.ws.logging.console.format=TBASIC"; // get focus on bootstrap.properties tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.BOOTSTRAP_PROPERTIES); + UIBotTestUtils.clickOnFileTab(remoteRobot, BOOTSTRAP_PROPERTIES); // Save the current bootstrap.properties content. UIBotTestUtils.copyWindowContent(remoteRobot); try { - UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, ItConstants.BOOTSTRAP_PROPERTIES, configNameSnippet, configNameChooserSnippet, configValueSnippet, true); - Path pathToBootstrapProps = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.BOOTSTRAP_PROPERTIES_PATH)); + UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, BOOTSTRAP_PROPERTIES, configNameSnippet, configNameChooserSnippet, configValueSnippet, true); + Path pathToBootstrapProps = Paths.get(projectsPath, TestUtils.combinePath(projectName, BOOTSTRAP_PROPERTIES_PATH)); TestUtils.validateStringInFile(pathToBootstrapProps.toString(), expectedBootstrapPropsString); } finally { // Replace server.xml content with the original content @@ -368,7 +368,7 @@ public void testServerEnvCfgHover() { String hoverExpectedOutcome = "This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default."; //mover cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, ItConstants.SERVER_ENV, UIBotTestUtils.PopupType.DOCUMENTATION); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, SERVER_ENV, UIBotTestUtils.PopupType.DOCUMENTATION); String hoverFoundOutcome = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DOCUMENTATION); // Validate that the hover action raised the expected hint text @@ -387,7 +387,7 @@ public void testBootstrapPropsCfgHover() { String hoverExpectedOutcome = "This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default."; //mover cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, ItConstants.BOOTSTRAP_PROPERTIES, UIBotTestUtils.PopupType.DOCUMENTATION); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, BOOTSTRAP_PROPERTIES, UIBotTestUtils.PopupType.DOCUMENTATION); String hoverFoundOutcome = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DOCUMENTATION); // Validate that the hover action raised the expected hint text @@ -406,10 +406,10 @@ public void testDiagnosticInServerXML() { String expectedHoverData = "cvc-datatype-valid.1.2.3: 'wrong' is not a valid value of union type 'booleanType'."; Path pathToServerXML = null; - pathToServerXML = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.SERVER_XML_PATH)); + pathToServerXML = Paths.get(projectsPath, TestUtils.combinePath(projectName, SERVER_XML_PATH)); // get focus on server.xml tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVER_XML); + UIBotTestUtils.clickOnFileTab(remoteRobot, SERVER_XML); // Save the current server.xml content. UIBotTestUtils.copyWindowContent(remoteRobot); @@ -418,7 +418,7 @@ public void testDiagnosticInServerXML() { UIBotTestUtils.insertStanzaInAppServerXML(remoteRobot, stanzaSnippet, 20, 0, UIBotTestUtils.InsertionType.ELEMENT, false); //move cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, ItConstants.SERVER_XML, UIBotTestUtils.PopupType.DIAGNOSTIC); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, SERVER_XML, UIBotTestUtils.PopupType.DIAGNOSTIC); String foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC); TestUtils.validateHoverData(expectedHoverData, foundHoverData); @@ -442,10 +442,10 @@ public void testQuickFixInServerXML() { String expectedHoverData = "cvc-datatype-valid.1.2.3: 'wrong' is not a valid value of union type 'booleanType'."; Path pathToServerXML = null; - pathToServerXML = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.SERVER_XML_PATH)); + pathToServerXML = Paths.get(projectsPath, TestUtils.combinePath(projectName, SERVER_XML_PATH)); // get focus on server.xml tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVER_XML); + UIBotTestUtils.clickOnFileTab(remoteRobot, SERVER_XML); // Save the current server.xml content. UIBotTestUtils.copyWindowContent(remoteRobot); @@ -454,7 +454,7 @@ public void testQuickFixInServerXML() { UIBotTestUtils.insertStanzaInAppServerXML(remoteRobot, stanzaSnippet, 20, 0, UIBotTestUtils.InsertionType.ELEMENT, false); //there should be a diagnostic - move cursor to hover point - UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, ItConstants.SERVER_XML, quickfixChooserString); + UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, SERVER_XML, quickfixChooserString); UIBotTestUtils.chooseQuickFix(remoteRobot, quickfixChooserString); TestUtils.validateStanzaInConfigFile(pathToServerXML.toString(), correctedStanza); @@ -477,15 +477,15 @@ public void testDiagnosticInServerEnv() { String expectedHoverData = "The value `NONE` is not valid for the variable `WLP_LOGGING_CONSOLE_FORMAT`."; // get focus on server.env tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVER_ENV); + UIBotTestUtils.clickOnFileTab(remoteRobot, SERVER_ENV); // Save the current server.env content. UIBotTestUtils.copyWindowContent(remoteRobot); try { - UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, ItConstants.SERVER_ENV, envCfgSnippet, envCfgNameChooserSnippet, incorrectValue, false); + UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, SERVER_ENV, envCfgSnippet, envCfgNameChooserSnippet, incorrectValue, false); //move cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, "NONE", ItConstants.SERVER_ENV, UIBotTestUtils.PopupType.DIAGNOSTIC); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, "NONE", SERVER_ENV, UIBotTestUtils.PopupType.DIAGNOSTIC); String foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC); TestUtils.validateHoverData(expectedHoverData, foundHoverData); @@ -507,16 +507,16 @@ public void testDiagnosticInBootstrapProperties() { String expectedHoverData = "The value `none` is not valid for the property `com.ibm.ws.logging.console.format`."; // get focus on bootstrap.properties tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.BOOTSTRAP_PROPERTIES); + UIBotTestUtils.clickOnFileTab(remoteRobot, BOOTSTRAP_PROPERTIES); // Save the current bootstrap.properties content. UIBotTestUtils.copyWindowContent(remoteRobot); try { - UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, ItConstants.BOOTSTRAP_PROPERTIES, configNameSnippet, configNameChooserSnippet, incorrectValue, false); + UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, BOOTSTRAP_PROPERTIES, configNameSnippet, configNameChooserSnippet, incorrectValue, false); //move cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, "none", ItConstants.BOOTSTRAP_PROPERTIES, UIBotTestUtils.PopupType.DIAGNOSTIC); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, "none", BOOTSTRAP_PROPERTIES, UIBotTestUtils.PopupType.DIAGNOSTIC); String foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC); TestUtils.validateHoverData(expectedHoverData, foundHoverData); } finally { @@ -582,7 +582,7 @@ public static void prepareEnv(String projectPath, String projectName) { UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); UIBotTestUtils.openProjectView(remoteRobot); if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, ItConstants.COMPACT_MODE, 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, COMPACT_MODE, 3); } // IntelliJ does not start building and indexing until the Project View is open UIBotTestUtils.waitForIndexing(remoteRobot); @@ -592,18 +592,18 @@ public static void prepareEnv(String projectPath, String projectName) { // get a JTreeFixture reference to the file project viewer entry ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2)); JTreeFixture projTree = projectFrame.getProjectViewJTree(projectName); - projTree.expand(TestUtils.combinePath(projectName, ItConstants.CONFIG_DIR_PATH)); + projTree.expand(TestUtils.combinePath(projectName, CONFIG_DIR_PATH)); - String[] configDirPath = TestUtils.combinePath(projectName, ItConstants.CONFIG_DIR_PATH); + String[] configDirPath = TestUtils.combinePath(projectName, CONFIG_DIR_PATH); // open server.xml file - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVER_XML, configDirPath); + UIBotTestUtils.openFile(remoteRobot, projectName, SERVER_XML, configDirPath); // open server.env file - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVER_ENV, configDirPath); + UIBotTestUtils.openFile(remoteRobot, projectName, SERVER_ENV, configDirPath); // open bootstrap.properties file - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.BOOTSTRAP_PROPERTIES, configDirPath); + UIBotTestUtils.openFile(remoteRobot, projectName, BOOTSTRAP_PROPERTIES, configDirPath); // Removes the build tool window if it is opened. This prevents text to be hidden by it. UIBotTestUtils.removeToolWindow(remoteRobot, "Build:"); diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java index 2ca140ad6..14379774d 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java @@ -12,7 +12,6 @@ import com.automation.remarks.junit5.Video; import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.fixtures.JTreeFixture; -import io.openliberty.tools.intellij.it.Utils.ItConstants; import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture; import org.junit.jupiter.api.*; @@ -21,6 +20,7 @@ import java.time.Duration; import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitForIgnoringError; +import static io.openliberty.tools.intellij.it.Utils.ItConstants.*; public abstract class SingleModMPLSTestCommon { public static final String REMOTEBOT_URL = "http://localhost:8082"; @@ -65,10 +65,10 @@ public static void cleanup() { projectFrame.findText("META-INF").doubleClick(); projectFrame.findText("resources").doubleClick(); - UIBotTestUtils.closeFileEditorTab(remoteRobot, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA, "5"); - UIBotTestUtils.closeFileEditorTab(remoteRobot, ItConstants.MPCFG_PROPERTIES, "5"); + UIBotTestUtils.closeFileEditorTab(remoteRobot, SERVICE_LIVE_HEALTH_CHECK_JAVA, "5"); + UIBotTestUtils.closeFileEditorTab(remoteRobot, MPCFG_PROPERTIES, "5"); if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, ItConstants.COMPACT_MODE, 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, COMPACT_MODE, 3); } UIBotTestUtils.closeProjectView(remoteRobot); UIBotTestUtils.closeProjectFrame(remoteRobot); @@ -86,7 +86,7 @@ public void testInsertCodeSnippetIntoJavaPart() { String insertedCode = "public class ServiceLiveHealthCheck implements HealthCheck {"; // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); + UIBotTestUtils.clickOnFileTab(remoteRobot, SERVICE_LIVE_HEALTH_CHECK_JAVA); // Save the current content. UIBotTestUtils.copyWindowContent(remoteRobot); @@ -96,8 +96,8 @@ public void testInsertCodeSnippetIntoJavaPart() { // Insert a code snippet into java part try { - UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA, snippetStr, snippetChooser); - Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.SERVICE_LIVE_HEALTHCHECK_PATH)); + UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, SERVICE_LIVE_HEALTH_CHECK_JAVA, snippetStr, snippetChooser); + Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, SERVICE_LIVE_HEALTHCHECK_PATH)); TestUtils.validateCodeInJavaSrc(pathToSrc.toString(), insertedCode); } finally { // Replace modified content with the original content @@ -117,14 +117,14 @@ public void testMPDiagnosticsInJavaPart() { String expectedHoverData = "The class `io.openliberty.mp.sample.health.ServiceLiveHealthCheck` implementing the HealthCheck interface should use the @Liveness, @Readiness or @Health annotation."; // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); + UIBotTestUtils.clickOnFileTab(remoteRobot, SERVICE_LIVE_HEALTH_CHECK_JAVA); // Save the current content. UIBotTestUtils.copyWindowContent(remoteRobot); // Delete the liveness annotation - UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA, livenessString); - Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.SERVICE_LIVE_HEALTHCHECK_PATH)); + UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot, SERVICE_LIVE_HEALTH_CHECK_JAVA, livenessString); + Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, SERVICE_LIVE_HEALTHCHECK_PATH)); try { // validate @Liveness no longer found in java part @@ -135,7 +135,7 @@ public void testMPDiagnosticsInJavaPart() { int maxWait = 60, delay = 5; // in some cases it can take 35s for the diagnostic to appear for (int i = 0; i <= maxWait; i += delay) { //there should be a diagnostic - move cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA, UIBotTestUtils.PopupType.DIAGNOSTIC); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, SERVICE_LIVE_HEALTH_CHECK_JAVA, UIBotTestUtils.PopupType.DIAGNOSTIC); foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC); if (!foundHoverData.isBlank()) { @@ -163,21 +163,21 @@ public void testMPQuickFixInJavaFile() { String mainQuickFixActionStr = "Generate OpenAPI Annotations for 'ServiceLiveHealthCheck'"; // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA); + UIBotTestUtils.clickOnFileTab(remoteRobot, SERVICE_LIVE_HEALTH_CHECK_JAVA); // Save the current content. UIBotTestUtils.copyWindowContent(remoteRobot); // Delete the liveness annotation - UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot,ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA, livenessString); - Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.SERVICE_LIVE_HEALTHCHECK_PATH)); + UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot,SERVICE_LIVE_HEALTH_CHECK_JAVA, livenessString); + Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, SERVICE_LIVE_HEALTHCHECK_PATH)); try { // validate @Liveness no longer found in java part TestUtils.validateStringNotInFile(pathToSrc.toString(), livenessString); //there should be a diagnostic - move cursor to hover point - UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, ItConstants.SERVICE_LIVE_HEALTH_CHECK_JAVA, quickfixChooserString); + UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, SERVICE_LIVE_HEALTH_CHECK_JAVA, quickfixChooserString); // trigger and use the quickfix popup attached to the diagnostic UIBotTestUtils.chooseQuickFix(remoteRobot, quickfixChooserString); @@ -202,14 +202,14 @@ public void testInsertMicroProfileProperty() { String expectedMpCfgPropertiesString = "mp.health.disable-default-procedures=true"; // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.MPCFG_PROPERTIES); + UIBotTestUtils.clickOnFileTab(remoteRobot, MPCFG_PROPERTIES); // Save the current microprofile-config.properties content. UIBotTestUtils.copyWindowContent(remoteRobot); try { - UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, ItConstants.MPCFG_PROPERTIES, cfgSnippet, cfgNameChooserSnippet, cfgValueSnippet, true); - Path pathToMpCfgProperties = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.MPCFG_PATH)); + UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, MPCFG_PROPERTIES, cfgSnippet, cfgNameChooserSnippet, cfgValueSnippet, true); + Path pathToMpCfgProperties = Paths.get(projectsPath, TestUtils.combinePath(projectName, MPCFG_PATH)); TestUtils.validateStringInFile(pathToMpCfgProperties.toString(), expectedMpCfgPropertiesString); } finally { // Replace modified microprofile-config.properties with the original content @@ -232,7 +232,7 @@ public void testMicroProfileConfigHover() { "java.lang.StringValue: http://localhost:9081/data/client/service"; //mover cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, ItConstants.MPCFG_PROPERTIES, UIBotTestUtils.PopupType.DOCUMENTATION); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, MPCFG_PROPERTIES, UIBotTestUtils.PopupType.DOCUMENTATION); String hoverFoundOutcome = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DOCUMENTATION); // if the LS has not yet poulated the popup, re-get the popup data @@ -262,16 +262,16 @@ public void testDiagnosticInMicroProfileConfigProperties() { String expectedHoverData = "Type mismatch: boolean expected. By default, this value will be interpreted as 'false'"; // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.MPCFG_PROPERTIES); + UIBotTestUtils.clickOnFileTab(remoteRobot, MPCFG_PROPERTIES); // Save the current content. UIBotTestUtils.copyWindowContent(remoteRobot); try { - UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, ItConstants.MPCFG_PROPERTIES, MPCfgSnippet, MPCfgNameChooserSnippet, incorrectValue, false); + UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, MPCFG_PROPERTIES, MPCfgSnippet, MPCfgNameChooserSnippet, incorrectValue, false); //move cursor to hover point - UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, incorrectValue, ItConstants.MPCFG_PROPERTIES, UIBotTestUtils.PopupType.DIAGNOSTIC); + UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, incorrectValue, MPCFG_PROPERTIES, UIBotTestUtils.PopupType.DIAGNOSTIC); String foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC); TestUtils.validateHoverData(expectedHoverData, foundHoverData); } finally { @@ -295,19 +295,19 @@ public void testQuickFixInMicroProfileConfigProperties() { String correctedValue = "mp.health.disable-default-procedures=true"; String expectedHoverData = "Type mismatch: boolean expected. By default, this value will be interpreted as 'false'"; - Path pathToMpCfgProperties = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.MPCFG_PATH)); + Path pathToMpCfgProperties = Paths.get(projectsPath, TestUtils.combinePath(projectName, MPCFG_PATH)); // get focus on file tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.MPCFG_PROPERTIES); + UIBotTestUtils.clickOnFileTab(remoteRobot, MPCFG_PROPERTIES); // Save the current content. UIBotTestUtils.copyWindowContent(remoteRobot); try { - UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, ItConstants.MPCFG_PROPERTIES, MPCfgSnippet, MPCfgNameChooserSnippet, incorrectValue, false); + UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, MPCFG_PROPERTIES, MPCfgSnippet, MPCfgNameChooserSnippet, incorrectValue, false); //move cursor to hover point - UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, incorrectValue, ItConstants.MPCFG_PROPERTIES, quickfixChooserString); + UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, incorrectValue, MPCFG_PROPERTIES, quickfixChooserString); UIBotTestUtils.chooseQuickFix(remoteRobot, quickfixChooserString); TestUtils.validateStanzaInConfigFile(pathToMpCfgProperties.toString(), correctedValue); @@ -333,7 +333,7 @@ public static void prepareEnv(String projectPath, String projectName) { UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); UIBotTestUtils.openProjectView(remoteRobot); if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, ItConstants.COMPACT_MODE, 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, COMPACT_MODE, 3); } // IntelliJ does not start building and indexing until the Project View is open UIBotTestUtils.waitForIndexing(remoteRobot); @@ -344,8 +344,8 @@ public static void prepareEnv(String projectPath, String projectName) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2)); JTreeFixture projTree = projectFrame.getProjectViewJTree(projectName); - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SERVICE_LIVEHEALTH_CHECK, TestUtils.combinePath(projectName, ItConstants.HEALTH_DIR_PATH)); - UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.MPCFG_PROPERTIES, TestUtils.combinePath(projectName, ItConstants.META_INF_DIR_PATH)); + UIBotTestUtils.openFile(remoteRobot, projectName, SERVICE_LIVEHEALTH_CHECK, TestUtils.combinePath(projectName, HEALTH_DIR_PATH)); + UIBotTestUtils.openFile(remoteRobot, projectName, MPCFG_PROPERTIES, TestUtils.combinePath(projectName, META_INF_DIR_PATH)); // Removes the build tool window if it is opened. This prevents text to be hidden by it. UIBotTestUtils.removeToolWindow(remoteRobot, "Build:"); diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java index f5c8cb838..7e98335fe 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java @@ -13,7 +13,6 @@ import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.fixtures.ComponentFixture; import com.intellij.remoterobot.utils.Keyboard; -import io.openliberty.tools.intellij.it.Utils.ItConstants; import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture; import org.junit.jupiter.api.*; import org.junit.jupiter.api.condition.EnabledOnOs; @@ -28,6 +27,7 @@ import java.util.Map; import static com.intellij.remoterobot.search.locators.Locators.byXpath; +import static io.openliberty.tools.intellij.it.Utils.ItConstants.*; import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitForIgnoringError; /** @@ -295,8 +295,8 @@ public static void cleanup() { */ protected static void closeProjectView() { if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, ItConstants.CLOSE_ALL_TABS, 3); - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, ItConstants.COMPACT_MODE, 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, CLOSE_ALL_TABS, 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, COMPACT_MODE, 3); } UIBotTestUtils.closeLibertyToolWindow(remoteRobot); UIBotTestUtils.closeProjectView(remoteRobot); @@ -1140,7 +1140,7 @@ public static void prepareEnv(String projectPath, String projectName) { UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); UIBotTestUtils.openProjectView(remoteRobot); if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, ItConstants.COMPACT_MODE, 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, COMPACT_MODE, 3); } // IntelliJ does not start building and indexing until the Project View is open UIBotTestUtils.waitForIndexing(remoteRobot); @@ -1158,7 +1158,7 @@ public static void prepareEnv(String projectPath, String projectName) { UIBotTestUtils.closeAllEditorTabs(remoteRobot); } else { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, ItConstants.CLOSE_ALL_TABS, 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, CLOSE_ALL_TABS, 3); } TestUtils.printTrace(TestUtils.TraceSevLevel.INFO, diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java index 5f2516e6d..6bdcfe201 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java @@ -11,7 +11,6 @@ import com.automation.remarks.junit5.Video; import com.intellij.remoterobot.RemoteRobot; -import io.openliberty.tools.intellij.it.Utils.ItConstants; import org.junit.jupiter.api.*; import java.nio.file.Files; @@ -22,6 +21,7 @@ import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitForIgnoringError; import static org.junit.jupiter.api.Assertions.fail; +import static io.openliberty.tools.intellij.it.Utils.ItConstants.*; /** * Holds common tests that use a single module non Liberty Tools compliant REST project. @@ -86,7 +86,7 @@ public void afterEach(TestInfo info) { @AfterAll public static void cleanup() { if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, ItConstants.COMPACT_MODE, 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, COMPACT_MODE, 3); } UIBotTestUtils.closeLibertyToolWindow(remoteRobot); UIBotTestUtils.closeProjectView(remoteRobot); @@ -195,8 +195,8 @@ public void testsRefreshProjectWithServerXmlOnly() { UIBotTestUtils.waitForLTWNoProjectDetectedMsg(remoteRobot, 10); // Copy a valid server.xml file to this project's src/main/liberty/config directory. - Path validServerXml = Paths.get(getHelperFilesDirPath(), ItConstants.SERVER_XML); - Path destination = Paths.get(getProjectsDirPath(), TestUtils.combinePath(getSmNLTRestProjectName(), ItConstants.SERVER_XML_PATH)); + Path validServerXml = Paths.get(getHelperFilesDirPath(), SERVER_XML); + Path destination = Paths.get(getProjectsDirPath(), TestUtils.combinePath(getSmNLTRestProjectName(), SERVER_XML_PATH)); try { Files.copy(validServerXml, destination, StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING); @@ -303,7 +303,7 @@ public static void prepareEnv(String projectPath, String projectName) { UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); UIBotTestUtils.openProjectView(remoteRobot); if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, ItConstants.COMPACT_MODE, 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, COMPACT_MODE, 3); } // IntelliJ does not start building and indexing until the Project View is open UIBotTestUtils.waitForIndexing(remoteRobot); diff --git a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java index 82a1909f4..0c271a47a 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java @@ -9,7 +9,6 @@ *******************************************************************************/ package io.openliberty.tools.intellij.it; -import io.openliberty.tools.intellij.it.Utils.ItConstants; import org.junit.jupiter.api.Assertions; import java.io.*; @@ -22,6 +21,8 @@ import java.util.List; import java.util.stream.Stream; +import static io.openliberty.tools.intellij.it.Utils.ItConstants.*; + /** * Test utilities. */ @@ -59,7 +60,7 @@ public static void validateLibertyServerStopped(String testName, String wlpInsta public static void validateLibertyServerStopped(String testName, String wlpInstallPath, int maxAttempts, boolean failOnNoStop) { printTrace(TraceSevLevel.INFO, testName + ":validateLibertyServerStopped: Entry."); - String wlpMsgLogPath = Paths.get(wlpInstallPath, ItConstants.MESSAGES_LOG_PATH).toString(); + String wlpMsgLogPath = Paths.get(wlpInstallPath, MESSAGES_LOG_PATH).toString(); int retryIntervalSecs = 5; boolean foundStoppedMsg = false; Exception error = null; @@ -167,7 +168,7 @@ public static void validateProjectStarted(String testName, String resourceURI, i // If we are here, the expected outcome was not found. Print the Liberty server's messages.log and fail. String msg = testName + ":validateProjectStarted: Timed out while waiting for project with resource URI " + resourceURI + "and port " + port + " to become available."; printTrace(TraceSevLevel.ERROR, msg); - String wlpMsgLogPath = Paths.get(wlpInstallPath, ItConstants.MESSAGES_LOG_PATH).toString(); + String wlpMsgLogPath = Paths.get(wlpInstallPath, MESSAGES_LOG_PATH).toString(); String msgHeader = "Message log for failed test: " + testName + ":validateProjectStarted"; printLibertyMessagesLogFile(msgHeader, wlpMsgLogPath); Assertions.fail(msg); @@ -273,7 +274,7 @@ public static void validateProjectStopped(String testName, String projUrl, Strin // If we are here, the expected outcome was not found. Print the Liberty server's messages.log and fail. String msg = testName + ":validateProjectStopped: Timed out while waiting for project under URL: " + projUrl + " to stop."; printTrace(TraceSevLevel.ERROR, msg); - String wlpMsgLogPath = Paths.get(wlpInstallPath, ItConstants.MESSAGES_LOG_PATH).toString(); + String wlpMsgLogPath = Paths.get(wlpInstallPath, MESSAGES_LOG_PATH).toString(); String msgHeader = "Message log for failed test: " + testName + ":validateProjectStopped"; printLibertyMessagesLogFile(msgHeader, wlpMsgLogPath); Assertions.fail(msg); @@ -515,7 +516,7 @@ public static void sleepAndIgnoreException(int seconds) { */ public static boolean isServerStopNeeded(String wlpInstallPath) { boolean stopServer = false; - Path msgLogPath = Paths.get(wlpInstallPath, ItConstants.MESSAGES_LOG_PATH); + Path msgLogPath = Paths.get(wlpInstallPath, MESSAGES_LOG_PATH); if (fileExists(msgLogPath)) { try { // The file maybe an old log. For now, check for the message indicating @@ -540,7 +541,7 @@ public static boolean isServerStopNeeded(String wlpInstallPath) { */ public static void checkDebugPort(String absoluteWLPPath, int debugPort) throws IOException { // Retrieve the WLP server.env file path - Path serverEnvPath = Paths.get(absoluteWLPPath, ItConstants.DEFAULT_SERVER_ENV_PATH); + Path serverEnvPath = Paths.get(absoluteWLPPath, DEFAULT_SERVER_ENV_PATH); // Read all lines from server.env List lines = Files.readAllLines(serverEnvPath); // Check if Debug Port is set to the specified port diff --git a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java index 6e3b07a78..c9b4a84fc 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java @@ -17,7 +17,6 @@ import com.intellij.remoterobot.utils.Keyboard; import com.intellij.remoterobot.utils.RepeatUtilsKt; import com.intellij.remoterobot.utils.WaitForConditionTimeoutException; -import io.openliberty.tools.intellij.it.Utils.ItConstants; import io.openliberty.tools.intellij.it.fixtures.DialogFixture; import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture; import io.openliberty.tools.intellij.it.fixtures.WelcomeFrameFixture; @@ -43,6 +42,7 @@ import static com.intellij.remoterobot.search.locators.Locators.byXpath; import static java.awt.event.KeyEvent.*; import static org.junit.jupiter.api.Assertions.fail; +import static io.openliberty.tools.intellij.it.Utils.ItConstants.*; /** * UI helper function. @@ -762,7 +762,7 @@ public static void closeFileEditorTab(RemoteRobot remoteRobot, String editorTabN */ public static void closeAllEditorTabs(RemoteRobot remoteRobot) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); - projectFrame.clickOnMainMenuWithActions(remoteRobot, "Window", "Editor Tabs", ItConstants.CLOSE_ALL_TABS); + projectFrame.clickOnMainMenuWithActions(remoteRobot, "Window", "Editor Tabs", CLOSE_ALL_TABS); } /** @@ -830,7 +830,7 @@ public static void hoverInAppServerCfgFile(RemoteRobot remoteRobot, String hover // Find the target text on the editor and move the move to it. editorNew.findText(contains(hoverTarget)).moveMouse(); // clear and "lightbulb" icons? - if (!hoverFile.equals(ItConstants.SERVER_XML)) { + if (!hoverFile.equals(SERVER_XML)) { keyboard.hotKey(VK_ESCAPE); } @@ -1208,7 +1208,7 @@ else if (fileName.equals("bootstrap.properties")) { public static void insertStanzaInAppServerXML(RemoteRobot remoteRobot, String stanzaSnippet, int line, int col, InsertionType type, boolean completeWithPopup) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(30)); - clickOnFileTab(remoteRobot, ItConstants.SERVER_XML); + clickOnFileTab(remoteRobot, SERVER_XML); Locator locator = byXpath("//div[@class='EditorCompositePanel']//div[@class='EditorComponentImpl']"); EditorFixture editorNew = remoteRobot.find(EditorFixture.class, locator, Duration.ofSeconds(20)); editorNew.click(); @@ -1748,7 +1748,7 @@ public static void runActionFromSearchEverywherePanel(RemoteRobot remoteRobot, S * If we are not specify a condition check for "Close All Tabs" action when no file tabs are open, the runActionFromSearchEverywherePanel method * will throw a RuntimeException, causing the test to fail. */ - if (error != null && !action.equals(ItConstants.CLOSE_ALL_TABS)) { + if (error != null && !action.equals(CLOSE_ALL_TABS)) { throw new RuntimeException("Failed to run the " + action + " action using the search everywhere option", error); } } @@ -2678,7 +2678,7 @@ public static void findWelcomeFrame(RemoteRobot remoteRobot) { UIBotTestUtils.closeAllEditorTabs(remoteRobot); } else { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, ItConstants.CLOSE_ALL_TABS, 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, CLOSE_ALL_TABS, 3); } UIBotTestUtils.closeProjectView(remoteRobot); UIBotTestUtils.closeProjectFrame(remoteRobot);