Skip to content

Commit fbe834d

Browse files
committed
Refactor the NLT UI tests to move common elements to the base class
Signed-off-by: Paul Gooderham <[email protected]>
1 parent 36e1d13 commit fbe834d

File tree

3 files changed

+85
-159
lines changed

3 files changed

+85
-159
lines changed

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

Lines changed: 6 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2023 IBM Corporation.
2+
* Copyright (c) 2023, 2024 IBM Corporation.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -19,75 +19,18 @@
1919
* Tests that use a single module non Liberty Tools compliant REST Gradle project.
2020
*/
2121
public class GradleSingleModNLTRestProjectTest extends SingleModNLTRestProjectTestCommon {
22-
/**
23-
* The path to the folder containing helper test files.
24-
*/
25-
public static String HELPER_FILES_PATH = Paths.get("src", "test", "resources", "files", "smNLTRestProject", "gradle").toAbsolutePath().toString();
26-
27-
/**
28-
* The path to the folder containing the test projects.
29-
*/
30-
private static final String PROJECTS_PATH = Paths.get("src", "test", "resources", "projects", "gradle").toAbsolutePath().toString();
31-
32-
/**
33-
* Single module REST project that lacks the configuration to be recognized by Liberty tools.
34-
*/
35-
private static final String SM_NLT_REST_PROJECT_NAME = "singleModGradleRESTNoLTXmlCfg";
36-
37-
/**
38-
* Build file name.
39-
*/
40-
private final String BUILD_FILE_NAME = "build.gradle";
4122

4223
/**
4324
* Prepares the environment for test execution.
4425
*/
4526
@BeforeAll
4627
public static void setup() {
47-
prepareEnv(PROJECTS_PATH, SM_NLT_REST_PROJECT_NAME);
48-
}
49-
50-
/**
51-
* Returns the directory path containing helper files.
52-
*
53-
* @return The directory path containing helper files.
54-
*/
55-
public String getHelperFilesDirPath() {
56-
return HELPER_FILES_PATH;
57-
}
58-
59-
/**
60-
* Returns the projects directory path.
61-
*
62-
* @return The projects directory path.
63-
*/
64-
@Override
65-
public String getProjectsDirPath() {
66-
return PROJECTS_PATH;
67-
}
28+
setSmNLTRestProjectName("singleModGradleRESTNoLTXmlCfg");
29+
setProjectsDirPath(Paths.get("src", "test", "resources", "projects", "gradle").toAbsolutePath().toString());
30+
setBuildFileName("build.gradle");
31+
setHelperFilesDirPath(Paths.get("src", "test", "resources", "files", "smNLTRestProject", "gradle").toAbsolutePath().toString());
6832

69-
/**
70-
* Returns the name of the single module REST project that does not meet
71-
* the requirements needed to automatically show in the Liberty tool window.
72-
* This project's Liberty config file does not the expected name and the
73-
* build file does not have any Liberty plugin related entries.
74-
*
75-
* @return The name of the single module REST project that does not meet the
76-
* requirements needed to automatically show in the Liberty tool window.
77-
*/
78-
@Override
79-
public String getSmNLTRestProjectName() {
80-
return SM_NLT_REST_PROJECT_NAME;
81-
}
82-
83-
/**
84-
* Returns the name of the build file used by the project.
85-
*
86-
* @return The name of the build file used by the project.
87-
*/
88-
@Override
89-
public String getBuildFileName() {
90-
return BUILD_FILE_NAME;
33+
prepareEnv(getProjectsDirPath(), getSmNLTRestProjectName());
9134
}
9235

9336
/**
Lines changed: 6 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2023 IBM Corporation.
2+
* Copyright (c) 2023, 2024 IBM Corporation.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -17,74 +17,17 @@
1717
* Tests that use a single module non Liberty Tools compliant REST Maven project.
1818
*/
1919
public class MavenSingleModNLTRestProjectTest extends SingleModNLTRestProjectTestCommon {
20-
/**
21-
* The path to the folder containing helper test files.
22-
*/
23-
public static String HELPER_FILES_PATH = Paths.get("src", "test", "resources", "files", "smNLTRestProject", "maven").toAbsolutePath().toString();
24-
25-
/**
26-
* The path to the folder containing the test projects.
27-
*/
28-
private static final String PROJECTS_PATH = Paths.get("src", "test", "resources", "projects", "maven").toAbsolutePath().toString();
29-
30-
/**
31-
* Single module REST project that lacks the configuration to be recognized by Liberty tools.
32-
*/
33-
private static final String SM_NLT_REST_PROJECT_NAME = "singleModMavenRESTNoLTXmlCfg";
34-
35-
/**
36-
* Build file name.
37-
*/
38-
private final String BUILD_FILE_NAME = "pom.xml";
3920

4021
/**
4122
* Prepares the environment for test execution.
4223
*/
4324
@BeforeAll
4425
public static void setup() {
45-
prepareEnv(PROJECTS_PATH, SM_NLT_REST_PROJECT_NAME);
46-
}
47-
48-
/**
49-
* Returns the directory path containing helper files.
50-
*
51-
* @return The directory path containing helper files.
52-
*/
53-
public String getHelperFilesDirPath() {
54-
return HELPER_FILES_PATH;
55-
}
56-
57-
/**
58-
* Returns the projects directory path.
59-
*
60-
* @return The projects directory path.
61-
*/
62-
@Override
63-
public String getProjectsDirPath() {
64-
return PROJECTS_PATH;
65-
}
26+
setSmNLTRestProjectName("singleModMavenRESTNoLTXmlCfg");
27+
setProjectsDirPath(Paths.get("src", "test", "resources", "projects", "maven").toAbsolutePath().toString());
28+
setBuildFileName("pom.xml");
29+
setHelperFilesDirPath(Paths.get("src", "test", "resources", "files", "smNLTRestProject", "maven").toAbsolutePath().toString());
6630

67-
/**
68-
* Returns the name of the single module REST project that does not meet
69-
* the requirements needed to automatically show in the Liberty tool window.
70-
* This project's Liberty config file does not the expected name and the
71-
* build file does not have any Liberty plugin related entries.
72-
*
73-
* @return The name of the single module REST project that does not meet the
74-
* requirements needed to automatically show in the Liberty tool window.
75-
*/
76-
@Override
77-
public String getSmNLTRestProjectName() {
78-
return SM_NLT_REST_PROJECT_NAME;
79-
}
80-
81-
/**
82-
* Returns the name of the build file used by the project.
83-
*
84-
* @return The name of the build file used by the project.
85-
*/
86-
@Override
87-
public String getBuildFileName() {
88-
return BUILD_FILE_NAME;
31+
prepareEnv(getProjectsDirPath(), getSmNLTRestProjectName());
8932
}
9033
}

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

Lines changed: 73 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2023 IBM Corporation.
2+
* Copyright (c) 2023, 2024 IBM Corporation.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -39,6 +39,26 @@ public abstract class SingleModNLTRestProjectTestCommon {
3939
*/
4040
public static final RemoteRobot remoteRobot = new RemoteRobot(REMOTE_BOT_URL);
4141

42+
/**
43+
* The path to the folder containing helper test files.
44+
*/
45+
public static String helperFilesPath = null;
46+
47+
/**
48+
* The path to the folder containing the test projects.
49+
*/
50+
private static String projectsPath = null;
51+
52+
/**
53+
* Single module REST project that lacks the configuration to be recognized by Liberty tools.
54+
*/
55+
private static String smNLTRestProjectName = null;
56+
57+
/**
58+
* Build file name.
59+
*/
60+
private static String buildFileName = null;
61+
4262
/**
4363
* Processes actions before each test.
4464
*
@@ -70,6 +90,58 @@ public static void cleanup() {
7090
UIBotTestUtils.validateProjectFrameClosed(remoteRobot);
7191
}
7292

93+
/**
94+
* Returns the directory path containing helper files.
95+
*
96+
* @return The directory path containing helper files.
97+
*/
98+
public static String getHelperFilesDirPath() {
99+
return helperFilesPath;
100+
}
101+
public static void setHelperFilesDirPath(String path) {
102+
helperFilesPath = path;
103+
}
104+
105+
/**
106+
* Returns the projects directory path.
107+
*
108+
* @return The projects directory path.
109+
*/
110+
public static String getProjectsDirPath() {
111+
return projectsPath;
112+
}
113+
public static void setProjectsDirPath(String path) {
114+
projectsPath = path;
115+
}
116+
117+
/**
118+
* Returns the name of the single module REST project that does not meet
119+
* the requirements needed to automatically show in the Liberty tool window.
120+
* This project's Liberty config file does not the expected name and the
121+
* build file does not have any Liberty plugin related entries.
122+
*
123+
* @return The name of the single module REST project that does not meet the
124+
* requirements needed to automatically show in the Liberty tool window.
125+
*/
126+
public static String getSmNLTRestProjectName() {
127+
return smNLTRestProjectName;
128+
}
129+
public static void setSmNLTRestProjectName(String name) {
130+
smNLTRestProjectName = name;
131+
}
132+
133+
/**
134+
* Returns the name of the build file used by the project.
135+
*
136+
* @return The name of the build file used by the project.
137+
*/
138+
public static String getBuildFileName() {
139+
return buildFileName;
140+
}
141+
public static void setBuildFileName(String name) {
142+
buildFileName = name;
143+
}
144+
73145
/**
74146
* Tests manually Adding/Removing project from the tool window using the Liberty add/remove
75147
* options available through search everywhere panel.
@@ -238,36 +310,4 @@ public static void prepareEnv(String projectPath, String projectName) {
238310
TestUtils.printTrace(TestUtils.TraceSevLevel.INFO,
239311
"prepareEnv. Exit. ProjectName: " + projectName);
240312
}
241-
242-
/**
243-
* Returns the directory path containing helper files.
244-
*
245-
* @return The directory path containing helper files.
246-
*/
247-
public abstract String getHelperFilesDirPath();
248-
249-
/**
250-
* Returns the projects directory path.
251-
*
252-
* @return The projects directory path.
253-
*/
254-
public abstract String getProjectsDirPath();
255-
256-
/**
257-
* Returns the name of the single module REST project that does not meet
258-
* the requirements needed to automatically show in the Liberty tool window.
259-
* This project's Liberty config file does not have the expected default name,
260-
* and the build file does not have any Liberty plugin related entries.
261-
*
262-
* @return The name of the single module REST project that does not meet the
263-
* requirements needed to automatically show in the Liberty tool window.
264-
*/
265-
public abstract String getSmNLTRestProjectName();
266-
267-
/**
268-
* Returns the name of the build file used by the project.
269-
*
270-
* @return The name of the build file used by the project.
271-
*/
272-
public abstract String getBuildFileName();
273313
}

0 commit comments

Comments
 (0)