From 8279ad7aa31253a0251d51b9d9a5d7948bb4a63e Mon Sep 17 00:00:00 2001 From: vaisakhkannan Date: Thu, 19 Dec 2024 17:41:21 +0530 Subject: [PATCH 1/6] Added 4 more tests to cover completion suggestions in different case letters --- .../it/SingleModLibertyLSTestCommon.java | 116 ++++++++++++++++++ .../tools/intellij/it/UIBotTestUtils.java | 33 +++-- 2 files changed, 139 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 48e9b2d59..98be5db1e 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -189,6 +189,63 @@ public void testInsertLibertyConfigIntoServerEnv() { } } + /** + * Tests Liberty-LS support in server.env for + * providing completion suggestions in lowercase letters. + */ + @Test + @Video + public void testInsertLibertyConfigIntoServerEnvForLowerCase() { + String envCfgSnippetLowerCase = "wlp_logging_con"; + String envCfgNameChooserSnippet = "FORMAT"; + String envCfgValueSnippet = "sim"; + String expectedServerEnvString = "WLP_LOGGING_CONSOLE_FORMAT=SIMPLE"; + + // get focus on server.env tab prior to copy + UIBotTestUtils.clickOnFileTab(remoteRobot, "server.env"); + + // Save the current server.env content. + UIBotTestUtils.copyWindowContent(remoteRobot); + + try { + UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, "server.env", envCfgSnippetLowerCase, envCfgNameChooserSnippet, envCfgValueSnippet, true); + Path pathToServerEnv = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", "server.env"); + TestUtils.validateStringInFile(pathToServerEnv.toString(), expectedServerEnvString); + } finally { + // Replace server.xml content with the original content + UIBotTestUtils.pasteOnActiveWindow(remoteRobot); + } + } + + /** + * Tests Liberty-LS support in server.env for providing completion + * suggestions in a mix of uppercase and lowercase letters. + */ + @Test + @Video + public void testInsertLibertyConfigIntoServerEnvForMixOfCases() { + String envCfgSnippetMixCase = "wLp_LOgginG_coN"; + String envCfgNameChooserSnippet = "FORMAT"; + String envCfgValueSnippet = "sIM"; + String expectedServerEnvString = "WLP_LOGGING_CONSOLE_FORMAT=SIMPLE"; + + // get focus on server.env tab prior to copy + UIBotTestUtils.clickOnFileTab(remoteRobot, "server.env"); + + // Save the current server.env content. + UIBotTestUtils.copyWindowContent(remoteRobot); + + try { + UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, "server.env", envCfgSnippetMixCase, envCfgNameChooserSnippet, envCfgValueSnippet, true); + Path pathToServerEnv = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", "server.env"); + TestUtils.validateStringInFile(pathToServerEnv.toString(), expectedServerEnvString); + } finally { + // Replace server.xml content with the original content + UIBotTestUtils.pasteOnActiveWindow(remoteRobot); + } + + } + /** * Tests liberty-ls type ahead support in bootstrap.properties for a * Liberty Server Configuration booststrap.properties entry @@ -215,6 +272,65 @@ public void testInsertLibertyConfigIntoBootstrapProps() { // Replace server.xml content with the original content UIBotTestUtils.pasteOnActiveWindow(remoteRobot); } + + } + + /** + * Tests Liberty-LS support in bootstrap.properties for + * providing completion suggestions in capital case letters. + */ + @Test + @Video + public void testInsertLibertyConfigIntoBootstrapPropsForCapitalCase() { + String configNameSnippetUpperCase = "COM.IBM.WS.LOGGING.CON"; + String configNameChooserSnippet = "format"; + String configValueSnippet = "tba"; + String expectedBootstrapPropsString = "com.ibm.ws.logging.console.format=TBASIC"; + + // get focus on bootstrap.properties tab prior to copy + UIBotTestUtils.clickOnFileTab(remoteRobot, "bootstrap.properties"); + + // Save the current bootstrap.properties content. + UIBotTestUtils.copyWindowContent(remoteRobot); + + try { + UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, "bootstrap.properties", configNameSnippetUpperCase, configNameChooserSnippet, configValueSnippet, true); + Path pathToBootstrapProps = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", "bootstrap.properties"); + TestUtils.validateStringInFile(pathToBootstrapProps.toString(), expectedBootstrapPropsString); + } finally { + // Replace server.xml content with the original content + UIBotTestUtils.pasteOnActiveWindow(remoteRobot); + } + + } + + /** + * Tests Liberty-LS support in bootstrap.properties for providing completion + * suggestions in a mix of uppercase and lowercase letters. + */ + @Test + @Video + public void testInsertLibertyConfigIntoBootstrapPropsForMixOfCases() { + String configNameSnippetMixCase = "CoM.Ibm.wS.LoGginG.cON"; + String configNameChooserSnippet = "format"; + String configValueSnippet = "Tba"; + String expectedBootstrapPropsString = "com.ibm.ws.logging.console.format=TBASIC"; + + // get focus on bootstrap.properties tab prior to copy + UIBotTestUtils.clickOnFileTab(remoteRobot, "bootstrap.properties"); + + // Save the current bootstrap.properties content. + UIBotTestUtils.copyWindowContent(remoteRobot); + + try { + UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, "bootstrap.properties", configNameSnippetMixCase, configNameChooserSnippet, configValueSnippet, true); + Path pathToBootstrapProps = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", "bootstrap.properties"); + TestUtils.validateStringInFile(pathToBootstrapProps.toString(), expectedBootstrapPropsString); + } finally { + // Replace server.xml content with the original content + UIBotTestUtils.pasteOnActiveWindow(remoteRobot); + } + } /** 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 23bf08fce..5e964db70 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java @@ -1096,18 +1096,30 @@ public static void insertConfigIntoMPConfigPropertiesFile(RemoteRobot remoteRobo * * @param remoteRobot The RemoteRobot instance. * @param fileName The string path to the config file - * @param configNameSnippet the portion of the name to type + * @param configNameSnippetCaseSpecific the portion of the name to type * @param configNameChooserSnippet the portion of the name to use for selecting from popup menu * @param configValueSnippet the value to type into keyboard - could be a snippet or a whole word * @param completeWithPopup use popup to complete value selection or type in an entire provided value string */ - public static void insertConfigIntoConfigFile(RemoteRobot remoteRobot, String fileName, String configNameSnippet, String configNameChooserSnippet, String configValueSnippet, boolean completeWithPopup) { + public static void insertConfigIntoConfigFile(RemoteRobot remoteRobot, String fileName, String configNameSnippetCaseSpecific, String configNameChooserSnippet, String configValueSnippet, boolean completeWithPopup) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(30)); clickOnFileTab(remoteRobot, fileName); EditorFixture editorNew = remoteRobot.find(EditorFixture.class, EditorFixture.Companion.getLocator()); Exception error = null; - for (int i = 0; i < 10; i++) { + String configNameSnippet = ""; + if (fileName.equals("server.env")) { + configNameSnippet = configNameSnippetCaseSpecific.toUpperCase(); + } + else if (fileName.equals("bootstrap.properties")) { + configNameSnippet = configNameSnippetCaseSpecific.toLowerCase(); + } + else { + configNameSnippet = configNameSnippetCaseSpecific; + } + String configValueSnippetUpperCase = configValueSnippet.toUpperCase(); + + for (int i = 0; i < 2; i++) { error = null; try { editorNew.click(); @@ -1118,7 +1130,7 @@ public static void insertConfigIntoConfigFile(RemoteRobot remoteRobot, String fi keyboard.hotKey(VK_CONTROL, VK_END); keyboard.enter(); - keyboard.enterText(configNameSnippet); + keyboard.enterText(configNameSnippetCaseSpecific); // After typing it can take 1 or 2s for IntelliJ to render diagnostics etc. Must wait before continuing. TestUtils.sleepAndIgnoreException(5); @@ -1126,11 +1138,12 @@ public static void insertConfigIntoConfigFile(RemoteRobot remoteRobot, String fi // opened as text is typed based on the value of configNameSnippet. Avoid hitting ctrl + space as it has the side effect of selecting // and entry automatically if the completion suggestion windows has one entry only. ComponentFixture namePopupWindow = projectFrame.getLookupList(); + String finalConfigNameSnippet = configNameSnippet; RepeatUtilsKt.waitFor(Duration.ofSeconds(5), Duration.ofSeconds(1), "Waiting for text " + configNameSnippet + " to appear in the completion suggestion pop-up window", "Text " + configNameSnippet + " did not appear in the completion suggestion pop-up window", - () -> namePopupWindow.hasText(configNameSnippet)); + () -> namePopupWindow.hasText(finalConfigNameSnippet)); // now choose the specific item based on the chooser string namePopupWindow.findText(contains(configNameChooserSnippet)).doubleClick(); @@ -1150,11 +1163,11 @@ public static void insertConfigIntoConfigFile(RemoteRobot remoteRobot, String fi ComponentFixture valuePopupWindow = projectFrame.getLookupList(); RepeatUtilsKt.waitFor(Duration.ofSeconds(5), Duration.ofSeconds(1), - "Waiting for text " + configValueSnippet + " to appear in the completion suggestion pop-up window", - "Text " + configValueSnippet + " did not appear in the completion suggestion pop-up window", - () -> valuePopupWindow.hasText(configValueSnippet)); + "Waiting for text " + configValueSnippetUpperCase + " to appear in the completion suggestion pop-up window", + "Text " + configValueSnippetUpperCase + " did not appear in the completion suggestion pop-up window", + () -> valuePopupWindow.hasText(configValueSnippetUpperCase)); - valuePopupWindow.findText(contains(configValueSnippet)).doubleClick(); + valuePopupWindow.findText(contains(configValueSnippetUpperCase)).doubleClick(); } // let the auto-save function of intellij save the file before testing it if (remoteRobot.isMac()) { @@ -1175,7 +1188,7 @@ public static void insertConfigIntoConfigFile(RemoteRobot remoteRobot, String fi // Report the last error if there is one. if (error != null) { - throw new RuntimeException("Unable to insert entry in config file : " + fileName + " using text: " + configNameSnippet, error); + throw new RuntimeException("Unable to insert entry in config file : " + fileName + " using text: " + configNameSnippetCaseSpecific, error); } } From 2d83b211636d28fc5e72aca6ad05ea1cc6255494 Mon Sep 17 00:00:00 2001 From: vaisakhkannan Date: Thu, 19 Dec 2024 17:43:56 +0530 Subject: [PATCH 2/6] Removed unwanted spaces --- .../tools/intellij/it/SingleModLibertyLSTestCommon.java | 9 --------- 1 file changed, 9 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 98be5db1e..0142c6943 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -243,7 +243,6 @@ public void testInsertLibertyConfigIntoServerEnvForMixOfCases() { // Replace server.xml content with the original content UIBotTestUtils.pasteOnActiveWindow(remoteRobot); } - } /** @@ -272,7 +271,6 @@ public void testInsertLibertyConfigIntoBootstrapProps() { // Replace server.xml content with the original content UIBotTestUtils.pasteOnActiveWindow(remoteRobot); } - } /** @@ -301,7 +299,6 @@ public void testInsertLibertyConfigIntoBootstrapPropsForCapitalCase() { // Replace server.xml content with the original content UIBotTestUtils.pasteOnActiveWindow(remoteRobot); } - } /** @@ -330,7 +327,6 @@ public void testInsertLibertyConfigIntoBootstrapPropsForMixOfCases() { // Replace server.xml content with the original content UIBotTestUtils.pasteOnActiveWindow(remoteRobot); } - } /** @@ -402,7 +398,6 @@ public void testDiagnosticInServerXML() { // Replace server.xml content with the original content UIBotTestUtils.pasteOnActiveWindow(remoteRobot); } - } /** @@ -440,8 +435,6 @@ public void testQuickFixInServerXML() { // Replace server.xml content with the original content UIBotTestUtils.pasteOnActiveWindow(remoteRobot, true); } - - } /** @@ -472,7 +465,6 @@ public void testDiagnosticInServerEnv() { // Replace server.xml content with the original content UIBotTestUtils.pasteOnActiveWindow(remoteRobot); } - } /** @@ -503,7 +495,6 @@ public void testDiagnosticInBootstrapProperties() { // Replace server.xml content with the original content UIBotTestUtils.pasteOnActiveWindow(remoteRobot); } - } /** From ecf98a6bec0b0700cff35949102c8c0087ab68b1 Mon Sep 17 00:00:00 2001 From: vaisakhkannan Date: Thu, 19 Dec 2024 17:51:13 +0530 Subject: [PATCH 3/6] back to loop count 10 --- .../java/io/openliberty/tools/intellij/it/UIBotTestUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 5e964db70..b5be3bb18 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java @@ -1119,7 +1119,7 @@ else if (fileName.equals("bootstrap.properties")) { } String configValueSnippetUpperCase = configValueSnippet.toUpperCase(); - for (int i = 0; i < 2; i++) { + for (int i = 0; i < 10; i++) { error = null; try { editorNew.click(); From df384d852eebf1f4f1de39d6ff2ebef21b082747 Mon Sep 17 00:00:00 2001 From: vaisakhkannan Date: Wed, 1 Jan 2025 11:33:17 +0530 Subject: [PATCH 4/6] Addressed review comment and updated header year to 2025 --- .../intellij/it/SingleModLibertyLSTestCommon.java | 2 +- .../tools/intellij/it/UIBotTestUtils.java | 14 +++++++------- 2 files changed, 8 insertions(+), 8 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 0142c6943..3f269d835 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.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/UIBotTestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java index b5be3bb18..55b1e6187 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.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 @@ -1094,12 +1094,12 @@ public static void insertConfigIntoMPConfigPropertiesFile(RemoteRobot remoteRobo * Inserts a configuration name value pair into a config file via text typing * and popup menu completion (if required) * - * @param remoteRobot The RemoteRobot instance. - * @param fileName The string path to the config file - * @param configNameSnippetCaseSpecific the portion of the name to type - * @param configNameChooserSnippet the portion of the name to use for selecting from popup menu - * @param configValueSnippet the value to type into keyboard - could be a snippet or a whole word - * @param completeWithPopup use popup to complete value selection or type in an entire provided value string + * @param remoteRobot The RemoteRobot instance. + * @param fileName The string path to the config file + * @param configNameSnippetCaseSpecific the portion of the name to type + * @param configNameChooserSnippet the portion of the name to use for selecting from popup menu + * @param configValueSnippet the value to type into keyboard - could be a snippet or a whole word + * @param completeWithPopup use popup to complete value selection or type in an entire provided value string */ public static void insertConfigIntoConfigFile(RemoteRobot remoteRobot, String fileName, String configNameSnippetCaseSpecific, String configNameChooserSnippet, String configValueSnippet, boolean completeWithPopup) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(30)); From d4767ea063eaddc3aee17af103bcd31a41dc769f Mon Sep 17 00:00:00 2001 From: vaisakhkannan Date: Wed, 1 Jan 2025 11:40:28 +0530 Subject: [PATCH 5/6] Updated comment and renamed default name method to clear way --- .../intellij/it/SingleModLibertyLSTestCommon.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 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 3f269d835..99449a207 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -163,11 +163,12 @@ public void testInsertLibertyConfigElementIntoServerXML() { /** * Tests liberty-ls type ahead support in server.env for a - * Liberty Server Configuration Stanza + * Liberty Server Configuration Stanza and + * providing completion suggestions in uppercase letters. */ @Test @Video - public void testInsertLibertyConfigIntoServerEnv() { + public void testInsertLibertyConfigIntoServerEnvForCapitalCase() { String envCfgSnippet = "WLP_LOGGING_CON"; String envCfgNameChooserSnippet = "FORMAT"; String envCfgValueSnippet = "SIM"; @@ -247,11 +248,12 @@ public void testInsertLibertyConfigIntoServerEnvForMixOfCases() { /** * Tests liberty-ls type ahead support in bootstrap.properties for a - * Liberty Server Configuration booststrap.properties entry + * Liberty Server Configuration bootstrap.properties entry and + * providing completion suggestions in lowercase letters. */ @Test @Video - public void testInsertLibertyConfigIntoBootstrapProps() { + public void testInsertLibertyConfigIntoBootstrapPropsForLowerCase() { String configNameSnippet = "com.ibm.ws.logging.con"; String configNameChooserSnippet = "format"; String configValueSnippet = "TBA"; From 8e368a387f7beb3813929bd8d8ddd93d9dd4ddd9 Mon Sep 17 00:00:00 2001 From: vaisakhkannan <133869023+vaisakhkannan@users.noreply.github.com> Date: Mon, 6 Jan 2025 09:28:28 +0530 Subject: [PATCH 6/6] Update src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java Co-authored-by: Michael Glavassevich --- .../io/openliberty/tools/intellij/it/UIBotTestUtils.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 55b1e6187..9b45a1a3e 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java @@ -1109,15 +1109,15 @@ public static void insertConfigIntoConfigFile(RemoteRobot remoteRobot, String fi String configNameSnippet = ""; if (fileName.equals("server.env")) { - configNameSnippet = configNameSnippetCaseSpecific.toUpperCase(); + configNameSnippet = configNameSnippetCaseSpecific.toUpperCase(java.util.Locale.ROOT); } else if (fileName.equals("bootstrap.properties")) { - configNameSnippet = configNameSnippetCaseSpecific.toLowerCase(); + configNameSnippet = configNameSnippetCaseSpecific.toLowerCase(java.util.Locale.ROOT); } else { configNameSnippet = configNameSnippetCaseSpecific; } - String configValueSnippetUpperCase = configValueSnippet.toUpperCase(); + String configValueSnippetUpperCase = configValueSnippet.toUpperCase(java.util.Locale.ROOT); for (int i = 0; i < 10; i++) { error = null;