Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add constants for string literals in UI test classes #1199

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5268e33
changed to constants in SingleModLibertyLSTestCommon and SingleModJak…
anusreelakshmi934 Dec 17, 2024
1e62f89
SingleModMPLSTestCommon file
anusreelakshmi934 Dec 17, 2024
02c2113
SingleModMPProjectTestCommon file
anusreelakshmi934 Dec 17, 2024
da9f216
SingleModNLTRestProjectTestCommon file
anusreelakshmi934 Dec 17, 2024
daa7096
modified other strings to constants
anusreelakshmi934 Dec 17, 2024
769d3d3
Moved into constants file under the test directory
anusreelakshmi934 Dec 19, 2024
fcac98e
Changed copyright year
anusreelakshmi934 Jan 2, 2025
02a2265
copyright header added
anusreelakshmi934 Jan 2, 2025
ce62614
SingleModJakartaLSTestCommon class
anusreelakshmi934 Jan 8, 2025
42261b6
SingleModLibertyLSTestCommon class
anusreelakshmi934 Jan 8, 2025
4fc023b
SingleModMPLSTestCommon class
anusreelakshmi934 Jan 8, 2025
92e9776
SingleModNLTRestProjectTestCommon class
anusreelakshmi934 Jan 8, 2025
2bf831c
TestUtils class
anusreelakshmi934 Jan 8, 2025
0618396
Update ItConstants.java
anusreelakshmi934 Jan 8, 2025
0588eba
changed the path to / seperated
anusreelakshmi934 Jan 13, 2025
b34d02a
SingleModMPLSTestCommon class updated
anusreelakshmi934 Jan 13, 2025
4761fe1
SingleModLibertyLSTestCommon updated
anusreelakshmi934 Jan 13, 2025
698703d
SingleModMPLSTestCommon updated
anusreelakshmi934 Jan 13, 2025
6f5f2f5
removed extra imports
anusreelakshmi934 Jan 13, 2025
97eac05
messages.log path
anusreelakshmi934 Jan 15, 2025
e64cdbd
path changed to string array
anusreelakshmi934 Jan 17, 2025
64b7a81
Update Constants.java
anusreelakshmi934 Jan 17, 2025
f1d400d
Update SingleModMPLSTestCommon.java
anusreelakshmi934 Jan 17, 2025
31ca81d
addressed review comments
anusreelakshmi934 Jan 22, 2025
3f1b7b3
Updates
anusreelakshmi934 Jan 23, 2025
229e73e
Changed into String[]
anusreelakshmi934 Jan 23, 2025
41a8522
server.env added to path
anusreelakshmi934 Jan 24, 2025
682853c
imported static Itconstants
anusreelakshmi934 Jan 24, 2025
25a376e
Dynamically combine paths and project name
anusreelakshmi934 Jan 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
SingleModMPLSTestCommon file
anusreelakshmi934 committed Jan 13, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 1e62f896744a529ec1e5defeb781be8a613f21e6
Original file line number Diff line number Diff line change
@@ -101,11 +101,15 @@ public final class Constants {
public static final String SYSTEM_RESOURCE_2_JAVA = "SystemResource2.java";
public static final String SYSTEM_RESOURCE = "SystemResource";
public static final String SYSTEM_RESOURCE_2 = "SystemResource2";

public static final String SERVER_XML = "server.xml";
public static final String SERVER_ENV = "server.env";
public static final String BOOTSTRAP_PROPERTIES = "bootstrap.properties";
public static final String COMPACT_MODE = "Compact Mode";

public static final String SERVICE_LIVE_HEALTH_CHECK_JAVA = "ServiceLiveHealthCheck.java";
public static final String MPG_PROPERTIES = "microprofile-config.properties";



}
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
import com.intellij.remoterobot.RemoteRobot;
import com.intellij.remoterobot.fixtures.JTreeFixture;
import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture;
import io.openliberty.tools.intellij.util.Constants;
import org.junit.jupiter.api.*;

import java.nio.file.Path;
@@ -64,10 +65,10 @@ public static void cleanup() {
projectFrame.findText("META-INF").doubleClick();
projectFrame.findText("resources").doubleClick();

UIBotTestUtils.closeFileEditorTab(remoteRobot, "ServiceLiveHealthCheck.java", "5");
UIBotTestUtils.closeFileEditorTab(remoteRobot, "microprofile-config.properties", "5");
UIBotTestUtils.closeFileEditorTab(remoteRobot, Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA, "5");
UIBotTestUtils.closeFileEditorTab(remoteRobot, Constants.MPG_PROPERTIES, "5");
if (!remoteRobot.isMac()) {
UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3);
UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, Constants.COMPACT_MODE, 3);
}
UIBotTestUtils.closeProjectView(remoteRobot);
UIBotTestUtils.closeProjectFrame(remoteRobot);
@@ -85,7 +86,7 @@ public void testInsertCodeSnippetIntoJavaPart() {
String insertedCode = "public class ServiceLiveHealthCheck implements HealthCheck {";

// get focus on file tab prior to copy
UIBotTestUtils.clickOnFileTab(remoteRobot, "ServiceLiveHealthCheck.java");
UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA);

// Save the current content.
UIBotTestUtils.copyWindowContent(remoteRobot);
@@ -95,8 +96,8 @@ public void testInsertCodeSnippetIntoJavaPart() {

// Insert a code snippet into java part
try {
UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, "ServiceLiveHealthCheck.java", snippetStr, snippetChooser);
Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "health","ServiceLiveHealthCheck.java");
UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA, snippetStr, snippetChooser);
Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "health",Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA);
TestUtils.validateCodeInJavaSrc(pathToSrc.toString(), insertedCode);
} finally {
// Replace modified content with the original content
@@ -116,14 +117,14 @@ public void testMPDiagnosticsInJavaPart() {
String expectedHoverData = "The class `io.openliberty.mp.sample.health.ServiceLiveHealthCheck` implementing the HealthCheck interface should use the @Liveness, @Readiness or @Health annotation.";

// get focus on file tab prior to copy
UIBotTestUtils.clickOnFileTab(remoteRobot, "ServiceLiveHealthCheck.java");
UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA);

// Save the current content.
UIBotTestUtils.copyWindowContent(remoteRobot);

// Delete the liveness annotation
UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot, "ServiceLiveHealthCheck.java", livenessString);
Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "health", "ServiceLiveHealthCheck.java");
UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot, Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA, livenessString);
Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "health", Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA);

try {
// validate @Liveness no longer found in java part
@@ -134,7 +135,7 @@ public void testMPDiagnosticsInJavaPart() {
int maxWait = 60, delay = 5; // in some cases it can take 35s for the diagnostic to appear
for (int i = 0; i <= maxWait; i += delay) {
//there should be a diagnostic - move cursor to hover point
UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, "ServiceLiveHealthCheck.java", UIBotTestUtils.PopupType.DIAGNOSTIC);
UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA, UIBotTestUtils.PopupType.DIAGNOSTIC);

foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC);
if (!foundHoverData.isBlank()) {
@@ -162,21 +163,21 @@ public void testMPQuickFixInJavaFile() {
String mainQuickFixActionStr = "Generate OpenAPI Annotations for 'ServiceLiveHealthCheck'";

// get focus on file tab prior to copy
UIBotTestUtils.clickOnFileTab(remoteRobot, "ServiceLiveHealthCheck.java");
UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA);

// Save the current content.
UIBotTestUtils.copyWindowContent(remoteRobot);

// Delete the liveness annotation
UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot,"ServiceLiveHealthCheck.java", livenessString);
Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "health", "ServiceLiveHealthCheck.java");
UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot,Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA, livenessString);
Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "health", Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA);

try {
// validate @Liveness no longer found in java part
TestUtils.validateStringNotInFile(pathToSrc.toString(), livenessString);

//there should be a diagnostic - move cursor to hover point
UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, "ServiceLiveHealthCheck.java", quickfixChooserString);
UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, Constants.SERVICE_LIVE_HEALTH_CHECK_JAVA, quickfixChooserString);

// trigger and use the quickfix popup attached to the diagnostic
UIBotTestUtils.chooseQuickFix(remoteRobot, quickfixChooserString);
@@ -201,14 +202,14 @@ public void testInsertMicroProfileProperty() {
String expectedMpCfgPropertiesString = "mp.health.disable-default-procedures=true";

// get focus on file tab prior to copy
UIBotTestUtils.clickOnFileTab(remoteRobot, "microprofile-config.properties");
UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.MPG_PROPERTIES);

// Save the current microprofile-config.properties content.
UIBotTestUtils.copyWindowContent(remoteRobot);

try {
UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, "microprofile-config.properties", cfgSnippet, cfgNameChooserSnippet, cfgValueSnippet, true);
Path pathToMpCfgProperties = Paths.get(projectsPath, projectName, "src", "main", "resources", "META-INF", "microprofile-config.properties");
UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, Constants.MPG_PROPERTIES, cfgSnippet, cfgNameChooserSnippet, cfgValueSnippet, true);
Path pathToMpCfgProperties = Paths.get(projectsPath, projectName, "src", "main", "resources", "META-INF", Constants.MPG_PROPERTIES);
TestUtils.validateStringInFile(pathToMpCfgProperties.toString(), expectedMpCfgPropertiesString);
} finally {
// Replace modified microprofile-config.properties with the original content
@@ -231,7 +232,7 @@ public void testMicroProfileConfigHover() {
"java.lang.StringValue: http://localhost:9081/data/client/service";

//mover cursor to hover point
UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, "microprofile-config.properties", UIBotTestUtils.PopupType.DOCUMENTATION);
UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, Constants.MPG_PROPERTIES, UIBotTestUtils.PopupType.DOCUMENTATION);
String hoverFoundOutcome = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DOCUMENTATION);

// if the LS has not yet poulated the popup, re-get the popup data
@@ -261,16 +262,16 @@ public void testDiagnosticInMicroProfileConfigProperties() {
String expectedHoverData = "Type mismatch: boolean expected. By default, this value will be interpreted as 'false'";

// get focus on file tab prior to copy
UIBotTestUtils.clickOnFileTab(remoteRobot, "microprofile-config.properties");
UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.MPG_PROPERTIES);

// Save the current content.
UIBotTestUtils.copyWindowContent(remoteRobot);

try {
UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, "microprofile-config.properties", MPCfgSnippet, MPCfgNameChooserSnippet, incorrectValue, false);
UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, Constants.MPG_PROPERTIES, MPCfgSnippet, MPCfgNameChooserSnippet, incorrectValue, false);

//move cursor to hover point
UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, incorrectValue, "microprofile-config.properties", UIBotTestUtils.PopupType.DIAGNOSTIC);
UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, incorrectValue, Constants.MPG_PROPERTIES, UIBotTestUtils.PopupType.DIAGNOSTIC);
String foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC);
TestUtils.validateHoverData(expectedHoverData, foundHoverData);
} finally {
@@ -294,19 +295,19 @@ public void testQuickFixInMicroProfileConfigProperties() {
String correctedValue = "mp.health.disable-default-procedures=true";
String expectedHoverData = "Type mismatch: boolean expected. By default, this value will be interpreted as 'false'";

Path pathToMpCfgProperties = Paths.get(projectsPath, projectName,"src", "main", "resources", "META-INF", "microprofile-config.properties");
Path pathToMpCfgProperties = Paths.get(projectsPath, projectName,"src", "main", "resources", "META-INF", Constants.MPG_PROPERTIES);

// get focus on file tab prior to copy
UIBotTestUtils.clickOnFileTab(remoteRobot, "microprofile-config.properties");
UIBotTestUtils.clickOnFileTab(remoteRobot, Constants.MPG_PROPERTIES);

// Save the current content.
UIBotTestUtils.copyWindowContent(remoteRobot);

try {
UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, "microprofile-config.properties", MPCfgSnippet, MPCfgNameChooserSnippet, incorrectValue, false);
UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, Constants.MPG_PROPERTIES, MPCfgSnippet, MPCfgNameChooserSnippet, incorrectValue, false);

//move cursor to hover point
UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, incorrectValue, "microprofile-config.properties", quickfixChooserString);
UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, incorrectValue, Constants.MPG_PROPERTIES, quickfixChooserString);

UIBotTestUtils.chooseQuickFix(remoteRobot, quickfixChooserString);
TestUtils.validateStanzaInConfigFile(pathToMpCfgProperties.toString(), correctedValue);
@@ -332,7 +333,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, Constants.COMPACT_MODE, 3);
}
// IntelliJ does not start building and indexing until the Project View is open
UIBotTestUtils.waitForIndexing(remoteRobot);
@@ -344,7 +345,7 @@ public static void prepareEnv(String projectPath, String projectName) {
JTreeFixture projTree = projectFrame.getProjectViewJTree(projectName);

UIBotTestUtils.openFile(remoteRobot, projectName, "ServiceLiveHealthCheck", projectName, "src", "main", "java", "io.openliberty.mp.sample", "health");
UIBotTestUtils.openFile(remoteRobot, projectName, "microprofile-config.properties", projectName, "src", "main", "resources", "META-INF");
UIBotTestUtils.openFile(remoteRobot, projectName, Constants.MPG_PROPERTIES, projectName, "src", "main", "resources", "META-INF");

// Removes the build tool window if it is opened. This prevents text to be hidden by it.
UIBotTestUtils.removeToolWindow(remoteRobot, "Build:");