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 678b347c8..d16c780f4 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPProjectTest.java +++ b/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPProjectTest.java @@ -9,17 +9,14 @@ *******************************************************************************/ package io.openliberty.tools.intellij.it; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; -import java.nio.file.Path; import java.nio.file.Paths; /** * Tests Liberty Tools actions using a single module MicroProfile Gradle project. */ public class GradleSingleModMPProjectTest extends SingleModMPProjectTestCommon { - /** * Single module Microprofile project name. */ @@ -30,56 +27,6 @@ public class GradleSingleModMPProjectTest extends SingleModMPProjectTestCommon { */ private static final String PROJECTS_PATH = Paths.get("src", "test", "resources", "projects", "gradle").toAbsolutePath().toString(); - /** - * Project port. - */ - private final int SM_MP_PROJECT_PORT = 9080; - - /** - * Project resource URI. - */ - private final String SM_MP_PROJECT_RES_URI = "api/resource"; - - /** - * Project response. - */ - private final String SM_MP_PROJECT_OUTPUT = "Hello! Welcome to Open Liberty"; - - /** - * Relative location of the WLP installation. - */ - private final String WLP_INSTALL_PATH = "build"; - - /** - * The path to the test report. - */ - private final Path TEST_REPORT_PATH = Paths.get(PROJECTS_PATH, SM_MP_PROJECT_NAME, "build", "reports", "tests", "test", "index.html"); - - /** - * Build file name. - */ - private final String BUILD_FILE_NAME = "build.gradle"; - - /** - * Build Category. - */ - private final BuildType BUILD_CATEGORY = BuildType.GRADLE_TYPE; - - /** - * Action command to open the build file. - */ - private final String BUILD_FILE_OPEN_CMD = "Liberty: View Gradle config"; - - /** - * Dev mode configuration start parameters. - */ - private final String DEV_MODE_START_PARAMS = "--hotTests"; - - /** - * Dev mode configuration custom start parameters for debugging. - */ - private final String DEV_MODE_START_PARAMS_DEBUG = "--libertyDebugPort=9876"; - /** * Prepares the environment for test execution. */ @@ -88,131 +35,18 @@ public static void setup() { prepareEnv(PROJECTS_PATH, SM_MP_PROJECT_NAME); } - /** - * Returns the path where the Liberty server was installed. - * - * @return The path where the Liberty server was installed. - */ - @Override - public String getWLPInstallPath() { - return WLP_INSTALL_PATH; - } - - /** - * Returns the projects directory path. - * - * @return The projects directory path. - */ - @Override - public String getProjectsDirPath() { - return PROJECTS_PATH; - } - - /** - * Returns the name of the single module MicroProfile project. - * - * @return The name of the single module MicroProfile project. - */ - @Override - public String getSmMPProjectName() { - return SM_MP_PROJECT_NAME; - } - - /** - * Returns the expected HTTP response payload associated with the single module - * MicroProfile project. - * - * @return The expected HTTP response payload associated with the single module - * MicroProfile project. - */ - @Override - public String getSmMPProjOutput() { - return SM_MP_PROJECT_OUTPUT; - } - - /** - * Returns the port number associated with the single module MicroProfile project. - * - * @return The port number associated with the single module MicroProfile project. - */ - @Override - public int getSmMpProjPort() { - return SM_MP_PROJECT_PORT; - } - - /** - * Return the Resource URI associated with the single module MicroProfile project. - * - * @return The Resource URI associated with the single module MicroProfile project. - */ - @Override - public String getSmMpProjResURI() { - return SM_MP_PROJECT_RES_URI; - } - - /** - * Returns the name of the build file used by the project. - * - * @return The name of the build file used by the project. - */ - @Override - public String getBuildFileName() { - return BUILD_FILE_NAME; - } - - /** - * Returns the name of the custom action command used to open the build file. - * - * @return The name of the custom action command used to open the build file. - */ - @Override - public String getBuildFileOpenCommand() { - return BUILD_FILE_OPEN_CMD; - } - - /** - * Returns the custom start parameters to be used to start dev mode. - * - * @return The custom start parameters to be used to start dev mode. - */ - @Override - public String getStartParams() { - return DEV_MODE_START_PARAMS; - } - - /** - * Returns the custom start parameters for debugging to start dev mode. - * - * @return The custom start parameters for debugging to start dev mode. - */ - @Override - public String getStartParamsDebugPort() { - return DEV_MODE_START_PARAMS_DEBUG; - } - - /** - * Deletes test reports. - */ - @Override - public void deleteTestReports() { - boolean testReportDeleted = TestUtils.deleteFile(TEST_REPORT_PATH); - Assertions.assertTrue(testReportDeleted, () -> "Test report file: " + TEST_REPORT_PATH + " was not be deleted."); - } - - /** - * Validates that test reports were generated. - */ - @Override - public void validateTestReportsExist() { - //TODO: rewrite validateTestReportExists() to accept one argument or to accept a null as the second argument - TestUtils.validateTestReportExists(TEST_REPORT_PATH, TEST_REPORT_PATH); - } - - /** - * Returns the build type category (either MAVEN_TYPE or GRADLE_TYPE) - */ - @Override - public BuildType getBuildCategory() { - return BUILD_CATEGORY; + GradleSingleModMPProjectTest() { + setProjectsDirPath(PROJECTS_PATH); + setSmMPProjectName(SM_MP_PROJECT_NAME); + setBuildCategory(BuildType.GRADLE_TYPE); + setSmMpProjPort(9080); + setSmMpProjResURI("api/resource"); + setSmMPProjOutput("Hello! Welcome to Open Liberty"); + setWLPInstallPath("build"); + setTestReportPath(Paths.get(getProjectsDirPath(), getSmMPProjectName(), "build", "reports", "tests", "test", "index.html")); + setBuildFileName("build.gradle"); + setBuildFileOpenCommand("Liberty: View Gradle config"); + setStartParams("--hotTests"); + setStartParamsDebugPort("--libertyDebugPort=9876"); } } \ 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 8c7923cc1..65a4e30e5 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPSIDProjectTest.java +++ b/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPSIDProjectTest.java @@ -44,63 +44,13 @@ public class GradleSingleModMPSIDProjectTest extends SingleModMPProjectTestCommo */ private static final String PROJECTS_PATH_NEW = Paths.get("src", "test", "resources", "projects", "gradle sample").toAbsolutePath().toString(); - /** - * Project port. - */ - private final int SM_MP_PROJECT_PORT = 9080; - - /** - * Project resource URI. - */ - private final String SM_MP_PROJECT_RES_URI = "api/resource"; - - /** - * Project response. - */ - private final String SM_MP_PROJECT_OUTPUT = "Hello! Welcome to Open Liberty"; - - /** - * Relative location of the WLP installation. - */ - private final String WLP_INSTALL_PATH = "build"; - - /** - * The path to the test report. - */ - private final Path TEST_REPORT_PATH = Paths.get(PROJECTS_PATH_NEW, SM_MP_PROJECT_NAME_NEW, "build", "reports", "tests", "test", "index.html"); - - /** - * Build file name. - */ - private final String BUILD_FILE_NAME = "build.gradle"; - - /** - * Build Category. - */ - private final BuildType BUILD_CATEGORY = BuildType.GRADLE_TYPE; - - /** - * Action command to open the build file. - */ - private final String BUILD_FILE_OPEN_CMD = "Liberty: View Gradle config"; - - /** - * Dev mode configuration start parameters. - */ - private final String DEV_MODE_START_PARAMS = "--hotTests"; - - /** - * Dev mode configuration custom start parameters for debugging. - */ - private final String DEV_MODE_START_PARAMS_DEBUG = "--libertyDebugPort=9876"; - /** * Prepares the environment for test execution. */ @BeforeAll public static void setup() { try { - // Copy the directory from PROJECTS_PATH to PROJECTS_PATH_NEW + // Copy the directory to allow renaming. TestUtils.copyDirectory(PROJECTS_PATH, PROJECTS_PATH_NEW); Path pathNew = Path.of(PROJECTS_PATH_NEW); @@ -142,130 +92,19 @@ public static void cleanup() { } } - /** - * Returns the path where the Liberty server was installed. - * - * @return The path where the Liberty server was installed. - */ - @Override - public String getWLPInstallPath() { - return WLP_INSTALL_PATH; - } - - /** - * Returns the projects new directory path. - * - * @return The projects new directory path. - */ - @Override - public String getProjectsDirPath() { - return PROJECTS_PATH_NEW; - } - - /** - * Returns the name of the single module MicroProfile project. - * - * @return The name of the single module MicroProfile project. - */ - @Override - public String getSmMPProjectName() { - return SM_MP_PROJECT_NAME_NEW; - } - - /** - * Returns the expected HTTP response payload associated with the single module - * MicroProfile project. - * - * @return The expected HTTP response payload associated with the single module - * MicroProfile project. - */ - @Override - public String getSmMPProjOutput() { - return SM_MP_PROJECT_OUTPUT; - } - - /** - * Returns the port number associated with the single module MicroProfile project. - * - * @return The port number associated with the single module MicroProfile project. - */ - @Override - public int getSmMpProjPort() { - return SM_MP_PROJECT_PORT; - } - - /** - * Return the Resource URI associated with the single module MicroProfile project. - * - * @return The Resource URI associated with the single module MicroProfile project. - */ - @Override - public String getSmMpProjResURI() { - return SM_MP_PROJECT_RES_URI; - } - - /** - * Returns the name of the build file used by the project. - * - * @return The name of the build file used by the project. - */ - @Override - public String getBuildFileName() { - return BUILD_FILE_NAME; - } - - /** - * Returns the name of the custom action command used to open the build file. - * - * @return The name of the custom action command used to open the build file. - */ - @Override - public String getBuildFileOpenCommand() { - return BUILD_FILE_OPEN_CMD; - } - - /** - * Returns the custom start parameters to be used to start dev mode. - * - * @return The custom start parameters to be used to start dev mode. - */ - @Override - public String getStartParams() { - return DEV_MODE_START_PARAMS; - } - - /** - * Returns the custom start parameters for debugging to start dev mode. - * - * @return The custom start parameters for debugging to start dev mode. - */ - @Override - public String getStartParamsDebugPort() { - return DEV_MODE_START_PARAMS_DEBUG; - } - - /** - * Deletes test reports. - */ - @Override - public void deleteTestReports() { - boolean testReportDeleted = TestUtils.deleteFile(TEST_REPORT_PATH); - Assertions.assertTrue(testReportDeleted, () -> "Test report file: " + TEST_REPORT_PATH + " was not be deleted."); - } - - /** - * Validates that test reports were generated. - */ - @Override - public void validateTestReportsExist() { - TestUtils.validateTestReportExists(TEST_REPORT_PATH, TEST_REPORT_PATH); - } - - /** - * Returns the build type category (either MAVEN_TYPE or GRADLE_TYPE) - */ - @Override - public BuildType getBuildCategory() { - return BUILD_CATEGORY; + GradleSingleModMPSIDProjectTest() { + // set the new locations for the test, not the original locations + setProjectsDirPath(PROJECTS_PATH_NEW); + setTestReportPath(Paths.get(PROJECTS_PATH_NEW, SM_MP_PROJECT_NAME_NEW, "build", "reports", "tests", "test", "index.html")); + setSmMPProjectName(SM_MP_PROJECT_NAME_NEW); + setBuildCategory(BuildType.GRADLE_TYPE); + setSmMpProjPort(9080); + setSmMpProjResURI("api/resource"); + setSmMPProjOutput("Hello! Welcome to Open Liberty"); + setWLPInstallPath("build"); + setBuildFileName("build.gradle"); + setBuildFileOpenCommand("Liberty: View Gradle config"); + setStartParams("--hotTests"); + setStartParamsDebugPort("--libertyDebugPort=9876"); } } \ No newline at end of file diff --git a/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModNLTRestProjectTest.java b/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModNLTRestProjectTest.java index 2cc22b776..247e2e340 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModNLTRestProjectTest.java +++ b/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModNLTRestProjectTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023 IBM Corporation. + * Copyright (c) 2023, 2024 IBM Corporation. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -19,10 +19,6 @@ * Tests that use a single module non Liberty Tools compliant REST Gradle project. */ public class GradleSingleModNLTRestProjectTest extends SingleModNLTRestProjectTestCommon { - /** - * The path to the folder containing helper test files. - */ - public static String HELPER_FILES_PATH = Paths.get("src", "test", "resources", "files", "smNLTRestProject", "gradle").toAbsolutePath().toString(); /** * The path to the folder containing the test projects. @@ -34,11 +30,6 @@ public class GradleSingleModNLTRestProjectTest extends SingleModNLTRestProjectTe */ private static final String SM_NLT_REST_PROJECT_NAME = "singleModGradleRESTNoLTXmlCfg"; - /** - * Build file name. - */ - private final String BUILD_FILE_NAME = "build.gradle"; - /** * Prepares the environment for test execution. */ @@ -47,47 +38,11 @@ public static void setup() { prepareEnv(PROJECTS_PATH, SM_NLT_REST_PROJECT_NAME); } - /** - * Returns the directory path containing helper files. - * - * @return The directory path containing helper files. - */ - public String getHelperFilesDirPath() { - return HELPER_FILES_PATH; - } - - /** - * Returns the projects directory path. - * - * @return The projects directory path. - */ - @Override - public String getProjectsDirPath() { - return PROJECTS_PATH; - } - - /** - * Returns the name of the single module REST project that does not meet - * the requirements needed to automatically show in the Liberty tool window. - * This project's Liberty config file does not the expected name and the - * build file does not have any Liberty plugin related entries. - * - * @return The name of the single module REST project that does not meet the - * requirements needed to automatically show in the Liberty tool window. - */ - @Override - public String getSmNLTRestProjectName() { - return SM_NLT_REST_PROJECT_NAME; - } - - /** - * Returns the name of the build file used by the project. - * - * @return The name of the build file used by the project. - */ - @Override - public String getBuildFileName() { - return BUILD_FILE_NAME; + GradleSingleModNLTRestProjectTest() { + setProjectsDirPath(PROJECTS_PATH); + setSmNLTRestProjectName(SM_NLT_REST_PROJECT_NAME); + setBuildFileName("build.gradle"); + setHelperFilesDirPath(Paths.get("src", "test", "resources", "files", "smNLTRestProject", "gradle").toAbsolutePath().toString()); } /** 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 8b49902cc..4e0005051 100755 --- a/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPProjectTest.java +++ b/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPProjectTest.java @@ -32,41 +32,6 @@ public class MavenSingleModMPProjectTest extends SingleModMPProjectTestCommon { */ private static final String PROJECTS_PATH = Paths.get("src", "test", "resources", "projects", "maven").toAbsolutePath().toString(); - /** - * Project port. - */ - private final int SM_MP_PROJECT_PORT = 9080; - - /** - * Project resource URI. - */ - private final String SM_MP_PROJECT_RES_URI = "api/resource"; - - /** - * Project response. - */ - private final String SM_MP_PROJECT_OUTPUT = "Hello! Welcome to Open Liberty"; - - /** - * Relative location of the WLP installation. - */ - private final String WLP_INSTALL_PATH = Paths.get("target", "liberty").toString(); - - /** - * Build file name. - */ - private final String BUILD_FILE_NAME = "pom.xml"; - - /** - * Build Category. - */ - private final BuildType BUILD_CATEGORY = BuildType.MAVEN_TYPE; - - /** - * Action command to open the build file. - */ - private final String BUILD_FILE_OPEN_CMD = "Liberty: View pom.xml"; - /** * 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. */ @@ -79,16 +44,6 @@ public class MavenSingleModMPProjectTest extends SingleModMPProjectTestCommon { private final Path pathToUTReport34 = Paths.get(PROJECTS_PATH, SM_MP_PROJECT_NAME, "target", "site", "surefire-report.html"); private final Path pathToUTReport35 = Paths.get(PROJECTS_PATH, SM_MP_PROJECT_NAME, "target", "reports", "surefire.html"); - /** - * Dev mode configuration start parameters. - */ - private final String DEV_MODE_START_PARAMS = "-DhotTests=true"; - - /** - * Dev mode configuration custom start parameters for debugging. - */ - private final String DEV_MODE_START_PARAMS_DEBUG = "-DdebugPort=9876"; - /** * Prepares the environment for test execution. */ @@ -98,108 +53,20 @@ public static void setup() { prepareEnv(PROJECTS_PATH, SM_MP_PROJECT_NAME); } - /** - * Returns the path where the Liberty server was installed. - * - * @return The path where the Liberty server was installed. - */ - @Override - public String getWLPInstallPath() { - return WLP_INSTALL_PATH; - } - - /** - * Returns the projects directory path. - * - * @return The projects directory path. - */ - @Override - public String getProjectsDirPath() { - return PROJECTS_PATH; - } - - /** - * Returns the name of the single module MicroProfile project. - * - * @return The name of the single module MicroProfile project. - */ - @Override - public String getSmMPProjectName() { - return SM_MP_PROJECT_NAME; + MavenSingleModMPProjectTest() { + setProjectsDirPath(PROJECTS_PATH); + 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()); + setTestReportPath(Paths.get(getProjectsDirPath(), getSmMPProjectName(), "build", "reports", "tests", "test", "index.html")); + setBuildFileName("pom.xml"); + setBuildFileOpenCommand("Liberty: View pom.xml"); + setStartParams("-DhotTests=true"); + setStartParamsDebugPort("-DdebugPort=9876"); } - - /** - * Returns the expected HTTP response payload associated with the single module - * MicroProfile project. - * - * @return The expected HTTP response payload associated with the single module - * MicroProfile project. - */ - @Override - public String getSmMPProjOutput() { - return SM_MP_PROJECT_OUTPUT; - } - - /** - * Returns the port number associated with the single module MicroProfile project. - * - * @return The port number associated with the single module MicroProfile project. - */ - @Override - public int getSmMpProjPort() { - return SM_MP_PROJECT_PORT; - } - - /** - * Return the Resource URI associated with the single module MicroProfile project. - * - * @return The Resource URI associated with the single module MicroProfile project. - */ - @Override - public String getSmMpProjResURI() { - return SM_MP_PROJECT_RES_URI; - } - - /** - * Returns the name of the build file used by the project. - * - * @return The name of the build file used by the project. - */ - @Override - public String getBuildFileName() { - return BUILD_FILE_NAME; - } - - /** - * Returns the name of the custom action command used to open the build file. - * - * @return The name of the custom action command used to open the build file. - */ - @Override - public String getBuildFileOpenCommand() { - return BUILD_FILE_OPEN_CMD; - } - - /** - * Returns the custom start parameters to be used to start dev mode. - * - * @return The custom start parameters to be used to start dev mode. - */ - @Override - public String getStartParams() { - return DEV_MODE_START_PARAMS; - } - - /** - * Returns the custom start parameters for debugging to start dev mode. - * - * @return The custom start parameters for debugging to start dev mode. - */ - @Override - public String getStartParamsDebugPort() { - return DEV_MODE_START_PARAMS_DEBUG; - } - /** * Deletes test reports. */ @@ -224,12 +91,4 @@ public void validateTestReportsExist() { TestUtils.validateTestReportExists(pathToITReport34, pathToITReport35); TestUtils.validateTestReportExists(pathToUTReport34, pathToUTReport35); } - - /** - * Returns the build type category (either MAVEN_TYPE or GRADLE_TYPE) - */ - @Override - public BuildType getBuildCategory() { - return BUILD_CATEGORY; - } } 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 f9322b814..b2c36acf7 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPSIDProjectTest.java +++ b/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPSIDProjectTest.java @@ -39,40 +39,6 @@ public class MavenSingleModMPSIDProjectTest extends SingleModMPProjectTestCommon */ private static final String PROJECTS_PATH_NEW = Paths.get("src", "test", "resources", "projects", "maven sample").toAbsolutePath().toString(); - /** - * Project port. - */ - private final int SM_MP_PROJECT_PORT = 9080; - - /** - * Project resource URI. - */ - private final String SM_MP_PROJECT_RES_URI = "api/resource"; - - /** - * Project response. - */ - private final String SM_MP_PROJECT_OUTPUT = "Hello! Welcome to Open Liberty"; - - /** - * Relative location of the WLP installation. - */ - private final String WLP_INSTALL_PATH = Paths.get("target", "liberty").toString(); - - /** - * Build file name. - */ - private final String BUILD_FILE_NAME = "pom.xml"; - - /** - * Build Category. - */ - private final BuildType BUILD_CATEGORY = BuildType.MAVEN_TYPE; - - /** - * Action command to open the build file. - */ - private final String BUILD_FILE_OPEN_CMD = "Liberty: View pom.xml"; /** * 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. */ @@ -85,16 +51,6 @@ public class MavenSingleModMPSIDProjectTest extends SingleModMPProjectTestCommon private final Path pathToUTReport34 = Paths.get(PROJECTS_PATH_NEW, SM_MP_PROJECT_NAME, "target", "site", "surefire-report.html"); private final Path pathToUTReport35 = Paths.get(PROJECTS_PATH_NEW, SM_MP_PROJECT_NAME, "target", "reports", "surefire.html"); - /** - * Dev mode configuration start parameters. - */ - private final String DEV_MODE_START_PARAMS = "-DhotTests=true"; - - /** - * Dev mode configuration custom start parameters for debugging. - */ - private final String DEV_MODE_START_PARAMS_DEBUG = "-DdebugPort=9876"; - /** * Prepares the environment for test execution. */ @@ -124,106 +80,20 @@ public static void cleanup() { } } - /** - * Returns the path where the Liberty server was installed. - * - * @return The path where the Liberty server was installed. - */ - @Override - public String getWLPInstallPath() { - return WLP_INSTALL_PATH; - } - - /** - * Returns the projects new directory path. - * - * @return The projects new directory path. - */ - @Override - public String getProjectsDirPath() { - return PROJECTS_PATH_NEW; - } - - /** - * Returns the name of the single module MicroProfile project. - * - * @return The name of the single module MicroProfile project. - */ - @Override - public String getSmMPProjectName() { - return SM_MP_PROJECT_NAME; - } - - /** - * Returns the expected HTTP response payload associated with the single module - * MicroProfile project. - * - * @return The expected HTTP response payload associated with the single module - * MicroProfile project. - */ - @Override - public String getSmMPProjOutput() { - return SM_MP_PROJECT_OUTPUT; - } - - /** - * Returns the port number associated with the single module MicroProfile project. - * - * @return The port number associated with the single module MicroProfile project. - */ - @Override - public int getSmMpProjPort() { - return SM_MP_PROJECT_PORT; - } - - /** - * Return the Resource URI associated with the single module MicroProfile project. - * - * @return The Resource URI associated with the single module MicroProfile project. - */ - @Override - public String getSmMpProjResURI() { - return SM_MP_PROJECT_RES_URI; - } - - /** - * Returns the name of the build file used by the project. - * - * @return The name of the build file used by the project. - */ - @Override - public String getBuildFileName() { - return BUILD_FILE_NAME; - } - - /** - * Returns the name of the custom action command used to open the build file. - * - * @return The name of the custom action command used to open the build file. - */ - @Override - public String getBuildFileOpenCommand() { - return BUILD_FILE_OPEN_CMD; - } - - /** - * Returns the custom start parameters to be used to start dev mode. - * - * @return The custom start parameters to be used to start dev mode. - */ - @Override - public String getStartParams() { - return DEV_MODE_START_PARAMS; - } - - /** - * Returns the custom start parameters for debugging to start dev mode. - * - * @return The custom start parameters for debugging to start dev mode. - */ - @Override - public String getStartParamsDebugPort() { - return DEV_MODE_START_PARAMS_DEBUG; + MavenSingleModMPSIDProjectTest() { + // set the new locations for the test, not the original locations + setProjectsDirPath(PROJECTS_PATH_NEW); + setTestReportPath(Paths.get(PROJECTS_PATH_NEW, 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"); } /** @@ -250,12 +120,4 @@ public void validateTestReportsExist() { TestUtils.validateTestReportExists(pathToITReport34, pathToITReport35); TestUtils.validateTestReportExists(pathToUTReport34, pathToUTReport35); } - - /** - * Returns the build type category (either MAVEN_TYPE or GRADLE_TYPE) - */ - @Override - public BuildType getBuildCategory() { - return BUILD_CATEGORY; - } } diff --git a/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModNLTRestProjectTest.java b/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModNLTRestProjectTest.java index 86be9985b..91ca3026a 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModNLTRestProjectTest.java +++ b/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModNLTRestProjectTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023 IBM Corporation. + * Copyright (c) 2023, 2024 IBM Corporation. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -17,10 +17,6 @@ * Tests that use a single module non Liberty Tools compliant REST Maven project. */ public class MavenSingleModNLTRestProjectTest extends SingleModNLTRestProjectTestCommon { - /** - * The path to the folder containing helper test files. - */ - public static String HELPER_FILES_PATH = Paths.get("src", "test", "resources", "files", "smNLTRestProject", "maven").toAbsolutePath().toString(); /** * The path to the folder containing the test projects. @@ -32,11 +28,6 @@ public class MavenSingleModNLTRestProjectTest extends SingleModNLTRestProjectTes */ private static final String SM_NLT_REST_PROJECT_NAME = "singleModMavenRESTNoLTXmlCfg"; - /** - * Build file name. - */ - private final String BUILD_FILE_NAME = "pom.xml"; - /** * Prepares the environment for test execution. */ @@ -45,46 +36,10 @@ public static void setup() { prepareEnv(PROJECTS_PATH, SM_NLT_REST_PROJECT_NAME); } - /** - * Returns the directory path containing helper files. - * - * @return The directory path containing helper files. - */ - public String getHelperFilesDirPath() { - return HELPER_FILES_PATH; - } - - /** - * Returns the projects directory path. - * - * @return The projects directory path. - */ - @Override - public String getProjectsDirPath() { - return PROJECTS_PATH; - } - - /** - * Returns the name of the single module REST project that does not meet - * the requirements needed to automatically show in the Liberty tool window. - * This project's Liberty config file does not the expected name and the - * build file does not have any Liberty plugin related entries. - * - * @return The name of the single module REST project that does not meet the - * requirements needed to automatically show in the Liberty tool window. - */ - @Override - public String getSmNLTRestProjectName() { - return SM_NLT_REST_PROJECT_NAME; - } - - /** - * Returns the name of the build file used by the project. - * - * @return The name of the build file used by the project. - */ - @Override - public String getBuildFileName() { - return BUILD_FILE_NAME; + MavenSingleModNLTRestProjectTest() { + setProjectsDirPath(PROJECTS_PATH); + setSmNLTRestProjectName(SM_NLT_REST_PROJECT_NAME); + setBuildFileName("pom.xml"); + setHelperFilesDirPath(Paths.get("src", "test", "resources", "files", "smNLTRestProject", "maven").toAbsolutePath().toString()); } } diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java index edd6caf12..685b9fbbd 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java @@ -1,3 +1,12 @@ +/******************************************************************************* + * Copyright (c) 2023 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 com.automation.remarks.junit5.Video; 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 7bf790d09..8169d7003 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -1,3 +1,12 @@ +/******************************************************************************* + * Copyright (c) 2023 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 com.automation.remarks.junit5.Video; 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 b162b7858..5ea6e7cdd 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java @@ -1,3 +1,12 @@ +/******************************************************************************* + * Copyright (c) 2023 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 com.automation.remarks.junit5.Video; 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 2b2845045..eda258d06 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java @@ -22,6 +22,7 @@ import java.awt.Point; import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.nio.file.Paths; import java.time.Duration; import java.util.Map; @@ -57,6 +58,206 @@ public enum BuildType { */ public static final RemoteRobot remoteRobot = new RemoteRobot(REMOTE_BOT_URL); + /** + * Single module Microprofile project name. + */ + private String smMpProjectName = null; + + /** + * The path to the folder containing the test projects. + */ + private String projectsPath = null; + + /** + * Project port. + */ + private int smMpProjectPort = 0; + + /** + * Project resource URI. + */ + private String smMpProjectResUri = null; + + /** + * Project response. + */ + private String smMpProjectOutput = null; + + /** + * Relative location of the WLP installation. + */ + private String wlpInstallPath = null; + + /** + * The path to the test report. + */ + private Path testReportPath = null; + + /** + * Build file name. + */ + private String buildFileName = null; + + /** + * Action command to open the build file. + */ + private String buildFileOpenCmd = null; + + /** + * Dev mode configuration start parameters. + */ + private String devModeStartParams = null; + + /** + * Dev mode configuration custom start parameters for debugging. + */ + private String devModeStartParamsDebug = null; + + /** + * Build Category. + */ + private BuildType buildCategory = null; + + /** + * Returns the path where the Liberty server was installed. + * + * @return The path where the Liberty server was installed. + */ + public String getWLPInstallPath() { + return wlpInstallPath; + } + public void setWLPInstallPath(String path) { + wlpInstallPath = path; + } + + /** + * Sets the path where the Liberty server stores test reports. + * + */ + public void setTestReportPath(Path path) { + testReportPath = path; + } + + /** + * Returns the projects directory path. + * + * @return The projects directory path. + */ + public String getProjectsDirPath() { + return projectsPath; + } + public void setProjectsDirPath(String path) { + projectsPath = path; + } + + /** + * Returns the name of the single module MicroProfile project. + * + * @return The name of the single module MicroProfile project. + */ + public String getSmMPProjectName() { + return smMpProjectName; + } + public void setSmMPProjectName(String name) { + smMpProjectName = name; + } + + /** + * Returns the expected HTTP response payload associated with the single module + * MicroProfile project. + * + * @return The expected HTTP response payload associated with the single module + * MicroProfile project. + */ + public String getSmMPProjOutput() { + return smMpProjectOutput; + } + public void setSmMPProjOutput(String s) { + smMpProjectOutput = s; + } + + /** + * Returns the port number associated with the single module MicroProfile project. + * + * @return The port number associated with the single module MicroProfile project. + */ + public int getSmMpProjPort() { + return smMpProjectPort; + } + public void setSmMpProjPort(int port) { + smMpProjectPort = port; + } + + /** + * Return the Resource URI associated with the single module MicroProfile project. + * + * @return The Resource URI associated with the single module MicroProfile project. + */ + public String getSmMpProjResURI() { + return smMpProjectResUri; + } + public void setSmMpProjResURI(String uri) { + smMpProjectResUri = uri; + } + + /** + * Returns the name of the build file used by the project. + * + * @return The name of the build file used by the project. + */ + public String getBuildFileName() { + return buildFileName; + } + public void setBuildFileName(String name) { + buildFileName = name; + } + + /** + * Returns the name of the custom action command used to open the build file. + * + * @return The name of the custom action command used to open the build file. + */ + public String getBuildFileOpenCommand() { + return buildFileOpenCmd; + } + public void setBuildFileOpenCommand(String command) { + buildFileOpenCmd = command; + } + + /** + * Returns the custom start parameters to be used to start dev mode. + * + * @return The custom start parameters to be used to start dev mode. + */ + public String getStartParams() { + return devModeStartParams; + } + public void setStartParams(String params) { + devModeStartParams = params; + } + + /** + * Returns the custom start parameters for debugging to start dev mode. + * + * @return The custom start parameters for debugging to start dev mode. + */ + public String getStartParamsDebugPort() { + return devModeStartParamsDebug; + } + public void setStartParamsDebugPort(String params) { + devModeStartParamsDebug = params; + } + + /** + * Returns Build Category + */ + public BuildType getBuildCategory() { + return buildCategory; + }; + public void setBuildCategory(BuildType type) { + buildCategory = type; + }; + /** * Processes actions before each test. * @@ -1048,7 +1249,7 @@ public void stopTerminal() { } else if (getBuildCategory() == BuildType.GRADLE_TYPE) { keyboard.enterText("./gradlew libertyStop"); } else { - TestUtils.printTrace(TestUtils.TraceSevLevel.INFO, "Invalid build type specified"); + TestUtils.printTrace(TestUtils.TraceSevLevel.ERROR, "Invalid build type specified"); return; } keyboard.enter(); @@ -1067,7 +1268,7 @@ public void cleanTerminal() { } else if (getBuildCategory() == BuildType.GRADLE_TYPE) { keyboard.enterText("./gradlew clean"); } else { - TestUtils.printTrace(TestUtils.TraceSevLevel.INFO, "Invalid build type specified"); + TestUtils.printTrace(TestUtils.TraceSevLevel.ERROR, "Invalid build type specified"); return; } keyboard.enter(); @@ -1085,90 +1286,20 @@ public void cleanAndResetTerminal() { UIBotTestUtils.closeTerminalTabs(remoteRobot); } - /** - * Returns the projects directory path. - * - * @return The projects directory path. - */ - public abstract String getProjectsDirPath(); - - /** - * Returns the name of the single module MicroProfile project. - * - * @return The name of the single module MicroProfile project. - */ - public abstract String getSmMPProjectName(); - - /** - * Returns the expected HTTP response payload associated with the single module - * MicroProfile project. - * - * @return The expected HTTP response payload associated with the single module - * MicroProfile project. - */ - public abstract String getSmMPProjOutput(); - - /** - * Returns the port number associated with the single module MicroProfile project. - * - * @return The port number associated with the single module MicroProfile project. - */ - public abstract int getSmMpProjPort(); - - /** - * Return the Resource URI associated with the single module MicroProfile project. - * - * @return The Resource URI associated with the single module MicroProfile project. - */ - public abstract String getSmMpProjResURI(); - - /** - * Returns the path where the Liberty server was installed. - * - * @return The path where the Liberty server was installed. - */ - public abstract String getWLPInstallPath(); - - /** - * Returns the name of the build file used by the project. - * - * @return The name of the build file used by the project. - */ - public abstract String getBuildFileName(); - - /** - * Returns the name of the custom action command used to open the build file. - * - * @return The name of the custom action command used to open the build file. - */ - public abstract String getBuildFileOpenCommand(); - - /** - * Returns the custom start parameters to be used to start dev mode. - * - * @return The custom start parameters to be used to start dev mode. - */ - public abstract String getStartParams(); - - /** - * Returns the custom start parameters to be used to start dev mode. - * - * @return The custom start parameters to be used to start dev mode. - */ - public abstract String getStartParamsDebugPort(); - /** * Deletes test reports. */ - public abstract void deleteTestReports(); + public void deleteTestReports() { + boolean testReportDeleted = TestUtils.deleteFile(testReportPath); + Assertions.assertTrue(testReportDeleted, () -> "Test report file: " + testReportPath + " was not be deleted."); + } /** * Validates that test reports were generated. */ - public abstract void validateTestReportsExist(); - /** - * Returns Build Category - */ - public abstract BuildType getBuildCategory(); + public void validateTestReportsExist() { + //TODO: rewrite validateTestReportExists() to accept one argument or to accept a null as the second argument + TestUtils.validateTestReportExists(testReportPath, testReportPath); + } } \ No newline at end of file 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 dd429f743..79d23894a 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023 IBM Corporation. + * Copyright (c) 2023, 2024 IBM Corporation. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -39,6 +39,26 @@ public abstract class SingleModNLTRestProjectTestCommon { */ public static final RemoteRobot remoteRobot = new RemoteRobot(REMOTE_BOT_URL); + /** + * The path to the folder containing helper test files. + */ + public String helperFilesPath = null; + + /** + * The path to the folder containing the test projects. + */ + private String projectsPath = null; + + /** + * Single module REST project that lacks the configuration to be recognized by Liberty tools. + */ + private String smNLTRestProjectName = null; + + /** + * Build file name. + */ + private String buildFileName = null; + /** * Processes actions before each test. * @@ -70,6 +90,58 @@ public static void cleanup() { UIBotTestUtils.validateProjectFrameClosed(remoteRobot); } + /** + * Returns the directory path containing helper files. + * + * @return The directory path containing helper files. + */ + public String getHelperFilesDirPath() { + return helperFilesPath; + } + public void setHelperFilesDirPath(String path) { + helperFilesPath = path; + } + + /** + * Returns the projects directory path. + * + * @return The projects directory path. + */ + public String getProjectsDirPath() { + return projectsPath; + } + public void setProjectsDirPath(String path) { + projectsPath = path; + } + + /** + * Returns the name of the single module REST project that does not meet + * the requirements needed to automatically show in the Liberty tool window. + * This project's Liberty config file does not the expected name and the + * build file does not have any Liberty plugin related entries. + * + * @return The name of the single module REST project that does not meet the + * requirements needed to automatically show in the Liberty tool window. + */ + public String getSmNLTRestProjectName() { + return smNLTRestProjectName; + } + public void setSmNLTRestProjectName(String name) { + smNLTRestProjectName = name; + } + + /** + * Returns the name of the build file used by the project. + * + * @return The name of the build file used by the project. + */ + public String getBuildFileName() { + return buildFileName; + } + public void setBuildFileName(String name) { + buildFileName = name; + } + /** * Tests manually Adding/Removing project from the tool window using the Liberty add/remove * options available through search everywhere panel. @@ -238,36 +310,4 @@ public static void prepareEnv(String projectPath, String projectName) { TestUtils.printTrace(TestUtils.TraceSevLevel.INFO, "prepareEnv. Exit. ProjectName: " + projectName); } - - /** - * Returns the directory path containing helper files. - * - * @return The directory path containing helper files. - */ - public abstract String getHelperFilesDirPath(); - - /** - * Returns the projects directory path. - * - * @return The projects directory path. - */ - public abstract String getProjectsDirPath(); - - /** - * Returns the name of the single module REST project that does not meet - * the requirements needed to automatically show in the Liberty tool window. - * This project's Liberty config file does not have the expected default name, - * and the build file does not have any Liberty plugin related entries. - * - * @return The name of the single module REST project that does not meet the - * requirements needed to automatically show in the Liberty tool window. - */ - public abstract String getSmNLTRestProjectName(); - - /** - * Returns the name of the build file used by the project. - * - * @return The name of the build file used by the project. - */ - public abstract String getBuildFileName(); }