From bc79157000fa26134afae6ca049b031fdba6faa9 Mon Sep 17 00:00:00 2001 From: vaisakhkannan Date: Thu, 16 Jan 2025 17:54:02 +0530 Subject: [PATCH] Added test to support multiple projects --- .../it/GradleSingleModMPProjectTest.java | 3 +- .../it/GradleSingleModMPSIDProjectTest.java | 3 +- .../it/MavenMPMultipleProjectTest.java | 138 +++++++++++++++ .../it/MavenSingleModMPProjectTest.java | 3 +- .../it/MavenSingleModMPSIDProjectTest.java | 3 +- .../it/SingleModLibertyLSTestCommon.java | 4 +- .../intellij/it/SingleModMPLSTestCommon.java | 4 +- .../it/SingleModMPProjectTestCommon.java | 158 +++++++++++++----- .../it/SingleModNLTRestProjectTestCommon.java | 10 +- .../tools/intellij/it/UIBotTestUtils.java | 63 ++++--- 10 files changed, 310 insertions(+), 79 deletions(-) create mode 100644 src/test/java/io/openliberty/tools/intellij/it/MavenMPMultipleProjectTest.java diff --git a/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPProjectTest.java b/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPProjectTest.java index d16c780f4..f117d906a 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPProjectTest.java +++ b/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPProjectTest.java @@ -32,7 +32,7 @@ public class GradleSingleModMPProjectTest extends SingleModMPProjectTestCommon { */ @BeforeAll public static void setup() { - prepareEnv(PROJECTS_PATH, SM_MP_PROJECT_NAME); + prepareEnv(PROJECTS_PATH, SM_MP_PROJECT_NAME, false); } GradleSingleModMPProjectTest() { @@ -48,5 +48,6 @@ public static void setup() { setBuildFileOpenCommand("Liberty: View Gradle config"); setStartParams("--hotTests"); setStartParamsDebugPort("--libertyDebugPort=9876"); + setProjectTypeIsMultiple(false); } } \ No newline at end of file diff --git a/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPSIDProjectTest.java b/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPSIDProjectTest.java index 65a4e30e5..5735ba5ea 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPSIDProjectTest.java +++ b/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPSIDProjectTest.java @@ -71,7 +71,7 @@ public static void setup() { Files.move(projectDirPath, projectDirNewPath, StandardCopyOption.REPLACE_EXISTING); // Prepare the environment with the new project path and name - prepareEnv(PROJECTS_PATH_NEW, SM_MP_PROJECT_NAME_NEW); + prepareEnv(PROJECTS_PATH_NEW, SM_MP_PROJECT_NAME_NEW, false); } catch (IOException e) { System.err.println("Setup failed: " + e.getMessage()); @@ -106,5 +106,6 @@ public static void cleanup() { setBuildFileOpenCommand("Liberty: View Gradle config"); setStartParams("--hotTests"); setStartParamsDebugPort("--libertyDebugPort=9876"); + setProjectTypeIsMultiple(false); } } \ No newline at end of file diff --git a/src/test/java/io/openliberty/tools/intellij/it/MavenMPMultipleProjectTest.java b/src/test/java/io/openliberty/tools/intellij/it/MavenMPMultipleProjectTest.java new file mode 100644 index 000000000..13506713c --- /dev/null +++ b/src/test/java/io/openliberty/tools/intellij/it/MavenMPMultipleProjectTest.java @@ -0,0 +1,138 @@ +/******************************************************************************* + * 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; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; + +/** + * Tests Liberty Tools actions using a single module MicroProfile Gradle project with space in directory and name. + */ +public class MavenMPMultipleProjectTest extends SingleModMPProjectTestCommon { + + /** + * Single module Microprofile project name. + */ + private static final String SM_MP_PROJECT_NAME = "singleModMavenMP"; + + private static final String MAVEN_MULTIPLE_PROJECTS_PATH = Paths.get("src", "test", "resources", "projects", "multiple-project", "singleModMavenMP").toAbsolutePath().toString(); + + private static final String MULTIPLE_PROJECTS_PATH = Paths.get("src", "test", "resources", "projects", "multiple-project").toAbsolutePath().toString(); + private static final String MULTIPLE_PROJECTS_PATH_PARENT = Paths.get("src", "test", "resources", "projects").toAbsolutePath().toString(); + + private static final String GRADLE_PROJECTS_PATH = Paths.get("src", "test", "resources", "projects", "gradle", "singleModGradleMP").toAbsolutePath().toString(); + + private static final String MAVEN_PROJECTS_PATH = Paths.get("src", "test", "resources", "projects", "maven", "singleModMavenMP").toAbsolutePath().toString(); + + private static final String GRADLE_MULTIPLE_PROJECTS_PATH = Paths.get("src", "test", "resources", "projects", "multiple-project", "singleModGradleMP").toAbsolutePath().toString(); + + /** + * The paths to the integration test reports. The first is used when maven-surefire-report-plugin 3.4 is used and the second when version 3.5 is used. + */ + private final Path pathToITReport34 = Paths.get(MULTIPLE_PROJECTS_PATH, SM_MP_PROJECT_NAME, "target", "site", "failsafe-report.html"); + private final Path pathToITReport35 = Paths.get(MULTIPLE_PROJECTS_PATH, SM_MP_PROJECT_NAME, "target", "reports", "failsafe.html"); + + /** + * The paths to the unit test reports. The first is used when maven-surefire-report-plugin 3.4 is used and the second when version 3.5 is used. + */ + private final Path pathToUTReport34 = Paths.get(MULTIPLE_PROJECTS_PATH, SM_MP_PROJECT_NAME, "target", "site", "surefire-report.html"); + private final Path pathToUTReport35 = Paths.get(MULTIPLE_PROJECTS_PATH, SM_MP_PROJECT_NAME, "target", "reports", "surefire.html"); + + + + /** + * Prepares the environment for test execution. + */ + @BeforeAll + public static void setup() { + try { + File theDir = new File(MULTIPLE_PROJECTS_PATH); + System.out.println("---------------"+theDir); + if (theDir.exists()){ + TestUtils.deleteDirectory(theDir); + System.out.println("---------------Inside If loop--------------"); + } + theDir.mkdirs(); + System.out.println("---------------"+theDir); + + // Copy the directory to allow renaming. + TestUtils.copyDirectory(GRADLE_PROJECTS_PATH, GRADLE_MULTIPLE_PROJECTS_PATH); + TestUtils.copyDirectory(MAVEN_PROJECTS_PATH, MAVEN_MULTIPLE_PROJECTS_PATH); + + // Prepare the environment with the new project path and name + prepareEnv(MULTIPLE_PROJECTS_PATH_PARENT, SM_MP_PROJECT_NAME, true); + + } catch (IOException e) { + System.err.println("Setup failed: " + e.getMessage()); + e.printStackTrace(); + Assertions.fail("Test setup failed due to an IOException: " + e.getMessage()); + } + } + + /** + * Cleanup includes deleting the created project path. + */ + @AfterAll + public static void cleanup() { + try { + closeProjectView(); + } finally { + deleteDirectoryIfExists(MULTIPLE_PROJECTS_PATH); + } + } + + MavenMPMultipleProjectTest() { + // set the new locations for the test, not the original locations + setProjectsDirPath(MULTIPLE_PROJECTS_PATH); + setTestReportPath(Paths.get(MULTIPLE_PROJECTS_PATH, SM_MP_PROJECT_NAME, "build", "reports", "tests", "test", "index.html")); + setSmMPProjectName(SM_MP_PROJECT_NAME); + setBuildCategory(BuildType.MAVEN_TYPE); + setSmMpProjPort(9080); + setSmMpProjResURI("api/resource"); + setSmMPProjOutput("Hello! Welcome to Open Liberty"); + setWLPInstallPath(Paths.get("target", "liberty").toString()); + setBuildFileName("pom.xml"); + setBuildFileOpenCommand("Liberty: View pom.xml"); + setStartParams("-DhotTests=true"); + setStartParamsDebugPort("-DdebugPort=9876"); + setProjectTypeIsMultiple(true); + } + + /** + * Deletes test reports. + */ + @Override + public void deleteTestReports() { + boolean itReportDeleted = TestUtils.deleteFile(pathToITReport34); + Assertions.assertTrue(itReportDeleted, () -> "Test report file: " + pathToITReport34 + " was not be deleted."); + itReportDeleted = TestUtils.deleteFile(pathToITReport35); + Assertions.assertTrue(itReportDeleted, () -> "Test report file: " + pathToITReport35 + " was not be deleted."); + + boolean utReportDeleted = TestUtils.deleteFile(pathToUTReport34); + Assertions.assertTrue(utReportDeleted, () -> "Test report file: " + pathToUTReport34 + " was not be deleted."); + utReportDeleted = TestUtils.deleteFile(pathToUTReport35); + Assertions.assertTrue(utReportDeleted, () -> "Test report file: " + pathToUTReport35 + " was not be deleted."); + } + + /** + * Validates that test reports were generated. + */ + @Override + public void validateTestReportsExist() { + TestUtils.validateTestReportExists(pathToITReport34, pathToITReport35); + TestUtils.validateTestReportExists(pathToUTReport34, pathToUTReport35); + } +} \ No newline at end of file diff --git a/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPProjectTest.java b/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPProjectTest.java index 4e0005051..e8253cc02 100755 --- a/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPProjectTest.java +++ b/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPProjectTest.java @@ -50,7 +50,7 @@ public class MavenSingleModMPProjectTest extends SingleModMPProjectTestCommon { @BeforeAll public static void setup() { StepWorker.registerProcessor(new StepLogger()); - prepareEnv(PROJECTS_PATH, SM_MP_PROJECT_NAME); + prepareEnv(PROJECTS_PATH, SM_MP_PROJECT_NAME, false); } MavenSingleModMPProjectTest() { @@ -66,6 +66,7 @@ public static void setup() { setBuildFileOpenCommand("Liberty: View pom.xml"); setStartParams("-DhotTests=true"); setStartParamsDebugPort("-DdebugPort=9876"); + setProjectTypeIsMultiple(false); } /** * Deletes test reports. diff --git a/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPSIDProjectTest.java b/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPSIDProjectTest.java index b2c36acf7..a9786672b 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPSIDProjectTest.java +++ b/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPSIDProjectTest.java @@ -60,7 +60,7 @@ public static void setup() { StepWorker.registerProcessor(new StepLogger()); // Copy the directory from PROJECTS_PATH to PROJECTS_PATH_NEW TestUtils.copyDirectory(PROJECTS_PATH, PROJECTS_PATH_NEW); - prepareEnv(PROJECTS_PATH_NEW, SM_MP_PROJECT_NAME); + prepareEnv(PROJECTS_PATH_NEW, SM_MP_PROJECT_NAME, false); } catch (IOException e) { System.err.println("Setup failed: " + e.getMessage()); e.printStackTrace(); @@ -94,6 +94,7 @@ public static void cleanup() { setBuildFileOpenCommand("Liberty: View pom.xml"); setStartParams("-DhotTests=true"); setStartParamsDebugPort("-DdebugPort=9876"); + setProjectTypeIsMultiple(false); } /** 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..25adcb751 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -68,7 +68,7 @@ public static void cleanup() { UIBotTestUtils.closeFileEditorTab(remoteRobot, "server.env", "5"); UIBotTestUtils.closeFileEditorTab(remoteRobot, "bootstrap.properties", "5"); if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3, false); } UIBotTestUtils.closeProjectView(remoteRobot); UIBotTestUtils.closeProjectFrame(remoteRobot); @@ -581,7 +581,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, "Compact Mode", 3, false); } // 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/SingleModMPLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java index 590c9da03..9083282a4 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() { UIBotTestUtils.closeFileEditorTab(remoteRobot, "ServiceLiveHealthCheck.java", "5"); UIBotTestUtils.closeFileEditorTab(remoteRobot, "microprofile-config.properties", "5"); if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3, false); } UIBotTestUtils.closeProjectView(remoteRobot); UIBotTestUtils.closeProjectFrame(remoteRobot); @@ -332,7 +332,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, "Compact Mode", 3, false); } // 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/SingleModMPProjectTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java index c794fea80..24ab74e11 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java @@ -117,6 +117,11 @@ public enum BuildType { */ private BuildType buildCategory = null; + /** + * Multiple project or not. + */ + private boolean isMultiple = false; + /** * Returns the path where the Liberty server was installed. * @@ -257,6 +262,18 @@ public void setBuildCategory(BuildType type) { buildCategory = type; }; + /** + * Returns a check whether the project opened is multiple project or not. + * + * @return a check whether the project opened is multiple project or not. + */ + public boolean getProjectTypeIsMutliple() { + return isMultiple; + } + public void setProjectTypeIsMultiple(boolean value) { + isMultiple = value; + } + /** * Processes actions before each test. * @@ -294,8 +311,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, "Close All Tabs", 3, false); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3, false); } UIBotTestUtils.closeLibertyToolWindow(remoteRobot); UIBotTestUtils.closeProjectView(remoteRobot); @@ -343,7 +360,7 @@ public void testStartWithParamsActionUsingDropDownMenu() { deleteTestReports(); // Trigger the start with parameters configuration dialog. - UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start...", false, 3); + UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start...", getSmMPProjectName(), false, 3); // Run the configuration dialog. UIBotTestUtils.runStartParamsConfigDialog(remoteRobot, getStartParams()); @@ -363,13 +380,13 @@ public void testStartWithParamsActionUsingDropDownMenu() { TestUtils.sleepAndIgnoreException(60); // Stop Liberty dev mode and validates that the Liberty server is down. - UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.LTWDROPDOWN, absoluteWLPPath, getSmMPProjectName(), 3); + UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.LTWDROPDOWN, absoluteWLPPath, getSmMPProjectName(), 3, getProjectTypeIsMutliple()); } } // Validate that the start with params action brings up the configuration previously used. try { - UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start...", false, 3); + UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start...", getSmMPProjectName(), false, 3); Map cfgEntries = UIBotTestUtils.getOpenedLibertyConfigDataAndCloseOnExit(remoteRobot); String activeCfgName = cfgEntries.get(UIBotTestUtils.ConfigEntries.NAME.toString()); Assertions.assertEquals(getSmMPProjectName(), activeCfgName, "The active config name " + activeCfgName + " does not match expected name of " + getSmMPProjectName()); @@ -398,7 +415,7 @@ public void testStartWithParamsActionUsingPlayToolbarButton() { UIBotTestUtils.deleteLibertyRunConfigurations(remoteRobot); // Trigger the start with parameters configuration dialog. - UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start...", true, 3); + UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start...", getSmMPProjectName(), true, 3); // Run the configuration dialog. UIBotTestUtils.runStartParamsConfigDialog(remoteRobot, getStartParams()); @@ -418,13 +435,13 @@ public void testStartWithParamsActionUsingPlayToolbarButton() { TestUtils.sleepAndIgnoreException(60); // Stop Liberty dev mode and validates that the Liberty server is down. - UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.LTWPLAY, absoluteWLPPath, getSmMPProjectName(), 3); + UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.LTWPLAY, absoluteWLPPath, getSmMPProjectName(), 3, getProjectTypeIsMutliple()); } } // Validate that the start with params action brings up the configuration previously used. try { - UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start...", true, 3); + UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start...", getSmMPProjectName(), true, 3); Map cfgEntries = UIBotTestUtils.getOpenedLibertyConfigDataAndCloseOnExit(remoteRobot); String activeCfgName = cfgEntries.get(UIBotTestUtils.ConfigEntries.NAME.toString()); Assertions.assertEquals(getSmMPProjectName(), activeCfgName, "The active config name " + activeCfgName + " does not match expected name of " + getSmMPProjectName()); @@ -472,7 +489,7 @@ public void testStartWithParamsActionUsingPopUpMenu() { TestUtils.sleepAndIgnoreException(60); // Stop Liberty dev mode and validates that the Liberty server is down. - UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.LTWPOPUP, absoluteWLPPath, getSmMPProjectName(), 3); + UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.LTWPOPUP, absoluteWLPPath, getSmMPProjectName(), 3, getProjectTypeIsMutliple()); } } @@ -506,7 +523,13 @@ public void testStartWithParamsActionUsingSearch() { UIBotTestUtils.deleteLibertyRunConfigurations(remoteRobot); // Trigger the start with parameters configuration dialog. - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Liberty: Start...", 3); + if (getProjectTypeIsMutliple()) { + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Liberty: Start...", 3, true); + UIBotTestUtils.selectProjectFromAddLibertyProjectDialog(remoteRobot, getSmMPProjectName(), "Liberty project", true); + } + else { + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Liberty: Start...", 3, false); + } // Run the configuration dialog. UIBotTestUtils.runStartParamsConfigDialog(remoteRobot, getStartParams()); @@ -526,13 +549,19 @@ public void testStartWithParamsActionUsingSearch() { TestUtils.sleepAndIgnoreException(60); // Stop Liberty dev mode and validates that the Liberty server is down. - UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.SEARCH, absoluteWLPPath, getSmMPProjectName(), 3); + UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.SEARCH, absoluteWLPPath, getSmMPProjectName(), 3, getProjectTypeIsMutliple()); } } // Validate that the start with params action brings up the configuration previously used. try { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Liberty: Start...", 3); + if (getProjectTypeIsMutliple()) { + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Liberty: Start...", 3, true); + UIBotTestUtils.selectProjectFromAddLibertyProjectDialog(remoteRobot, getSmMPProjectName(), "Liberty project", true); + } + else { + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Liberty: Start...", 3, false); + } Map cfgEntries = UIBotTestUtils.getOpenedLibertyConfigDataAndCloseOnExit(remoteRobot); String activeCfgName = cfgEntries.get(UIBotTestUtils.ConfigEntries.NAME.toString()); Assertions.assertEquals(getSmMPProjectName(), activeCfgName, "The active config name " + activeCfgName + " does not match expected name of " + getSmMPProjectName()); @@ -557,14 +586,14 @@ public void testRunTestsActionUsingDropDownMenu() { deleteTestReports(); // Start dev mode. - UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start", false, 3); + UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start", getSmMPProjectName(), false, 3); // Validate that the project started. TestUtils.validateProjectStarted(testName, getSmMpProjResURI(), getSmMpProjPort(), getSmMPProjOutput(), absoluteWLPPath, false); try { // Run the project's tests. - UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Run tests", false, 3); + UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Run tests", getSmMPProjectName(), false, 3); // Validate that the report was generated. validateTestReportsExist(); @@ -577,7 +606,7 @@ public void testRunTestsActionUsingDropDownMenu() { TestUtils.sleepAndIgnoreException(60); // Stop Liberty dev mode and validates that the Liberty server is down. - UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.LTWDROPDOWN, absoluteWLPPath, getSmMPProjectName(), 3); + UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.LTWDROPDOWN, absoluteWLPPath, getSmMPProjectName(), 3, getProjectTypeIsMutliple()); } } } @@ -596,14 +625,14 @@ public void testRunTestsActionUsingPlayToolbarButton() { deleteTestReports(); // Start dev mode. - UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start", true, 3); + UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start", getSmMPProjectName(), true, 3); try { // Validate that the application started. TestUtils.validateProjectStarted(testName, getSmMpProjResURI(), getSmMpProjPort(), getSmMPProjOutput(), absoluteWLPPath, false); // Run the application's tests. - UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Run tests", true, 3); + UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Run tests", getSmMPProjectName(), true, 3); // Validate that the report was generated. validateTestReportsExist(); @@ -616,7 +645,7 @@ public void testRunTestsActionUsingPlayToolbarButton() { TestUtils.sleepAndIgnoreException(60); // Stop Liberty dev mode and validates that the Liberty server is down. - UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.LTWDROPDOWN, absoluteWLPPath, getSmMPProjectName(), 3); + UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.LTWDROPDOWN, absoluteWLPPath, getSmMPProjectName(), 3, getProjectTypeIsMutliple()); } } } @@ -654,7 +683,7 @@ public void testRunTestsActionUsingPopUpMenu() { TestUtils.sleepAndIgnoreException(60); // Stop Liberty dev mode and validates that the Liberty server is down. - UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.LTWPOPUP, absoluteWLPPath, getSmMPProjectName(), 3); + UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.LTWPOPUP, absoluteWLPPath, getSmMPProjectName(), 3, getProjectTypeIsMutliple()); } } } @@ -672,14 +701,25 @@ public void testRunTestsActionUsingSearch() { deleteTestReports(); // Start dev mode. - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Liberty: Start", 3); + if (getProjectTypeIsMutliple()) { + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Liberty: Start", 3, true); + UIBotTestUtils.selectProjectFromAddLibertyProjectDialog(remoteRobot, getSmMPProjectName(), "Liberty project", true); + } + else { + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Liberty: Start", 3, false); + } try { // Validate that the application started. TestUtils.validateProjectStarted(testName, getSmMpProjResURI(), getSmMpProjPort(), getSmMPProjOutput(), absoluteWLPPath, false); // Run the application's tests. - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Liberty: Run tests", 3); + if (getProjectTypeIsMutliple()) { + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Liberty: Run tests", 3, true); + UIBotTestUtils.selectProjectFromAddLibertyProjectDialog(remoteRobot, getSmMPProjectName(), "Liberty project", true); + } else { + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Liberty: Run tests", 3, false); + } // Validate that the reports were generated. validateTestReportsExist(); @@ -692,7 +732,7 @@ public void testRunTestsActionUsingSearch() { TestUtils.sleepAndIgnoreException(60); // Stop Liberty dev mode and validates that the Liberty server is down. - UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.SEARCH, absoluteWLPPath, getSmMPProjectName(), 3); + UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.SEARCH, absoluteWLPPath, getSmMPProjectName(), 3, getProjectTypeIsMutliple()); } } } @@ -747,7 +787,7 @@ public void testStartWithConfigInDebugModeUsingToolbar() { try { // Stop the server. if (TestUtils.isServerStopNeeded(absoluteWLPPath)) { - UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.LTWDROPDOWN, absoluteWLPPath, getSmMPProjectName(), 3); + UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.LTWDROPDOWN, absoluteWLPPath, getSmMPProjectName(), 3, getProjectTypeIsMutliple()); } } finally { // Cleanup configurations. @@ -804,7 +844,7 @@ public void testStartWithConfigInDebugModeUsingMenu() { try { // Stop the server. if (TestUtils.isServerStopNeeded(absoluteWLPPath)) { - UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.LTWDROPDOWN, absoluteWLPPath, getSmMPProjectName(), 3); + UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.LTWDROPDOWN, absoluteWLPPath, getSmMPProjectName(), 3, getProjectTypeIsMutliple()); } } finally { // Cleanup configurations. @@ -845,7 +885,7 @@ public void testStartWithConfigInRunModeUsingToolbar() { } finally { try { if (TestUtils.isServerStopNeeded(absoluteWLPPath)) { - UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.LTWDROPDOWN, absoluteWLPPath, getSmMPProjectName(), 3); + UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.LTWDROPDOWN, absoluteWLPPath, getSmMPProjectName(), 3, getProjectTypeIsMutliple()); } } finally { // Cleanup configurations. @@ -881,7 +921,7 @@ public void testStartWithConfigInRunModeUsingMenu() { } finally { try { if (TestUtils.isServerStopNeeded(absoluteWLPPath)) { - UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.LTWDROPDOWN, absoluteWLPPath, getSmMPProjectName(), 3); + UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.LTWDROPDOWN, absoluteWLPPath, getSmMPProjectName(), 3, getProjectTypeIsMutliple()); } } finally { // Cleanup configurations. @@ -925,7 +965,7 @@ public void testMultipleConfigEditHistory() { // Note that depending on the size of the dialog, the project config file path shown in the Liberty project // combo box, may be truncated. Therefore, this check is just a best effort approach to make sure that // there is a value in the box, and that it approximates the expected value. - UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start...", false, 3); + UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start...", getSmMPProjectName(), false, 3); Map cfgEntries1 = UIBotTestUtils.getOpenedLibertyConfigDataAndCloseOnExit(remoteRobot); String activeCfgName1 = cfgEntries1.get(UIBotTestUtils.ConfigEntries.NAME.toString()); Assertions.assertEquals(configName1, activeCfgName1, "The active config name " + activeCfgName1 + " does not match expected name of " + configName1); @@ -939,7 +979,7 @@ public void testMultipleConfigEditHistory() { UIBotTestUtils.selectConfigUsingToolbar(remoteRobot, configName2); // Validate that selected configuration 2 shows the expected data. The dialog is opened using the start... action. - UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start...", false, 3); + UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start...", getSmMPProjectName(), false, 3); Map cfgEntries2 = UIBotTestUtils.getOpenedLibertyConfigDataAndCloseOnExit(remoteRobot); String activeCfgName2 = cfgEntries2.get(UIBotTestUtils.ConfigEntries.NAME.toString()); Assertions.assertEquals(configName2, activeCfgName2, "The active config name " + activeCfgName2 + " does not match expected name of " + configName2); @@ -955,7 +995,7 @@ public void testMultipleConfigEditHistory() { String newCfgName1 = cfgUID11 + "-" + getSmMPProjectName(); String newCfgStartParams1 = getStartParams() + " " + cfgUID11; String newCfgProjBldPath1 = projectBldFilePath; - UIBotTestUtils.editLibertyConfigUsingEditConfigDialog(remoteRobot, newCfgName1, newCfgStartParams1); + UIBotTestUtils.editLibertyConfigUsingEditConfigDialog(remoteRobot, getSmMPProjectName(), newCfgName1, newCfgStartParams1); // Edit configuration 2 UIBotTestUtils.selectConfigUsingToolbar(remoteRobot, configName2); @@ -963,13 +1003,13 @@ public void testMultipleConfigEditHistory() { String newCfgName2 = cfgUID22 + "-" + getSmMPProjectName(); String newCfgProjBldPath2 = projectBldFilePath; String newCfgStartParams2 = getStartParams() + " " + cfgUID22; - UIBotTestUtils.editLibertyConfigUsingEditConfigDialog(remoteRobot, newCfgName2, newCfgStartParams2); + UIBotTestUtils.editLibertyConfigUsingEditConfigDialog(remoteRobot, getSmMPProjectName(), newCfgName2, newCfgStartParams2); // Find newly created config 1 in the config selection box on the toolbar of the project frame. UIBotTestUtils.selectConfigUsingToolbar(remoteRobot, newCfgName1); // Validate that selected configuration 1 shows the expected data. The dialog is opened using the start... action. - UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start...", false, 3); + UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start...", getSmMPProjectName(), false, 3); Map newCfgEntries1 = UIBotTestUtils.getOpenedLibertyConfigDataAndCloseOnExit(remoteRobot); String newActiveCfgName1 = newCfgEntries1.get(UIBotTestUtils.ConfigEntries.NAME.toString()); Assertions.assertEquals(newCfgName1, newActiveCfgName1, "The active config name " + newActiveCfgName1 + " does not match expected name of " + newCfgName1); @@ -983,7 +1023,7 @@ public void testMultipleConfigEditHistory() { UIBotTestUtils.selectConfigUsingToolbar(remoteRobot, newCfgName2); // Validate that selected configuration 2 shows the expected data. The dialog is opened using the start... action. - UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start...", false, 3); + UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start...", getSmMPProjectName(), false, 3); Map newCfgEntries2 = UIBotTestUtils.getOpenedLibertyConfigDataAndCloseOnExit(remoteRobot); String newActiveCfgName2 = newCfgEntries2.get(UIBotTestUtils.ConfigEntries.NAME.toString()); Assertions.assertEquals(newCfgName2, newActiveCfgName2, "The active config name " + newActiveCfgName2 + " does not match expected name of " + newCfgName2); @@ -1014,14 +1054,14 @@ public void testStartInContainerActionUsingDropDownMenu() { String absoluteWLPPath = Paths.get(getProjectsDirPath(), getSmMPProjectName(), getWLPInstallPath()).toString(); // Start dev mode in a container. - UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start in container", false, 3); + UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start in container", getSmMPProjectName(), false, 3); try { // Validate that the project started. TestUtils.validateProjectStarted(testName, getSmMpProjResURI(), getSmMpProjPort(), getSmMPProjOutput(), absoluteWLPPath, true); } finally { if (TestUtils.isServerStopNeeded(absoluteWLPPath)) { // Stop dev mode. - UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Stop", false, 3); + UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Stop", getSmMPProjectName(), false, 3); // Validate that the server stopped. TestUtils.validateLibertyServerStopped(testName, absoluteWLPPath); @@ -1046,14 +1086,14 @@ public void testStartInContainerActionUsingPlayToolbarButton() { String absoluteWLPPath = Paths.get(getProjectsDirPath(), getSmMPProjectName(), getWLPInstallPath()).toString(); // Start dev mode in a container. - UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start in container", true, 3); + UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start in container", getSmMPProjectName(), true, 3); try { // Validate that the project started. TestUtils.validateProjectStarted(testName, getSmMpProjResURI(), getSmMpProjPort(), getSmMPProjOutput(), absoluteWLPPath, true); } finally { if (TestUtils.isServerStopNeeded(absoluteWLPPath)) { // Stop dev mode. - UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Stop", true, 3); + UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Stop", getSmMPProjectName(), true, 3); // Validate that the server stopped. TestUtils.validateLibertyServerStopped(testName, absoluteWLPPath); @@ -1109,7 +1149,13 @@ public void testStartInContainerActionUsingSearch() { String absoluteWLPPath = Paths.get(getProjectsDirPath(), getSmMPProjectName(), getWLPInstallPath()).toString(); // Start dev mode in a container. - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Liberty: Start in container", 3); + if (getProjectTypeIsMutliple()) { + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Liberty: Start in container", 3, true); + UIBotTestUtils.selectProjectFromAddLibertyProjectDialog(remoteRobot, getSmMPProjectName(), "Liberty project", true); + } + else { + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Liberty: Start in container", 3, false); + } try { // Validate that the project started. @@ -1117,7 +1163,13 @@ public void testStartInContainerActionUsingSearch() { } finally { if (TestUtils.isServerStopNeeded(absoluteWLPPath)) { // Stop dev mode. - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Liberty: Stop", 3); + if (getProjectTypeIsMutliple()) { + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Liberty: Stop", 3, true); + UIBotTestUtils.selectProjectFromAddLibertyProjectDialog(remoteRobot, getSmMPProjectName(), "Liberty project", true); + } + else { + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Liberty: Stop", 3, false); + } // Validate that the server stopped. TestUtils.validateLibertyServerStopped(testName, absoluteWLPPath); @@ -1131,15 +1183,21 @@ public void testStartInContainerActionUsingSearch() { * @param projectPath The path of the project. * @param projectName The name of the project being used. */ - public static void prepareEnv(String projectPath, String projectName) { + public static void prepareEnv(String projectPath, String projectName, boolean isMultiple) { TestUtils.printTrace(TestUtils.TraceSevLevel.INFO, "prepareEnv. Entry. ProjectPath: " + projectPath + ". ProjectName: " + projectName); waitForIgnoringError(Duration.ofMinutes(4), Duration.ofSeconds(5), "Wait for IDE to start", "IDE did not start", () -> remoteRobot.callJs("true")); UIBotTestUtils.findWelcomeFrame(remoteRobot); - UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); + if (isMultiple) { + UIBotTestUtils.importProject(remoteRobot, projectPath, "multiple-project"); + UIBotTestUtils.clickOnLoad(remoteRobot); + } + else { + UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); + } UIBotTestUtils.openProjectView(remoteRobot); if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3, false); } // IntelliJ does not start building and indexing until the Project View is open UIBotTestUtils.waitForIndexing(remoteRobot); @@ -1157,7 +1215,7 @@ public static void prepareEnv(String projectPath, String projectName) { UIBotTestUtils.closeAllEditorTabs(remoteRobot); } else { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Close All Tabs", 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Close All Tabs", 3, false); } TestUtils.printTrace(TestUtils.TraceSevLevel.INFO, @@ -1178,7 +1236,7 @@ public void testCustomStartParametersClearedOnConfigRemoval() { UIBotTestUtils.deleteLibertyRunConfigurations(remoteRobot); // Trigger the start with parameters configuration dialog. - UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start...", true, 3); + UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start...", getSmMPProjectName(), true, 3); // Run the configuration dialog. UIBotTestUtils.runStartParamsConfigDialog(remoteRobot, getStartParamsDebugPort()); @@ -1197,7 +1255,7 @@ public void testCustomStartParametersClearedOnConfigRemoval() { // Stops the Liberty server if necessary. if (TestUtils.isServerStopNeeded(absoluteWLPPath)) { // Stop Liberty dev mode and validate that the Liberty server is down. - UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.LTWDROPDOWN, absoluteWLPPath, getSmMPProjectName(), 3); + UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.LTWDROPDOWN, absoluteWLPPath, getSmMPProjectName(), 3, getProjectTypeIsMutliple()); } } @@ -1205,7 +1263,7 @@ public void testCustomStartParametersClearedOnConfigRemoval() { UIBotTestUtils.deleteLibertyRunConfigurations(remoteRobot); // Start dev mode. - UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start", true, 3); + UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start", getSmMPProjectName(), true, 3); try { // Validate that the project started. @@ -1221,7 +1279,7 @@ public void testCustomStartParametersClearedOnConfigRemoval() { // Stops the Liberty server if necessary. if (TestUtils.isServerStopNeeded(absoluteWLPPath)) { // Stop Liberty dev mode and validate that the Liberty server is down. - UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.LTWDROPDOWN, absoluteWLPPath, getSmMPProjectName(), 3); + UIBotTestUtils.runStopAction(remoteRobot, testName, UIBotTestUtils.ActionExecType.LTWDROPDOWN, absoluteWLPPath, getSmMPProjectName(), 3, getProjectTypeIsMutliple()); } } } @@ -1253,6 +1311,10 @@ public void stopTerminal() { // Perform Stop Action if (getBuildCategory() == BuildType.MAVEN_TYPE) { + if (getProjectsDirPath().contains("multiple-project")) { + keyboard.enterText("cd singleModMavenMP"); + keyboard.enter(); + } keyboard.enterText("./mvnw liberty:stop"); } else if (getBuildCategory() == BuildType.GRADLE_TYPE) { keyboard.enterText("./gradlew libertyStop"); @@ -1272,6 +1334,10 @@ public void cleanTerminal() { Keyboard keyboard = new Keyboard(remoteRobot); // Perform clean if (getBuildCategory() == BuildType.MAVEN_TYPE) { + if (getProjectsDirPath().contains("multiple-project")) { + keyboard.enterText("cd singleModMavenMP"); + keyboard.enter(); + } keyboard.enterText("./mvnw clean"); } else if (getBuildCategory() == BuildType.GRADLE_TYPE) { keyboard.enterText("./gradlew clean"); 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..d7daa6ceb 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java @@ -85,7 +85,7 @@ public void afterEach(TestInfo info) { @AfterAll public static void cleanup() { if (!remoteRobot.isMac()) { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3, false); } UIBotTestUtils.closeLibertyToolWindow(remoteRobot); UIBotTestUtils.closeProjectView(remoteRobot); @@ -156,17 +156,17 @@ public void testManualProjectAddRemoveActionUsingSearch() { UIBotTestUtils.waitForLTWNoProjectDetectedMsg(remoteRobot, 10); // Add the project to the Liberty tool window. - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Liberty: Add project to the tool window", 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Liberty: Add project to the tool window", 3, false); // Select project from the 'Add Liberty project' dialog. - UIBotTestUtils.selectProjectFromAddLibertyProjectDialog(remoteRobot, getSmNLTRestProjectName()); + UIBotTestUtils.selectProjectFromAddLibertyProjectDialog(remoteRobot, getSmNLTRestProjectName(), "Add Liberty project", false); try { // Validate that the project is displayed in the Liberty tool window. UIBotTestUtils.findProjectInLibertyToolWindow(remoteRobot, getSmNLTRestProjectName(), "10"); } finally { // Remove the project from the Liberty tool window. - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Liberty: Remove project from the tool window", 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Liberty: Remove project from the tool window", 3, false); // Select project from the 'Remote Liberty project' dialog. UIBotTestUtils.selectProjectFromRemoveLibertyProjectDialog(remoteRobot, getSmNLTRestProjectName()); @@ -302,7 +302,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, "Compact Mode", 3, false); } // 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/UIBotTestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java index 1ba7103b2..caf6a524f 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java @@ -244,7 +244,7 @@ public static void closeProjectFrame(RemoteRobot remoteRobot) { * @param action The action to run * @param usePlayButton The indicator that specifies if play button should be used to run the action or not. */ - public static void runLibertyActionFromLTWDropDownMenu(RemoteRobot remoteRobot, String action, boolean usePlayButton, int maxRetries) { + public static void runLibertyActionFromLTWDropDownMenu(RemoteRobot remoteRobot, String action, String projectName, boolean usePlayButton, int maxRetries) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); // Click on the Liberty toolbar to give it focus. @@ -264,8 +264,12 @@ public static void runLibertyActionFromLTWDropDownMenu(RemoteRobot remoteRobot, treeFixture::isShowing); List rts = treeFixture.findAllText(); + boolean flag = false; for (RemoteText rt : rts) { - if (action.equals(rt.getText())) { + if (projectName.equals(rt.getText())) { + flag = true; + } + if (action.equals(rt.getText()) && flag) { if (usePlayButton) { rt.click(); clickOnLibertyTWToolbarPlayButton(remoteRobot); @@ -1667,7 +1671,7 @@ public static void printUIComponentHierarchy(PrintTo printTo, int secondsToWait) * * @param remoteRobot The RemoteRobot instance. */ - public static void runActionFromSearchEverywherePanel(RemoteRobot remoteRobot, String action, int maxRetries) { + public static void runActionFromSearchEverywherePanel(RemoteRobot remoteRobot, String action, int maxRetries, boolean isMultiple) { // Search everywhere UI actions may fail due to UI flickering/indexing on Windows. Retry in case of a failure. Exception error = null; for (int i = 0; i < maxRetries; i++) { @@ -1704,9 +1708,9 @@ public static void runActionFromSearchEverywherePanel(RemoteRobot remoteRobot, S Duration.ofSeconds(1), "Waiting for the search to filter and show " + action + " in search output", "The search did not filter or show " + action + " in the search output", - () -> findTextInListOutputPanel(projectFrame, action) != null); + () -> findTextInListOutputPanel(projectFrame, action, true) != null); - RemoteText foundAction = findTextInListOutputPanel(projectFrame, action); + RemoteText foundAction = findTextInListOutputPanel(projectFrame, action, true); if (foundAction != null) { foundAction.click(); } else { @@ -1714,7 +1718,7 @@ public static void runActionFromSearchEverywherePanel(RemoteRobot remoteRobot, S } // If the Liberty: Start... action was selected, make sure the Edit Configuration dialog is displayed. - if (action.equals("Liberty: Start...")) { + if (action.equals("Liberty: Start...") && !isMultiple) { // This call will fail if the expected dialog is not displayed. projectFrame.find(DialogFixture.class, DialogFixture.byTitle("Edit Configuration"), Duration.ofSeconds(30)); } @@ -1759,19 +1763,20 @@ public static void runActionFromSearchEverywherePanel(RemoteRobot remoteRobot, S * @param remoteRobot The RemoteRobot instance. * @param projectName The name of the project to select. */ - public static void selectProjectFromAddLibertyProjectDialog(RemoteRobot remoteRobot, String projectName) { + public static void selectProjectFromAddLibertyProjectDialog(RemoteRobot remoteRobot, String projectName, String dialogTitle, boolean isMutiple) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); DialogFixture addProjectDialog = projectFrame.find(DialogFixture.class, - DialogFixture.byTitle("Add Liberty project"), + DialogFixture.byTitle(dialogTitle), Duration.ofSeconds(10)); JButtonFixture jbf = addProjectDialog.getBasicArrowButton(); jbf.click(); - RemoteText remoteProject = findTextInListOutputPanel(addProjectDialog, projectName); + RemoteText remoteProject; + remoteProject = findTextInListOutputPanel(addProjectDialog, projectName, !isMutiple); if (remoteProject != null) { remoteProject.click(); } else { - fail("Unable to find " + projectName + " in the output list of the Add Liberty project dialog."); + fail("Unable to find " + projectName + " in the output list of the " + dialogTitle + " dialog."); } JButtonFixture okButton = addProjectDialog.getButton("OK"); @@ -1792,7 +1797,7 @@ public static void selectProjectFromRemoveLibertyProjectDialog(RemoteRobot remot Duration.ofSeconds(10)); removeProjectDialog.getBasicArrowButton().click(); - RemoteText remoteProject = findTextInListOutputPanel(removeProjectDialog, projectName); + RemoteText remoteProject = findTextInListOutputPanel(removeProjectDialog, projectName, true); if (remoteProject != null) { remoteProject.click(); } else { @@ -2067,9 +2072,9 @@ public static void createLibertyConfiguration(RemoteRobot remoteRobot, String cf * @param cfgName The name of the new configuration. * @param startParams The dev mode start parameters. */ - public static void editLibertyConfigUsingEditConfigDialog(RemoteRobot remoteRobot, String cfgName, String startParams) { + public static void editLibertyConfigUsingEditConfigDialog(RemoteRobot remoteRobot, String projectName, String cfgName, String startParams) { // Display the Liberty Edit Configuration dialog. - runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start...", false, 3); + runLibertyActionFromLTWDropDownMenu(remoteRobot, "Start...", projectName, false, 3); // Get a hold of the Liberty Edit Configurations dialog. ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); @@ -2452,7 +2457,7 @@ public static void stopDebugger(RemoteRobot remoteRobot) { * @return The RemoteText object representing the text found in the list panel, or * null if the text was not found. */ - public static RemoteText findTextInListOutputPanel(CommonContainerFixture fixture, String text) { + public static RemoteText findTextInListOutputPanel(CommonContainerFixture fixture, String text, boolean exactMatch) { RemoteText foundText = null; List searchLists = fixture.jLists(JListFixture.Companion.byType()); @@ -2461,7 +2466,7 @@ public static RemoteText findTextInListOutputPanel(CommonContainerFixture fixtur try { List entries = searchList.findAllText(); for (RemoteText entry : entries) { - if (entry.getText().equals(text)) { + if ((exactMatch && entry.getText().equals(text)) || (!exactMatch && entry.getText().contains(text))) { foundText = entry; } } @@ -2482,22 +2487,25 @@ public static RemoteText findTextInListOutputPanel(CommonContainerFixture fixtur * @param absoluteWLPPath The absolute path of the Liberty installation. * @param maxRetries The maximum amount of attempts to try to stop the server. */ - public static void runStopAction(RemoteRobot remoteRobot, String testName, ActionExecType execType, String absoluteWLPPath, String smMPProjName, int maxRetries) { + public static void runStopAction(RemoteRobot remoteRobot, String testName, ActionExecType execType, String absoluteWLPPath, String smMPProjName, int maxRetries, Boolean isMultiple) { for (int i = 0; i < maxRetries; i++) { // Stop dev mode. Any failures during command processing are retried. If there are any // failures, this method will exit. switch (execType) { case LTWPLAY: - UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Stop", true, maxRetries); + UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Stop", smMPProjName, true, maxRetries); break; case LTWDROPDOWN: - UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Stop", false, maxRetries); + UIBotTestUtils.runLibertyActionFromLTWDropDownMenu(remoteRobot, "Stop", smMPProjName, false, maxRetries); break; case LTWPOPUP: UIBotTestUtils.runActionLTWPopupMenu(remoteRobot, smMPProjName, "Liberty: Stop", maxRetries); break; case SEARCH: - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Liberty: Stop", maxRetries); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Liberty: Stop", maxRetries, false); + if (isMultiple) { + UIBotTestUtils.selectProjectFromAddLibertyProjectDialog(remoteRobot, smMPProjName, "Liberty project", true); + } break; default: fail("An invalid execution type of " + execType + " was requested."); @@ -2677,7 +2685,7 @@ public static void findWelcomeFrame(RemoteRobot remoteRobot) { UIBotTestUtils.closeAllEditorTabs(remoteRobot); } else { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Close All Tabs", 3); + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Close All Tabs", 3, false); } UIBotTestUtils.closeProjectView(remoteRobot); UIBotTestUtils.closeProjectFrame(remoteRobot); @@ -2816,4 +2824,19 @@ public static String handleMenuBasedOnVersion(RemoteRobot remoteRobot, String me return menuAction2; } + public static void clickOnLoad(RemoteRobot remoteRobot) { + ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); + + try { + // Clicking on the left toolbar ensures that the Main Menu button is active. + String xPath = "//div[@accessiblename='Load all' and @class='JButton']"; + ComponentFixture actionButton = projectFrame.getActionButton(xPath, "10"); + actionButton.click(); + TestUtils.sleepAndIgnoreException(5); + + } catch (WaitForConditionTimeoutException e) { + // Main Menu button is not clicked, nothing to do + } + } + }