diff --git a/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotLSP4JakartaTest.java b/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotLSP4JakartaTest.java index 93be2785..ad20d518 100644 --- a/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotLSP4JakartaTest.java +++ b/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotLSP4JakartaTest.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2022, 2023 IBM Corporation and others. +* Copyright (c) 2023 IBM Corporation and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -12,6 +12,8 @@ *******************************************************************************/ package io.openliberty.tools.eclipse.test.it; +import static io.openliberty.tools.eclipse.test.it.utils.MagicWidgetFinder.goGlobal; +import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.launchDashboardAction; import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; @@ -29,6 +31,7 @@ import io.openliberty.tools.eclipse.test.it.utils.LibertyPluginTestUtils; import io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations; +import io.openliberty.tools.eclipse.ui.dashboard.DashboardView; /** * Tests LSP4Jakarta functionality within Liberty Tools for Eclipse @@ -106,27 +109,52 @@ public static void cleanup() { public void testClassLevelSnippets() { try { + // Start dev mode. + launchDashboardAction(MVN_WRAPPER_APP_NAME, DashboardView.APP_MENU_ACTION_START); + + goGlobal("Terminal"); + + // Validate application is up and running. + LibertyPluginTestUtils.validateApplicationOutcome(MVN_WRAPPER_APP_NAME, true, + wrapperProjectPath.toAbsolutePath().toString() + "/target/liberty"); + // Open new class file SWTBotPluginOperations.createNewClass(bot, MVN_WRAPPER_APP_NAME, "MyClass", true); // Get type-ahead list - List typeAheadOptions = SWTBotPluginOperations.getTypeAheadList(bot, "MyClass.java", "", 0, 0); - boolean allFound = true; List missingOptions = new ArrayList(); - for (String option : typeAheadOptions_classLevel) { - if (!typeAheadOptions.contains(option)) { - allFound = false; - missingOptions.add(option); + + int i = 0; + while (i < 3) { + List typeAheadOptions = SWTBotPluginOperations.getTypeAheadList(bot, "MyClass.java", "", 0, 0); + System.out.println("INFO: Type-ahead options found = " + Arrays.toString(typeAheadOptions.toArray())); + + allFound = true; + missingOptions = new ArrayList(); + for (String option : typeAheadOptions_classLevel) { + if (!typeAheadOptions.contains(option)) { + allFound = false; + missingOptions.add(option); + } } + i++; } assertTrue(allFound, "Missing type-ahead options: " + Arrays.toString(missingOptions.toArray())); + } catch (Exception e) { + System.out.println("Caught exception: " + e); } finally { // Delete new file LibertyPluginTestUtils.deleteFile(new File(wrapperProjectPath + "/src/main/java/test/maven/liberty/web/app/MyClass.java")); + + // Stop dev mode. + launchDashboardAction(MVN_WRAPPER_APP_NAME, DashboardView.APP_MENU_ACTION_STOP); + + // Validate application stopped. + LibertyPluginTestUtils.validateLibertyServerStopped(wrapperProjectPath.toAbsolutePath().toString() + "/target/liberty"); } } @@ -137,27 +165,52 @@ public void testClassLevelSnippets() { public void testInClassSnippets() { try { + // Start dev mode. + launchDashboardAction(MVN_WRAPPER_APP_NAME, DashboardView.APP_MENU_ACTION_START); + + goGlobal("Terminal"); + + // Validate application is up and running. + LibertyPluginTestUtils.validateApplicationOutcome(MVN_WRAPPER_APP_NAME, true, + wrapperProjectPath.toAbsolutePath().toString() + "/target/liberty"); + // Open new class file SWTBotPluginOperations.createNewClass(bot, MVN_WRAPPER_APP_NAME, "MyClass", false); // Get type-ahead list - List typeAheadOptions = SWTBotPluginOperations.getTypeAheadList(bot, "MyClass.java", "", 3, 0); - boolean allFound = true; List missingOptions = new ArrayList(); - for (String option : typeAheadOptions_inClass) { - if (!typeAheadOptions.contains(option)) { - allFound = false; - missingOptions.add(option); + + int i = 0; + while (i < 3) { + List typeAheadOptions = SWTBotPluginOperations.getTypeAheadList(bot, "MyClass.java", "", 3, 0); + System.out.println("INFO: Type-ahead options found = " + Arrays.toString(typeAheadOptions.toArray())); + + allFound = true; + missingOptions = new ArrayList(); + for (String option : typeAheadOptions_inClass) { + if (!typeAheadOptions.contains(option)) { + allFound = false; + missingOptions.add(option); + } } + i++; } assertTrue(allFound, "Missing type-ahead options: " + Arrays.toString(missingOptions.toArray())); + } catch (Exception e) { + System.out.println("Caught exception: " + e); } finally { // Delete new file LibertyPluginTestUtils.deleteFile(new File(wrapperProjectPath + "/src/main/java/test/maven/liberty/web/app/MyClass.java")); + + // Stop dev mode. + launchDashboardAction(MVN_WRAPPER_APP_NAME, DashboardView.APP_MENU_ACTION_STOP); + + // Validate application stopped. + LibertyPluginTestUtils.validateLibertyServerStopped(wrapperProjectPath.toAbsolutePath().toString() + "/target/liberty"); } } @@ -193,6 +246,8 @@ public void testDiagnosticsAndQuickFixes() { assertTrue(allFound, "Missing quick-fixes: " + Arrays.toString(missingFixes.toArray())); + } catch (Exception e) { + System.out.println("Caught exception: " + e); } finally { // Delete new file diff --git a/tests/src/main/java/io/openliberty/tools/eclipse/test/it/utils/SWTBotPluginOperations.java b/tests/src/main/java/io/openliberty/tools/eclipse/test/it/utils/SWTBotPluginOperations.java index 3eec679b..6567f9df 100644 --- a/tests/src/main/java/io/openliberty/tools/eclipse/test/it/utils/SWTBotPluginOperations.java +++ b/tests/src/main/java/io/openliberty/tools/eclipse/test/it/utils/SWTBotPluginOperations.java @@ -933,6 +933,8 @@ public boolean matches(Object object) { */ public static void createNewClass(SWTWorkbenchBot bot, String appName, String className, boolean clearContent) { + System.out.println("INFO: Creating new Java class: " + className); + Object project = getAppInPackageExplorerTree(appName); context(project, "New", "Class"); @@ -966,7 +968,10 @@ public static void createNewClass(SWTWorkbenchBot bot, String appName, String cl */ public static List getTypeAheadList(SWTWorkbenchBot bot, String editorFileName, String insertText, int cursorRow, int cursorColumn) { - SWTBotPreferences.PLAYBACK_DELAY = 1000; + + System.out.println("INFO: Getting type-ahead list"); + + SWTBotPreferences.PLAYBACK_DELAY = 10000; SWTBotEditor editor = searchForEditor(bot, editorFileName); SWTBotEclipseEditor e = editor.toTextEditor(); @@ -991,6 +996,9 @@ public static List getTypeAheadList(SWTWorkbenchBot bot, String editorFi */ public static void selectTypeAheadOption(SWTWorkbenchBot bot, String editorFileName, String option, int cursorRow, int cursorColumn) { + + System.out.println("INFO: Selecting type-ahead option: " + option); + SWTBotPreferences.PLAYBACK_DELAY = 1000; SWTBotEditor editor = searchForEditor(bot, editorFileName); SWTBotEclipseEditor e = editor.toTextEditor(); @@ -1008,6 +1016,8 @@ public static void selectTypeAheadOption(SWTWorkbenchBot bot, String editorFileN * @return */ public static List getQuickFixList(SWTWorkbenchBot bot, String editorFileName) { + System.out.println("INFO: Getting quick-fix list for class: " + editorFileName); + SWTBotPreferences.PLAYBACK_DELAY = 1000; SWTBotEditor editor = searchForEditor(bot, editorFileName);