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 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 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
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023, 2024 IBM Corporation.
* Copyright (c) 2023, 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
Expand All @@ -12,6 +12,7 @@
import com.automation.remarks.junit5.Video;
import com.intellij.remoterobot.RemoteRobot;
import com.intellij.remoterobot.fixtures.JTreeFixture;
import io.openliberty.tools.intellij.it.Utils.ItConstants;
import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture;
import org.junit.jupiter.api.*;

Expand Down Expand Up @@ -61,8 +62,8 @@ public void afterEach(TestInfo info) {
public static void cleanup() {
ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2));

UIBotTestUtils.closeFileEditorTab(remoteRobot, "SystemResource.java", "5");
UIBotTestUtils.closeFileEditorTab(remoteRobot, "SystemResource2.java", "5");
UIBotTestUtils.closeFileEditorTab(remoteRobot, ItConstants.SYSTEM_RESOURCE_JAVA, "5");
UIBotTestUtils.closeFileEditorTab(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA, "5");

UIBotTestUtils.closeProjectView(remoteRobot);
UIBotTestUtils.closeProjectFrame(remoteRobot);
Expand All @@ -80,7 +81,7 @@ public void testInsertJakartaCodeSnippetIntoJavaPart() {
String insertedCode = "public String methodname() {";

// get focus on file tab prior to copy
UIBotTestUtils.clickOnFileTab(remoteRobot, "SystemResource.java");
UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SYSTEM_RESOURCE_JAVA);

// Save the current content.
UIBotTestUtils.copyWindowContent(remoteRobot);
Expand All @@ -90,8 +91,8 @@ public void testInsertJakartaCodeSnippetIntoJavaPart() {

// Insert a code snippet into java part
try {
UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, "SystemResource.java", snippetStr, snippetChooser);
Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "system", "SystemResource.java");
UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, ItConstants.SYSTEM_RESOURCE_JAVA, snippetStr, snippetChooser);
Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.SYSTEM_DIR_PATH, ItConstants.SYSTEM_RESOURCE_JAVA);
TestUtils.validateCodeInJavaSrc(pathToSrc.toString(), insertedCode);
}
finally {
Expand All @@ -109,28 +110,28 @@ public void testJakartaDiagnosticsInJavaPart() {
String privateString = "private Response getProperties() {";
String flaggedString = "getProperties";
String expectedHoverData = "Only public methods can be exposed as resource methods";
Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "system", "SystemResource2.java");
Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.SYSTEM_DIR_PATH, ItConstants.SYSTEM_RESOURCE_2_JAVA);

// get focus on file tab prior to copy
UIBotTestUtils.clickOnFileTab(remoteRobot, "SystemResource2.java");
UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA);

// Modify the method signature
UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, "SystemResource2.java", publicString, privateString);
UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA, publicString, privateString);

try {
// validate the method signature is no longer set to public
TestUtils.validateStringNotInFile(pathToSrc.toString(), publicString);

//there should be a diagnostic for "private" on method signature - move cursor to hover point
UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, "SystemResource2.java", UIBotTestUtils.PopupType.DIAGNOSTIC);
UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, ItConstants.SYSTEM_RESOURCE_2_JAVA, UIBotTestUtils.PopupType.DIAGNOSTIC);

String foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC);
TestUtils.validateHoverData(expectedHoverData, foundHoverData);
UIBotTestUtils.clickOnFileTab(remoteRobot, "SystemResource2.java");
UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA);

} finally {
// Replace modified content with the original content
UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, "SystemResource2.java", privateString, publicString);
UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA, privateString, publicString);
}
}

Expand All @@ -144,24 +145,24 @@ public void testJakartaQuickFixInJavaPart() {
String privateString = "private Response getProperties() {";
String flaggedString = "getProperties";

Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "system", "SystemResource2.java");
Path pathToSrc = Paths.get(projectsPath, projectName, ItConstants.SYSTEM_DIR_PATH, ItConstants.SYSTEM_RESOURCE_2_JAVA);
String quickfixChooserString = "Make method public";

// get focus on file tab prior to copy
UIBotTestUtils.clickOnFileTab(remoteRobot, "SystemResource2.java");
UIBotTestUtils.clickOnFileTab(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA);

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

// Modify the method signature
UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, "SystemResource2.java", publicString, privateString);
UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA, publicString, privateString);

try {
// validate public signature no longer found in java part
TestUtils.validateStringNotInFile(pathToSrc.toString(), publicString);

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

// trigger and use the quickfix popup attached to the diagnostic
UIBotTestUtils.chooseQuickFix(remoteRobot, quickfixChooserString);
Expand Down Expand Up @@ -198,11 +199,11 @@ public static void prepareEnv(String projectPath, String projectName) {

// expand project directories that are specific to this test app being used by these testcases
// must be expanded here before trying to open specific files
projTree.expand(projectName, "src", "main", "java", "io.openliberty.mp.sample", "system");

UIBotTestUtils.openFile(remoteRobot, projectName, "SystemResource", projectName, "src", "main", "java", "io.openliberty.mp.sample", "system");
UIBotTestUtils.openFile(remoteRobot, projectName, "SystemResource2", projectName, "src", "main", "java", "io.openliberty.mp.sample", "system");
projTree.expand(projectName, ItConstants.SYSTEM_DIR_PATH);

String[] systemDirPath = TestUtils.combinePath(projectName, ItConstants.SYSTEM_DIR_PATH_ARR);
UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE, systemDirPath);
UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE_2, systemDirPath);

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