Skip to content

Commit

Permalink
imported static Itconstants
Browse files Browse the repository at this point in the history
  • Loading branch information
anusreelakshmi934 committed Jan 24, 2025
1 parent 41a8522 commit 682853c
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
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 All @@ -21,6 +20,7 @@
import java.time.Duration;

import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitForIgnoringError;
import static io.openliberty.tools.intellij.it.Utils.ItConstants.*;

public abstract class SingleModJakartaLSTestCommon {
public static final String REMOTEBOT_URL = "http://localhost:8082";
Expand Down Expand Up @@ -62,8 +62,8 @@ public void afterEach(TestInfo info) {
public static void cleanup() {
ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2));

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

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

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

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

// Insert a code snippet into java part
try {
UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, ItConstants.SYSTEM_RESOURCE_JAVA, snippetStr, snippetChooser);
Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.SYSTEM_RESOURCE_PATH));
UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, SYSTEM_RESOURCE_JAVA, snippetStr, snippetChooser);
Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, SYSTEM_RESOURCE_PATH));
TestUtils.validateCodeInJavaSrc(pathToSrc.toString(), insertedCode);
}
finally {
Expand All @@ -110,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, TestUtils.combinePath(projectName, ItConstants.SYSTEM_RESOURCE_2_PATH));
Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, SYSTEM_RESOURCE_2_PATH));

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

// Modify the method signature
UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA, publicString, privateString);
UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, 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, ItConstants.SYSTEM_RESOURCE_2_JAVA, UIBotTestUtils.PopupType.DIAGNOSTIC);
UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, SYSTEM_RESOURCE_2_JAVA, UIBotTestUtils.PopupType.DIAGNOSTIC);

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

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

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

Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, ItConstants.SYSTEM_RESOURCE_2_PATH));
Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, SYSTEM_RESOURCE_2_PATH));
String quickfixChooserString = "Make method public";

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

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

// Modify the method signature
UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, ItConstants.SYSTEM_RESOURCE_2_JAVA, publicString, privateString);
UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, 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, ItConstants.SYSTEM_RESOURCE_2_JAVA, quickfixChooserString);
UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, SYSTEM_RESOURCE_2_JAVA, quickfixChooserString);

// trigger and use the quickfix popup attached to the diagnostic
UIBotTestUtils.chooseQuickFix(remoteRobot, quickfixChooserString);
Expand Down Expand Up @@ -199,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(TestUtils.combinePath(projectName, ItConstants.SYSTEM_DIR_PATH));
projTree.expand(TestUtils.combinePath(projectName, SYSTEM_DIR_PATH));

String[] systemDirPath = TestUtils.combinePath(projectName, ItConstants.SYSTEM_DIR_PATH);
UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE, systemDirPath);
UIBotTestUtils.openFile(remoteRobot, projectName, ItConstants.SYSTEM_RESOURCE_2, systemDirPath);
String[] systemDirPath = TestUtils.combinePath(projectName, SYSTEM_DIR_PATH);
UIBotTestUtils.openFile(remoteRobot, projectName, SYSTEM_RESOURCE, systemDirPath);
UIBotTestUtils.openFile(remoteRobot, projectName, 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

0 comments on commit 682853c

Please sign in to comment.