From 33ac4ac1ce421282b9e0b998962fcb798e24487c Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Mon, 23 Dec 2024 16:21:23 +0530 Subject: [PATCH 01/10] Update SingleModLibertyLSTestCommon.java --- .../it/SingleModLibertyLSTestCommon.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) 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..162f3c1d8 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -11,13 +11,17 @@ import com.automation.remarks.junit5.Video; import com.intellij.remoterobot.RemoteRobot; +import com.intellij.remoterobot.fixtures.ComponentFixture; import com.intellij.remoterobot.fixtures.JTreeFixture; +import com.intellij.remoterobot.utils.Keyboard; +import com.intellij.remoterobot.utils.RepeatUtilsKt; import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture; import org.junit.jupiter.api.*; import java.nio.file.Path; import java.nio.file.Paths; import java.time.Duration; +import static java.awt.event.KeyEvent.*; import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitForIgnoringError; @@ -189,6 +193,46 @@ public void testInsertLibertyConfigIntoServerEnv() { } } + /** + Test to Ensure that relevant completion values (e.g., SIMPLE, ADVANCED) + * are displayed and prioritized at the top of the list. + */ + @Test + @Video + public void testCompletionValuesInServerEnv() { + String envCfgKeySnippet = "WLP_LOGGING_CONSOLE_FORMAT="; // Property key + String[] expectedCompletionValues = {"DEV", "JSON", "SIMPLE", "TBASIC"}; // Expected completion values + + Keyboard keyboard = new Keyboard(remoteRobot); + ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(30)); + + // get focus on server.env tab prior to copy + UIBotTestUtils.clickOnFileTab(remoteRobot, "server.env"); + + // Delete the current server.env content. + UIBotTestUtils.clearWindowContent(remoteRobot); + + // Type the property key + keyboard.enterText(envCfgKeySnippet); + + // Trigger code completion + keyboard.hotKey(VK_CONTROL, VK_SPACE); + + // Wait for the completion suggestion pop-up window to display the expected values + ComponentFixture completionPopupWindow = projectFrame.getLookupList(); + + // Check if all expected completion values are available in the pop-up + for (String expectedValue : expectedCompletionValues) { + // Wait for each expected value to appear in the completion suggestion pop-up window + RepeatUtilsKt.waitFor(Duration.ofSeconds(5), + Duration.ofSeconds(1), + "Waiting for text " + expectedValue + " to appear in the completion suggestion pop-up window", + "Text " + expectedValue + " did not appear in the completion suggestion pop-up window", + () -> completionPopupWindow.hasText(expectedValue)); + + } + } + /** * Tests liberty-ls type ahead support in bootstrap.properties for a * Liberty Server Configuration booststrap.properties entry From edf52af094faeeaaaa2effc78cb2e8b97f3b6181 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Wed, 1 Jan 2025 18:25:26 +0530 Subject: [PATCH 02/10] UI Test --- .../it/SingleModLibertyLSTestCommon.java | 34 ++++++++++--------- .../it/fixtures/ProjectFrameFixture.java | 21 ++++++++++++ 2 files changed, 39 insertions(+), 16 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 162f3c1d8..c84d4e566 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -11,10 +11,8 @@ import com.automation.remarks.junit5.Video; import com.intellij.remoterobot.RemoteRobot; -import com.intellij.remoterobot.fixtures.ComponentFixture; import com.intellij.remoterobot.fixtures.JTreeFixture; import com.intellij.remoterobot.utils.Keyboard; -import com.intellij.remoterobot.utils.RepeatUtilsKt; import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture; import org.junit.jupiter.api.*; @@ -204,11 +202,13 @@ public void testCompletionValuesInServerEnv() { String[] expectedCompletionValues = {"DEV", "JSON", "SIMPLE", "TBASIC"}; // Expected completion values Keyboard keyboard = new Keyboard(remoteRobot); - ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(30)); - // get focus on server.env tab prior to copy + // Get focus on server.env tab prior to copy UIBotTestUtils.clickOnFileTab(remoteRobot, "server.env"); + // Save the current server.env content. + UIBotTestUtils.copyWindowContent(remoteRobot); + // Delete the current server.env content. UIBotTestUtils.clearWindowContent(remoteRobot); @@ -218,18 +218,20 @@ public void testCompletionValuesInServerEnv() { // Trigger code completion keyboard.hotKey(VK_CONTROL, VK_SPACE); - // Wait for the completion suggestion pop-up window to display the expected values - ComponentFixture completionPopupWindow = projectFrame.getLookupList(); - - // Check if all expected completion values are available in the pop-up - for (String expectedValue : expectedCompletionValues) { - // Wait for each expected value to appear in the completion suggestion pop-up window - RepeatUtilsKt.waitFor(Duration.ofSeconds(5), - Duration.ofSeconds(1), - "Waiting for text " + expectedValue + " to appear in the completion suggestion pop-up window", - "Text " + expectedValue + " did not appear in the completion suggestion pop-up window", - () -> completionPopupWindow.hasText(expectedValue)); - + try { + // Check if the expected value appears in the top of the completion pop-up + for (String expectedValue : expectedCompletionValues) { + int position = ProjectFrameFixture.findTextPosition(remoteRobot, expectedValue); + + // Verify that the position is within the top 4 positions + Assertions.assertTrue(position != -1, + "Text '" + expectedValue + "' did not appear in the completion suggestion pop-up window."); + Assertions.assertTrue(position >= 0 && position <= 3, + "Text '" + expectedValue + "' is at position " + position + " and is not in the top 4."); + } + } finally { + // Replace server.env content with the original content + UIBotTestUtils.pasteOnActiveWindow(remoteRobot); } } diff --git a/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java b/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java index 7e3e8e442..e4252948c 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java +++ b/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java @@ -12,6 +12,7 @@ import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.data.RemoteComponent; import com.intellij.remoterobot.fixtures.*; +import com.intellij.remoterobot.fixtures.dataExtractor.RemoteText; import com.intellij.remoterobot.search.locators.Locator; import com.intellij.remoterobot.utils.RepeatUtilsKt; import com.intellij.remoterobot.utils.WaitForConditionTimeoutException; @@ -329,6 +330,26 @@ public ContainerFixture getLookupList() { return find(ContainerFixture.class, byXpath("//div[@class='HeavyWeightWindow']//div[@class='LookupList']"), Duration.ofSeconds(10)); } + /** + * Returns the position of the specified text within the completion suggestion pop-up window. + * + * @param text The text to search for in the suggestion list. + */ + public static int findTextPosition(RemoteRobot remoteRobot, String text) { + ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); + + // Wait for the completion suggestion pop-up window to display the expected values + ComponentFixture completionPopupWindow = projectFrame.getLookupList(); + + List allData = completionPopupWindow.getData().getAll(); + for (int i = 0; i < allData.size(); i++) { + if (allData.get(i).getText().equals(text)) { + return i; + } + } + return -1; // Return -1 if the text is not found + } + /** * Returns the ContainerFixture object associated with the MyList class in a HeavyWeightWindow (List window). * From 7efcfa6204225c8f02f116396e2a8e49a02ba929 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Wed, 1 Jan 2025 19:03:18 +0530 Subject: [PATCH 03/10] server.env test --- .../it/SingleModLibertyLSTestCommon.java | 10 +++++++--- .../it/fixtures/ProjectFrameFixture.java | 20 ++++++++++--------- 2 files changed, 18 insertions(+), 12 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 c84d4e566..9b4c07049 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -19,6 +19,8 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.time.Duration; +import java.util.Map; + import static java.awt.event.KeyEvent.*; import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitForIgnoringError; @@ -220,11 +222,13 @@ public void testCompletionValuesInServerEnv() { try { // Check if the expected value appears in the top of the completion pop-up - for (String expectedValue : expectedCompletionValues) { - int position = ProjectFrameFixture.findTextPosition(remoteRobot, expectedValue); + Map textPositions = ProjectFrameFixture.findAllTextPositions(remoteRobot); + // Verify each expected value's position + for (String expectedValue : expectedCompletionValues) { + Integer position = textPositions.get(expectedValue); // Verify that the position is within the top 4 positions - Assertions.assertTrue(position != -1, + Assertions.assertNotNull(position, "Text '" + expectedValue + "' did not appear in the completion suggestion pop-up window."); Assertions.assertTrue(position >= 0 && position <= 3, "Text '" + expectedValue + "' is at position " + position + " and is not in the top 4."); diff --git a/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java b/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java index e4252948c..da893ecd0 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java +++ b/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java @@ -21,7 +21,9 @@ import org.jetbrains.annotations.NotNull; import java.time.Duration; +import java.util.HashMap; import java.util.List; +import java.util.Map; import static com.intellij.remoterobot.search.locators.Locators.byXpath; @@ -331,23 +333,23 @@ public ContainerFixture getLookupList() { } /** - * Returns the position of the specified text within the completion suggestion pop-up window. + * Retrieves a map of text and their positions from the completion suggestion pop-up in IntelliJ IDEA. * - * @param text The text to search for in the suggestion list. + * @return a map where keys are suggestion texts and values are their positions. */ - public static int findTextPosition(RemoteRobot remoteRobot, String text) { - ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); + public static Map findAllTextPositions(RemoteRobot remoteRobot) { + + ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); // Wait for the completion suggestion pop-up window to display the expected values ComponentFixture completionPopupWindow = projectFrame.getLookupList(); - List allData = completionPopupWindow.getData().getAll(); + Map textPositionMap = new HashMap<>(); + // Populate the map with text and their respective positions for (int i = 0; i < allData.size(); i++) { - if (allData.get(i).getText().equals(text)) { - return i; - } + textPositionMap.put(allData.get(i).getText(), i); } - return -1; // Return -1 if the text is not found + return textPositionMap; // Return the map with all text positions } /** From b3aed0c8e2b8f913e2d280ee7314719a81184dfb Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Wed, 1 Jan 2025 19:20:40 +0530 Subject: [PATCH 04/10] bootstrap.properties file test added --- .../it/SingleModLibertyLSTestCommon.java | 50 ++++++++++++++++++- 1 file changed, 48 insertions(+), 2 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 9b4c07049..5fad2a8e4 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -195,7 +195,7 @@ public void testInsertLibertyConfigIntoServerEnv() { /** Test to Ensure that relevant completion values (e.g., SIMPLE, ADVANCED) - * are displayed and prioritized at the top of the list. + * are displayed and prioritized at the top of the list in server.env. */ @Test @Video @@ -227,7 +227,7 @@ public void testCompletionValuesInServerEnv() { // Verify each expected value's position for (String expectedValue : expectedCompletionValues) { Integer position = textPositions.get(expectedValue); - // Verify that the position is within the top 4 positions + // Verify that the expected value is within the top 4 positions Assertions.assertNotNull(position, "Text '" + expectedValue + "' did not appear in the completion suggestion pop-up window."); Assertions.assertTrue(position >= 0 && position <= 3, @@ -239,6 +239,52 @@ public void testCompletionValuesInServerEnv() { } } + /** + Test to Ensure that relevant completion values (e.g., AUDIT, ERROR) + * are displayed and prioritized at the top of the list in bootstrap.properties. + */ + @Test + @Video + public void testCompletionValuesInBootstrapProperties() { + String envCfgKeySnippet = "com.ibm.ws.logging.console.log.level="; // Property key + String[] expectedCompletionValues = {"AUDIT", "ERROR", "INFO", "OFF", "WARNING"}; // Expected completion values + + Keyboard keyboard = new Keyboard(remoteRobot); + + // get focus on bootstrap.properties tab prior to copy + UIBotTestUtils.clickOnFileTab(remoteRobot, "bootstrap.properties"); + + // Save the current bootstrap.properties content. + UIBotTestUtils.copyWindowContent(remoteRobot); + + // Delete the current bootstrap.properties content. + UIBotTestUtils.clearWindowContent(remoteRobot); + + // Type the property key + keyboard.enterText(envCfgKeySnippet); + + // Trigger code completion + keyboard.hotKey(VK_CONTROL, VK_SPACE); + + try { + // Check if the expected value appears in the top of the completion pop-up + Map textPositions = ProjectFrameFixture.findAllTextPositions(remoteRobot); + + // Verify each expected value's position + for (String expectedValue : expectedCompletionValues) { + Integer position = textPositions.get(expectedValue); + // Verify that the expected value is within the top 5 positions + Assertions.assertNotNull(position, + "Text '" + expectedValue + "' did not appear in the completion suggestion pop-up window."); + Assertions.assertTrue(position >= 0 && position <= 4, + "Text '" + expectedValue + "' is at position " + position + " and is not in the top 5."); + } + } finally { + // Replace bootstrap.properties 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 From 176e941fb62b5afde316470e1d0c43fff26a3901 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Thu, 2 Jan 2025 11:39:07 +0530 Subject: [PATCH 05/10] Copyright year changed --- .../tools/intellij/it/SingleModLibertyLSTestCommon.java | 2 +- .../tools/intellij/it/fixtures/ProjectFrameFixture.java | 2 +- 2 files changed, 2 insertions(+), 2 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 5fad2a8e4..4927bd0db 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/fixtures/ProjectFrameFixture.java b/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java index da893ecd0..45f40f29d 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java +++ b/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.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 26950625368cc8f115176a7afc158e2cfe42b2e3 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Tue, 7 Jan 2025 14:14:13 +0530 Subject: [PATCH 06/10] Update SingleModLibertyLSTestCommon.java --- .../tools/intellij/it/SingleModLibertyLSTestCommon.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 4927bd0db..08c26213e 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -21,7 +21,8 @@ import java.time.Duration; import java.util.Map; -import static java.awt.event.KeyEvent.*; +import static java.awt.event.KeyEvent.VK_CONTROL; +import static java.awt.event.KeyEvent.VK_SPACE; import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitForIgnoringError; From c8d82d8ba01af5c0880dfa73e88e9435124097ed Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Fri, 10 Jan 2025 11:09:26 +0530 Subject: [PATCH 07/10] Avoided code duplication --- .../it/SingleModLibertyLSTestCommon.java | 127 +++++++----------- 1 file changed, 50 insertions(+), 77 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 08c26213e..e553c7028 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -195,97 +195,26 @@ public void testInsertLibertyConfigIntoServerEnv() { } /** - Test to Ensure that relevant completion values (e.g., SIMPLE, ADVANCED) + * Test to Ensure that relevant completion values (e.g., SIMPLE, ADVANCED) * are displayed and prioritized at the top of the list in server.env. */ @Test @Video public void testCompletionValuesInServerEnv() { - String envCfgKeySnippet = "WLP_LOGGING_CONSOLE_FORMAT="; // Property key - String[] expectedCompletionValues = {"DEV", "JSON", "SIMPLE", "TBASIC"}; // Expected completion values - - Keyboard keyboard = new Keyboard(remoteRobot); - - // Get focus on server.env tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, "server.env"); - - // Save the current server.env content. - UIBotTestUtils.copyWindowContent(remoteRobot); - - // Delete the current server.env content. - UIBotTestUtils.clearWindowContent(remoteRobot); - - // Type the property key - keyboard.enterText(envCfgKeySnippet); - - // Trigger code completion - keyboard.hotKey(VK_CONTROL, VK_SPACE); - - try { - // Check if the expected value appears in the top of the completion pop-up - Map textPositions = ProjectFrameFixture.findAllTextPositions(remoteRobot); - - // Verify each expected value's position - for (String expectedValue : expectedCompletionValues) { - Integer position = textPositions.get(expectedValue); - // Verify that the expected value is within the top 4 positions - Assertions.assertNotNull(position, - "Text '" + expectedValue + "' did not appear in the completion suggestion pop-up window."); - Assertions.assertTrue(position >= 0 && position <= 3, - "Text '" + expectedValue + "' is at position " + position + " and is not in the top 4."); - } - } finally { - // Replace server.env content with the original content - UIBotTestUtils.pasteOnActiveWindow(remoteRobot); - } + runCompletionTest("server.env", "WLP_LOGGING_CONSOLE_FORMAT=", new String[]{"DEV", "JSON", "SIMPLE", "TBASIC"}, 4); } /** - Test to Ensure that relevant completion values (e.g., AUDIT, ERROR) - * are displayed and prioritized at the top of the list in bootstrap.properties. + * Test to Ensure that relevant completion values (e.g., AUDIT, ERROR) + * are displayed and prioritized at the top of the list in bootstrap.properties */ @Test @Video public void testCompletionValuesInBootstrapProperties() { - String envCfgKeySnippet = "com.ibm.ws.logging.console.log.level="; // Property key - String[] expectedCompletionValues = {"AUDIT", "ERROR", "INFO", "OFF", "WARNING"}; // Expected completion values - - Keyboard keyboard = new Keyboard(remoteRobot); - - // get focus on bootstrap.properties tab prior to copy - UIBotTestUtils.clickOnFileTab(remoteRobot, "bootstrap.properties"); - - // Save the current bootstrap.properties content. - UIBotTestUtils.copyWindowContent(remoteRobot); - - // Delete the current bootstrap.properties content. - UIBotTestUtils.clearWindowContent(remoteRobot); - - // Type the property key - keyboard.enterText(envCfgKeySnippet); - - // Trigger code completion - keyboard.hotKey(VK_CONTROL, VK_SPACE); - - try { - // Check if the expected value appears in the top of the completion pop-up - Map textPositions = ProjectFrameFixture.findAllTextPositions(remoteRobot); - - // Verify each expected value's position - for (String expectedValue : expectedCompletionValues) { - Integer position = textPositions.get(expectedValue); - // Verify that the expected value is within the top 5 positions - Assertions.assertNotNull(position, - "Text '" + expectedValue + "' did not appear in the completion suggestion pop-up window."); - Assertions.assertTrue(position >= 0 && position <= 4, - "Text '" + expectedValue + "' is at position " + position + " and is not in the top 5."); - } - } finally { - // Replace bootstrap.properties content with the original content - UIBotTestUtils.pasteOnActiveWindow(remoteRobot); - } + runCompletionTest("bootstrap.properties", "com.ibm.ws.logging.console.log.level=", new String[]{"AUDIT", "ERROR", "INFO", "OFF", "WARNING"}, 5); } + /** * Tests liberty-ls type ahead support in bootstrap.properties for a * Liberty Server Configuration booststrap.properties entry @@ -487,6 +416,50 @@ public void testDiagnosticInBootstrapProperties() { } + /** + * Helper method to test completion values in a specified file. + * + * @param fileName the name of the file to focus on + * @param propertyKeySnippet the property key snippet to type + * @param expectedCompletionValues the expected completion values + * @param maxPosition the maximum position for the completion values + */ + public void runCompletionTest(String fileName, String propertyKeySnippet, String[] expectedCompletionValues, int maxPosition) { + Keyboard keyboard = new Keyboard(remoteRobot); + + // Get focus on the specified file tab prior to copy + UIBotTestUtils.clickOnFileTab(remoteRobot, fileName); + + // Save the current file content + UIBotTestUtils.copyWindowContent(remoteRobot); + + // Delete the current file content + UIBotTestUtils.clearWindowContent(remoteRobot); + + // Type the property key + keyboard.enterText(propertyKeySnippet); + + // Trigger code completion + keyboard.hotKey(VK_CONTROL, VK_SPACE); + + try { + // Check if the expected value appears in the top of the completion pop-up + Map textPositions = ProjectFrameFixture.findAllTextPositions(remoteRobot); + + // Verify each expected value's position + for (String expectedValue : expectedCompletionValues) { + Integer position = textPositions.get(expectedValue); + Assertions.assertNotNull(position, + "Text '" + expectedValue + "' did not appear in the completion suggestion pop-up window."); + Assertions.assertTrue(position >= 0 && position < maxPosition, + "Text '" + expectedValue + "' is at position " + position + " and is not in the top " + maxPosition + "."); + } + } finally { + // Replace the file content with the original content + UIBotTestUtils.pasteOnActiveWindow(remoteRobot); + } + } + /** * Prepares the environment to run the tests. * From bd54cfd736631e2ae41eb0676ce00d7e2acdd255 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Fri, 10 Jan 2025 11:14:44 +0530 Subject: [PATCH 08/10] Update SingleModLibertyLSTestCommon.java --- .../it/SingleModLibertyLSTestCommon.java | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) 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 99449a207..9b6255433 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -12,12 +12,17 @@ import com.automation.remarks.junit5.Video; import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.fixtures.JTreeFixture; +import com.intellij.remoterobot.utils.Keyboard; import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture; import org.junit.jupiter.api.*; import java.nio.file.Path; import java.nio.file.Paths; import java.time.Duration; +import java.util.Map; + +import static java.awt.event.KeyEvent.VK_CONTROL; +import static java.awt.event.KeyEvent.VK_SPACE; import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitForIgnoringError; @@ -331,6 +336,26 @@ public void testInsertLibertyConfigIntoBootstrapPropsForMixOfCases() { } } + /** + * Test to Ensure that relevant completion values (e.g., SIMPLE, ADVANCED) + * are displayed and prioritized at the top of the list in server.env. + */ + @Test + @Video + public void testCompletionValuesInServerEnv() { + runCompletionTest("server.env", "WLP_LOGGING_CONSOLE_FORMAT=", new String[]{"DEV", "JSON", "SIMPLE", "TBASIC"}, 4); + } + + /** + * Test to Ensure that relevant completion values (e.g., AUDIT, ERROR) + * are displayed and prioritized at the top of the list in bootstrap.properties + */ + @Test + @Video + public void testCompletionValuesInBootstrapProperties() { + runCompletionTest("bootstrap.properties", "com.ibm.ws.logging.console.log.level=", new String[]{"AUDIT", "ERROR", "INFO", "OFF", "WARNING"}, 5); + } + /** * Tests liberty-ls Hover support in server.env for a * Liberty Server Config setting @@ -499,6 +524,50 @@ public void testDiagnosticInBootstrapProperties() { } } + /** + * Helper method to test completion values in a specified file. + * + * @param fileName the name of the file to focus on + * @param propertyKeySnippet the property key snippet to type + * @param expectedCompletionValues the expected completion values + * @param maxPosition the maximum position for the completion values + */ + public void runCompletionTest(String fileName, String propertyKeySnippet, String[] expectedCompletionValues, int maxPosition) { + Keyboard keyboard = new Keyboard(remoteRobot); + + // Get focus on the specified file tab prior to copy + UIBotTestUtils.clickOnFileTab(remoteRobot, fileName); + + // Save the current file content + UIBotTestUtils.copyWindowContent(remoteRobot); + + // Delete the current file content + UIBotTestUtils.clearWindowContent(remoteRobot); + + // Type the property key + keyboard.enterText(propertyKeySnippet); + + // Trigger code completion + keyboard.hotKey(VK_CONTROL, VK_SPACE); + + try { + // Check if the expected value appears in the top of the completion pop-up + Map textPositions = ProjectFrameFixture.findAllTextPositions(remoteRobot); + + // Verify each expected value's position + for (String expectedValue : expectedCompletionValues) { + Integer position = textPositions.get(expectedValue); + Assertions.assertNotNull(position, + "Text '" + expectedValue + "' did not appear in the completion suggestion pop-up window."); + Assertions.assertTrue(position >= 0 && position < maxPosition, + "Text '" + expectedValue + "' is at position " + position + " and is not in the top " + maxPosition + "."); + } + } finally { + // Replace the file content with the original content + UIBotTestUtils.pasteOnActiveWindow(remoteRobot); + } + } + /** * Prepares the environment to run the tests. * From 0c5744873cd68a802d9d927edf192961dc59b4a3 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Fri, 10 Jan 2025 13:01:59 +0530 Subject: [PATCH 09/10] alignment corrected --- .../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 9b6255433..09b883dc3 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -527,10 +527,10 @@ public void testDiagnosticInBootstrapProperties() { /** * Helper method to test completion values in a specified file. * - * @param fileName the name of the file to focus on - * @param propertyKeySnippet the property key snippet to type + * @param fileName the name of the file to focus on + * @param propertyKeySnippet the property key snippet to type * @param expectedCompletionValues the expected completion values - * @param maxPosition the maximum position for the completion values + * @param maxPosition the maximum position for the completion values */ public void runCompletionTest(String fileName, String propertyKeySnippet, String[] expectedCompletionValues, int maxPosition) { Keyboard keyboard = new Keyboard(remoteRobot); From 526dad58e7fad1d789864b61aaea20c81ba00d3d Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi Date: Fri, 10 Jan 2025 13:06:34 +0530 Subject: [PATCH 10/10] changed runCompletionTest to private --- .../tools/intellij/it/SingleModLibertyLSTestCommon.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 09b883dc3..9e2a0833b 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -532,7 +532,7 @@ public void testDiagnosticInBootstrapProperties() { * @param expectedCompletionValues the expected completion values * @param maxPosition the maximum position for the completion values */ - public void runCompletionTest(String fileName, String propertyKeySnippet, String[] expectedCompletionValues, int maxPosition) { + private void runCompletionTest(String fileName, String propertyKeySnippet, String[] expectedCompletionValues, int maxPosition) { Keyboard keyboard = new Keyboard(remoteRobot); // Get focus on the specified file tab prior to copy