Skip to content

Commit fb1762e

Browse files
authored
Merge pull request #1083 from turkeylurkey/refactor-IT
Refactor the automated UI tests for easier maintenance
2 parents 14e0597 + ad42003 commit fb1762e

11 files changed

+378
-876
lines changed

src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPProjectTest.java

Lines changed: 13 additions & 179 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,14 @@
99
*******************************************************************************/
1010
package io.openliberty.tools.intellij.it;
1111

12-
import org.junit.jupiter.api.Assertions;
1312
import org.junit.jupiter.api.BeforeAll;
1413

15-
import java.nio.file.Path;
1614
import java.nio.file.Paths;
1715

1816
/**
1917
* Tests Liberty Tools actions using a single module MicroProfile Gradle project.
2018
*/
2119
public class GradleSingleModMPProjectTest extends SingleModMPProjectTestCommon {
22-
2320
/**
2421
* Single module Microprofile project name.
2522
*/
@@ -30,56 +27,6 @@ public class GradleSingleModMPProjectTest extends SingleModMPProjectTestCommon {
3027
*/
3128
private static final String PROJECTS_PATH = Paths.get("src", "test", "resources", "projects", "gradle").toAbsolutePath().toString();
3229

33-
/**
34-
* Project port.
35-
*/
36-
private final int SM_MP_PROJECT_PORT = 9080;
37-
38-
/**
39-
* Project resource URI.
40-
*/
41-
private final String SM_MP_PROJECT_RES_URI = "api/resource";
42-
43-
/**
44-
* Project response.
45-
*/
46-
private final String SM_MP_PROJECT_OUTPUT = "Hello! Welcome to Open Liberty";
47-
48-
/**
49-
* Relative location of the WLP installation.
50-
*/
51-
private final String WLP_INSTALL_PATH = "build";
52-
53-
/**
54-
* The path to the test report.
55-
*/
56-
private final Path TEST_REPORT_PATH = Paths.get(PROJECTS_PATH, SM_MP_PROJECT_NAME, "build", "reports", "tests", "test", "index.html");
57-
58-
/**
59-
* Build file name.
60-
*/
61-
private final String BUILD_FILE_NAME = "build.gradle";
62-
63-
/**
64-
* Build Category.
65-
*/
66-
private final BuildType BUILD_CATEGORY = BuildType.GRADLE_TYPE;
67-
68-
/**
69-
* Action command to open the build file.
70-
*/
71-
private final String BUILD_FILE_OPEN_CMD = "Liberty: View Gradle config";
72-
73-
/**
74-
* Dev mode configuration start parameters.
75-
*/
76-
private final String DEV_MODE_START_PARAMS = "--hotTests";
77-
78-
/**
79-
* Dev mode configuration custom start parameters for debugging.
80-
*/
81-
private final String DEV_MODE_START_PARAMS_DEBUG = "--libertyDebugPort=9876";
82-
8330
/**
8431
* Prepares the environment for test execution.
8532
*/
@@ -88,131 +35,18 @@ public static void setup() {
8835
prepareEnv(PROJECTS_PATH, SM_MP_PROJECT_NAME);
8936
}
9037

91-
/**
92-
* Returns the path where the Liberty server was installed.
93-
*
94-
* @return The path where the Liberty server was installed.
95-
*/
96-
@Override
97-
public String getWLPInstallPath() {
98-
return WLP_INSTALL_PATH;
99-
}
100-
101-
/**
102-
* Returns the projects directory path.
103-
*
104-
* @return The projects directory path.
105-
*/
106-
@Override
107-
public String getProjectsDirPath() {
108-
return PROJECTS_PATH;
109-
}
110-
111-
/**
112-
* Returns the name of the single module MicroProfile project.
113-
*
114-
* @return The name of the single module MicroProfile project.
115-
*/
116-
@Override
117-
public String getSmMPProjectName() {
118-
return SM_MP_PROJECT_NAME;
119-
}
120-
121-
/**
122-
* Returns the expected HTTP response payload associated with the single module
123-
* MicroProfile project.
124-
*
125-
* @return The expected HTTP response payload associated with the single module
126-
* MicroProfile project.
127-
*/
128-
@Override
129-
public String getSmMPProjOutput() {
130-
return SM_MP_PROJECT_OUTPUT;
131-
}
132-
133-
/**
134-
* Returns the port number associated with the single module MicroProfile project.
135-
*
136-
* @return The port number associated with the single module MicroProfile project.
137-
*/
138-
@Override
139-
public int getSmMpProjPort() {
140-
return SM_MP_PROJECT_PORT;
141-
}
142-
143-
/**
144-
* Return the Resource URI associated with the single module MicroProfile project.
145-
*
146-
* @return The Resource URI associated with the single module MicroProfile project.
147-
*/
148-
@Override
149-
public String getSmMpProjResURI() {
150-
return SM_MP_PROJECT_RES_URI;
151-
}
152-
153-
/**
154-
* Returns the name of the build file used by the project.
155-
*
156-
* @return The name of the build file used by the project.
157-
*/
158-
@Override
159-
public String getBuildFileName() {
160-
return BUILD_FILE_NAME;
161-
}
162-
163-
/**
164-
* Returns the name of the custom action command used to open the build file.
165-
*
166-
* @return The name of the custom action command used to open the build file.
167-
*/
168-
@Override
169-
public String getBuildFileOpenCommand() {
170-
return BUILD_FILE_OPEN_CMD;
171-
}
172-
173-
/**
174-
* Returns the custom start parameters to be used to start dev mode.
175-
*
176-
* @return The custom start parameters to be used to start dev mode.
177-
*/
178-
@Override
179-
public String getStartParams() {
180-
return DEV_MODE_START_PARAMS;
181-
}
182-
183-
/**
184-
* Returns the custom start parameters for debugging to start dev mode.
185-
*
186-
* @return The custom start parameters for debugging to start dev mode.
187-
*/
188-
@Override
189-
public String getStartParamsDebugPort() {
190-
return DEV_MODE_START_PARAMS_DEBUG;
191-
}
192-
193-
/**
194-
* Deletes test reports.
195-
*/
196-
@Override
197-
public void deleteTestReports() {
198-
boolean testReportDeleted = TestUtils.deleteFile(TEST_REPORT_PATH);
199-
Assertions.assertTrue(testReportDeleted, () -> "Test report file: " + TEST_REPORT_PATH + " was not be deleted.");
200-
}
201-
202-
/**
203-
* Validates that test reports were generated.
204-
*/
205-
@Override
206-
public void validateTestReportsExist() {
207-
//TODO: rewrite validateTestReportExists() to accept one argument or to accept a null as the second argument
208-
TestUtils.validateTestReportExists(TEST_REPORT_PATH, TEST_REPORT_PATH);
209-
}
210-
211-
/**
212-
* Returns the build type category (either MAVEN_TYPE or GRADLE_TYPE)
213-
*/
214-
@Override
215-
public BuildType getBuildCategory() {
216-
return BUILD_CATEGORY;
38+
GradleSingleModMPProjectTest() {
39+
setProjectsDirPath(PROJECTS_PATH);
40+
setSmMPProjectName(SM_MP_PROJECT_NAME);
41+
setBuildCategory(BuildType.GRADLE_TYPE);
42+
setSmMpProjPort(9080);
43+
setSmMpProjResURI("api/resource");
44+
setSmMPProjOutput("Hello! Welcome to Open Liberty");
45+
setWLPInstallPath("build");
46+
setTestReportPath(Paths.get(getProjectsDirPath(), getSmMPProjectName(), "build", "reports", "tests", "test", "index.html"));
47+
setBuildFileName("build.gradle");
48+
setBuildFileOpenCommand("Liberty: View Gradle config");
49+
setStartParams("--hotTests");
50+
setStartParamsDebugPort("--libertyDebugPort=9876");
21751
}
21852
}

0 commit comments

Comments
 (0)