From f80bb2660c5add0193077551fafdfa6cb60660b3 Mon Sep 17 00:00:00 2001 From: Mariano de Achaval Date: Mon, 30 Sep 2024 10:09:26 -0300 Subject: [PATCH] Fixing debugger when running testing framework (#124) --- .../als/action/RestartALSServerAction.java | 3 +- .../als/component/ALSLanguageService.java | 11 +- .../org/mule/tooling/als/utils/LSPUtils.java | 3 +- .../BatTestConfigurationProducer.java | 2 +- .../launcher/BatTestRunnerCommandLine.java | 2 +- .../tooling/commons/AnypointNotification.java | 6 + .../DotBasedToolingWindowPanel.java | 3 +- .../configuration/WeaveConfiguration.java | 196 +++++++++--------- .../WeaveConfigurationProducer.java | 2 +- .../runner/WeaveRunnerCommandLine.java | 10 +- .../runner/WeaveTestRunnerCommandLine.java | 20 +- .../WeaveIntegrationTestConfiguration.java | 2 +- .../ui/test/WeaveTestBaseRunnerConfig.java | 5 +- .../ui/test/WeaveTestConfiguration.java | 5 +- .../test/WeaveTestConfigurationProducer.java | 4 +- .../dw/preview/PreviewToolWindowFactory.java | 2 +- .../dw/service/agent/WeaveAgentService.java | 11 +- .../testintegration/WeaveTestFramework.java | 4 +- .../src/main/resources/META-INF/plugin.xml | 8 +- 19 files changed, 154 insertions(+), 145 deletions(-) create mode 100644 data-weave-plugin/src/main/java/org/mule/tooling/commons/AnypointNotification.java diff --git a/data-weave-plugin/src/main/java/org/mule/tooling/als/action/RestartALSServerAction.java b/data-weave-plugin/src/main/java/org/mule/tooling/als/action/RestartALSServerAction.java index d3e69230..56873443 100644 --- a/data-weave-plugin/src/main/java/org/mule/tooling/als/action/RestartALSServerAction.java +++ b/data-weave-plugin/src/main/java/org/mule/tooling/als/action/RestartALSServerAction.java @@ -9,6 +9,7 @@ import com.intellij.openapi.project.Project; import org.jetbrains.annotations.NotNull; import org.mule.tooling.als.component.ALSLanguageService; +import org.mule.tooling.commons.AnypointNotification; public class RestartALSServerAction extends AnAction { @@ -27,7 +28,7 @@ public void actionPerformed(@NotNull AnActionEvent e) { Project project = e.getProject(); if (project != null) { ALSLanguageService.getInstance(project).restart(); - Notifications.Bus.notify(new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "ALS server restarted", "The ALS server was restarted successfully.", NotificationType.INFORMATION)); + Notifications.Bus.notify(new Notification(AnypointNotification.ANYPOINT_NOTIFICATION, "ALS server restarted", "The ALS server was restarted successfully.", NotificationType.INFORMATION)); } } } diff --git a/data-weave-plugin/src/main/java/org/mule/tooling/als/component/ALSLanguageService.java b/data-weave-plugin/src/main/java/org/mule/tooling/als/component/ALSLanguageService.java index 5edb5c1e..cb517cb3 100644 --- a/data-weave-plugin/src/main/java/org/mule/tooling/als/component/ALSLanguageService.java +++ b/data-weave-plugin/src/main/java/org/mule/tooling/als/component/ALSLanguageService.java @@ -28,12 +28,13 @@ import com.intellij.util.Alarm; import com.intellij.util.concurrency.AppExecutorUtil; import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.mule.tooling.als.settings.DialectsRegistry; import org.mule.tooling.als.utils.LSPUtils; +import org.mule.tooling.commons.AnypointNotification; import org.mule.tooling.lang.dw.util.ScalaUtils; import org.mulesoft.als.logger.PrintLnLogger$; import org.mulesoft.als.server.EmptyJvmSerializationProps$; @@ -353,7 +354,7 @@ private void scheduleUpdateDialect(VirtualFileEvent event, ALSLanguageExtension. return; } registerDialect(value); - Notifications.Bus.notify(new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "Updating dialect", "Dialect '" + event.getFileName() + "' was updated as changes where detected.", NotificationType.INFORMATION)); + Notifications.Bus.notify(new Notification(AnypointNotification.ANYPOINT_NOTIFICATION, "Updating dialect", "Dialect '" + event.getFileName() + "' was updated as changes where detected.", NotificationType.INFORMATION)); }, 500); } @@ -383,9 +384,9 @@ private void registerDialect(ALSLanguageExtension.Dialect supportedLanguage) { try { Future objectFuture = languageServer.workspaceService().executeCommand(executeCommandParams); resultOf(objectFuture); - Notifications.Bus.notify(new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "Dialect registered successfully", "Dialect '" + supportedLanguage.getDialectUrl() + "' was registered.", NotificationType.INFORMATION)); + Notifications.Bus.notify(new Notification(AnypointNotification.ANYPOINT_NOTIFICATION, "Dialect registered successfully", "Dialect '" + supportedLanguage.getDialectUrl() + "' was registered.", NotificationType.INFORMATION)); } catch (Exception e) { - Notifications.Bus.notify(new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "Unable to register dialect", "Unable to register dialect `" + supportedLanguage.getDialectUrl() + "`\nReason:\n" + e.getMessage(), NotificationType.ERROR)); + Notifications.Bus.notify(new Notification(AnypointNotification.ANYPOINT_NOTIFICATION, "Unable to register dialect", "Unable to register dialect `" + supportedLanguage.getDialectUrl() + "`\nReason:\n" + e.getMessage(), NotificationType.ERROR)); } } @@ -402,7 +403,7 @@ public void registerUserDefinedDialects() { String dialectUrl = dialect.get().getDialectUrl(); try { if (new File(new URI(dialectUrl)).exists() && !dialectUrl.isBlank()) { - Notifications.Bus.notify(new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "Registering dialect", "Dialect '" + dialectLocation.getName() + "'.", NotificationType.INFORMATION)); + Notifications.Bus.notify(new Notification(AnypointNotification.ANYPOINT_NOTIFICATION, "Registering dialect", "Dialect '" + dialectLocation.getName() + "'.", NotificationType.INFORMATION)); registerDialect(dialect.get()); //If file doesn't exists don't register it } diff --git a/data-weave-plugin/src/main/java/org/mule/tooling/als/utils/LSPUtils.java b/data-weave-plugin/src/main/java/org/mule/tooling/als/utils/LSPUtils.java index 1d7adc41..6a085d13 100644 --- a/data-weave-plugin/src/main/java/org/mule/tooling/als/utils/LSPUtils.java +++ b/data-weave-plugin/src/main/java/org/mule/tooling/als/utils/LSPUtils.java @@ -11,6 +11,7 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import org.jetbrains.annotations.Nullable; +import org.mule.tooling.commons.AnypointNotification; import org.mulesoft.lsp.feature.common.Position; import org.mulesoft.lsp.feature.common.TextDocumentIdentifier; import scala.concurrent.Await; @@ -42,7 +43,7 @@ public static Optional resultOf(Future objectFuture) { try { return Optional.of(Await.result(objectFuture, Duration.apply(30, TimeUnit.SECONDS))); } catch (InterruptedException | TimeoutException e) { - Notifications.Bus.notify(new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "Error while executing future", "Unable to execute ALS Future. Reason: \n" + e.getMessage(), NotificationType.ERROR)); + Notifications.Bus.notify(new Notification(AnypointNotification.ANYPOINT_NOTIFICATION, "Error while executing future", "Unable to execute ALS Future. Reason: \n" + e.getMessage(), NotificationType.ERROR)); return Optional.empty(); } } diff --git a/data-weave-plugin/src/main/java/org/mule/tooling/bat/launcher/BatTestConfigurationProducer.java b/data-weave-plugin/src/main/java/org/mule/tooling/bat/launcher/BatTestConfigurationProducer.java index cfa037e8..11804c02 100644 --- a/data-weave-plugin/src/main/java/org/mule/tooling/bat/launcher/BatTestConfigurationProducer.java +++ b/data-weave-plugin/src/main/java/org/mule/tooling/bat/launcher/BatTestConfigurationProducer.java @@ -7,7 +7,7 @@ import com.intellij.openapi.util.Ref; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import org.mule.tooling.bat.testintegration.BatTestFramework; import org.mule.tooling.bat.utils.BatUtils; diff --git a/data-weave-plugin/src/main/java/org/mule/tooling/bat/launcher/BatTestRunnerCommandLine.java b/data-weave-plugin/src/main/java/org/mule/tooling/bat/launcher/BatTestRunnerCommandLine.java index c5ac7224..7e570e6c 100644 --- a/data-weave-plugin/src/main/java/org/mule/tooling/bat/launcher/BatTestRunnerCommandLine.java +++ b/data-weave-plugin/src/main/java/org/mule/tooling/bat/launcher/BatTestRunnerCommandLine.java @@ -12,7 +12,7 @@ import com.intellij.psi.PsiFile; import com.intellij.psi.search.FilenameIndex; import com.intellij.psi.search.GlobalSearchScope; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import org.mule.tooling.lang.dw.launcher.configuration.runner.WeaveCommandLineState; import org.mule.tooling.lang.dw.launcher.configuration.runner.WeaveRunnerHelper; diff --git a/data-weave-plugin/src/main/java/org/mule/tooling/commons/AnypointNotification.java b/data-weave-plugin/src/main/java/org/mule/tooling/commons/AnypointNotification.java new file mode 100644 index 00000000..93a7353c --- /dev/null +++ b/data-weave-plugin/src/main/java/org/mule/tooling/commons/AnypointNotification.java @@ -0,0 +1,6 @@ +package org.mule.tooling.commons; + +public class AnypointNotification { + + public static String ANYPOINT_NOTIFICATION = "AnypointNotification"; +} diff --git a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/develop_view/DotBasedToolingWindowPanel.java b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/develop_view/DotBasedToolingWindowPanel.java index c1d4b299..1dbf9363 100644 --- a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/develop_view/DotBasedToolingWindowPanel.java +++ b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/develop_view/DotBasedToolingWindowPanel.java @@ -18,6 +18,7 @@ import com.intellij.ui.components.JBScrollPane; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.mule.tooling.commons.AnypointNotification; import org.mule.tooling.lang.dw.WeaveFileType; import org.mule.tooling.lang.dw.settings.DataWeaveSettingsState; @@ -105,7 +106,7 @@ Image runDot(String dot) { final int err = p.waitFor(); return ImageIO.read(imageFile); } catch (Exception e) { - Notifications.Bus.notify(new Notification("Data Weave", "Unable to run dot cmd", "Unable to run dot command line from '" + cmdPath + "'", NotificationType.ERROR)); + Notifications.Bus.notify(new Notification(AnypointNotification.ANYPOINT_NOTIFICATION, "Unable to run dot cmd", "Unable to run dot command line from '" + cmdPath + "'", NotificationType.ERROR)); return null; } } diff --git a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/WeaveConfiguration.java b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/WeaveConfiguration.java index d9fa35c6..933bdff9 100644 --- a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/WeaveConfiguration.java +++ b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/WeaveConfiguration.java @@ -3,14 +3,7 @@ import com.intellij.execution.ExecutionException; import com.intellij.execution.Executor; -import com.intellij.execution.configurations.ConfigurationFactory; -import com.intellij.execution.configurations.JavaRunConfigurationModule; -import com.intellij.execution.configurations.ModuleBasedConfiguration; -import com.intellij.execution.configurations.ModuleRunProfile; -import com.intellij.execution.configurations.RunConfiguration; -import com.intellij.execution.configurations.RunConfigurationWithSuppressedDefaultDebugAction; -import com.intellij.execution.configurations.RunProfileState; -import com.intellij.execution.configurations.RuntimeConfigurationException; +import com.intellij.execution.configurations.*; import com.intellij.execution.runners.ExecutionEnvironment; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; @@ -19,7 +12,6 @@ import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.JDOMExternalizerUtil; import com.intellij.openapi.util.WriteExternalException; -import org.apache.commons.lang.StringUtils; import org.jdom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -28,107 +20,109 @@ import java.util.Arrays; import java.util.Collection; -public class WeaveConfiguration extends ModuleBasedConfiguration implements ModuleRunProfile, RunConfigurationWithSuppressedDefaultDebugAction, WeaveBasedConfiguration { - - public static final String PREFIX = "DataWeaveConfig-"; - public static final String WEAVE_NAME_IDENTIFIER = PREFIX + "WeaveNameIdentifier"; - public static final String WEAVE_SCENARIO = PREFIX + "WeaveScenario"; - public static final String WEAVE_OUTPUT = PREFIX + "WeaveOutput"; - - - private Project project; - private String nameIdentifier; - private String scenario; - private String outputPath; - - - protected WeaveConfiguration(String name, @NotNull ConfigurationFactory factory, Project project) { - super(name, new JavaRunConfigurationModule(project, true), factory); - this.project = project; - } - - - @NotNull - @Override - public SettingsEditor getConfigurationEditor() { - return new WeaveRunnerEditor(this); - } - - @Nullable - @Override - public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment executionEnvironment) throws ExecutionException { - return new WeaveRunnerCommandLine(executionEnvironment, this); - } - - @Override - public void readExternal(Element element) throws InvalidDataException { - super.readExternal(element); - this.nameIdentifier = JDOMExternalizerUtil.readField(element, WEAVE_NAME_IDENTIFIER); - this.scenario = JDOMExternalizerUtil.readField(element, WEAVE_SCENARIO); - this.outputPath = JDOMExternalizerUtil.readField(element, WEAVE_OUTPUT); - getConfigurationModule().readExternal(element); - } - - - @Override - public void writeExternal(Element element) throws WriteExternalException { - super.writeExternal(element); - // Stores the values of this class into the parent - JDOMExternalizerUtil.writeField(element, WEAVE_NAME_IDENTIFIER, this.getNameIdentifier()); - JDOMExternalizerUtil.writeField(element, WEAVE_SCENARIO, this.getScenario()); - JDOMExternalizerUtil.writeField(element, WEAVE_OUTPUT, this.getOutputPath()); - getConfigurationModule().writeExternal(element); - } - - @Override - public Collection getValidModules() { - final ModuleManager moduleManager = ModuleManager.getInstance(this.project); - return Arrays.asList(moduleManager.getModules()); - } - - - @Override - public void checkConfiguration() throws RuntimeConfigurationException { - if (getModule() == null) { - throw new RuntimeConfigurationException("Module can not be empty."); +import static org.apache.commons.lang3.StringUtils.isBlank; + +public class WeaveConfiguration extends ModuleBasedConfiguration implements ModuleRunProfile, RunConfigurationWithSuppressedDefaultDebugAction, WeaveBasedConfiguration { + + public static final String PREFIX = "DataWeaveConfig-"; + public static final String WEAVE_NAME_IDENTIFIER = PREFIX + "WeaveNameIdentifier"; + public static final String WEAVE_SCENARIO = PREFIX + "WeaveScenario"; + public static final String WEAVE_OUTPUT = PREFIX + "WeaveOutput"; + + + private Project project; + private String nameIdentifier; + private String scenario; + private String outputPath; + + + protected WeaveConfiguration(String name, @NotNull ConfigurationFactory factory, Project project) { + super(name, new JavaRunConfigurationModule(project, true), factory); + this.project = project; + } + + + @NotNull + @Override + public SettingsEditor getConfigurationEditor() { + return new WeaveRunnerEditor(this); + } + + @Nullable + @Override + public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment executionEnvironment) throws ExecutionException { + return new WeaveRunnerCommandLine(executionEnvironment, this); + } + + @Override + public void readExternal(Element element) throws InvalidDataException { + super.readExternal(element); + this.nameIdentifier = JDOMExternalizerUtil.readField(element, WEAVE_NAME_IDENTIFIER); + this.scenario = JDOMExternalizerUtil.readField(element, WEAVE_SCENARIO); + this.outputPath = JDOMExternalizerUtil.readField(element, WEAVE_OUTPUT); + getConfigurationModule().readExternal(element); + } + + + @Override + public void writeExternal(Element element) throws WriteExternalException { + super.writeExternal(element); + // Stores the values of this class into the parent + JDOMExternalizerUtil.writeField(element, WEAVE_NAME_IDENTIFIER, this.getNameIdentifier()); + JDOMExternalizerUtil.writeField(element, WEAVE_SCENARIO, this.getScenario()); + JDOMExternalizerUtil.writeField(element, WEAVE_OUTPUT, this.getOutputPath()); + getConfigurationModule().writeExternal(element); } - if (StringUtils.isBlank(getNameIdentifier())) { - throw new RuntimeConfigurationException(getNameIdentifier() + " weave name identifier can not be empty."); + @Override + public Collection getValidModules() { + final ModuleManager moduleManager = ModuleManager.getInstance(this.project); + return Arrays.asList(moduleManager.getModules()); } - super.checkConfiguration(); - } - public String getNameIdentifier() { - return nameIdentifier; - } - public void setNameIdentifier(String nameIdentifier) { - this.nameIdentifier = nameIdentifier; - } + @Override + public void checkConfiguration() throws RuntimeConfigurationException { + if (getModule() == null) { + throw new RuntimeConfigurationException("Module can not be empty."); + } + + if (isBlank(getNameIdentifier())) { + throw new RuntimeConfigurationException(getNameIdentifier() + " weave name identifier can not be empty."); + } + super.checkConfiguration(); + } + + public String getNameIdentifier() { + return nameIdentifier; + } + + public void setNameIdentifier(String nameIdentifier) { + this.nameIdentifier = nameIdentifier; + } - public String getScenario() { - return scenario; - } + public String getScenario() { + return scenario; + } - public String getOutputPath() { - return outputPath; - } + public String getOutputPath() { + return outputPath; + } - public void setOutputPath(String outputPath) { - this.outputPath = outputPath; - } + public void setOutputPath(String outputPath) { + this.outputPath = outputPath; + } - public void setScenario(String scenario) { - this.scenario = scenario; - } + public void setScenario(String scenario) { + this.scenario = scenario; + } - public Module getModule() { - return getConfigurationModule().getModule(); - } + public Module getModule() { + return getConfigurationModule().getModule(); + } - @Override - public String getWorkingDirectory() { - return project.getBasePath(); - } + @Override + public String getWorkingDirectory() { + return project.getBasePath(); + } } diff --git a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/WeaveConfigurationProducer.java b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/WeaveConfigurationProducer.java index bafcc7fe..f61f2732 100644 --- a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/WeaveConfigurationProducer.java +++ b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/WeaveConfigurationProducer.java @@ -8,7 +8,7 @@ import com.intellij.openapi.util.Ref; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import org.mule.tooling.lang.dw.launcher.configuration.ui.test.WeaveTestConfigurationType; import org.mule.tooling.lang.dw.parser.psi.WeaveDocument; diff --git a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/runner/WeaveRunnerCommandLine.java b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/runner/WeaveRunnerCommandLine.java index 768e257c..c4abda71 100644 --- a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/runner/WeaveRunnerCommandLine.java +++ b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/runner/WeaveRunnerCommandLine.java @@ -5,7 +5,6 @@ import com.intellij.execution.runners.ExecutionEnvironment; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; -import org.apache.commons.lang.StringUtils; import org.jetbrains.annotations.NotNull; import org.mule.tooling.lang.dw.launcher.configuration.WeaveConfiguration; import org.mule.tooling.lang.dw.service.Scenario; @@ -14,6 +13,9 @@ import org.mule.weave.v2.parser.ast.variables.NameIdentifier; import scala.Option; +import static org.apache.commons.lang3.StringUtils.isBlank; +import static org.apache.commons.lang3.StringUtils.isNotBlank; + public class WeaveRunnerCommandLine extends WeaveCommandLineState { //Mule Main Class @@ -37,7 +39,7 @@ protected JavaParameters createJavaParameters() { javaParams.getProgramParametersList().add("-debug"); } final String scenario = model.getScenario(); - if (!StringUtils.isBlank(scenario)) { + if (!isBlank(scenario)) { VirtualFile resolve = VirtualFileSystemUtils.resolve(model.getModule(), NameIdentifier.apply(model.getNameIdentifier(), Option.empty())); if (resolve != null) { final WeaveRuntimeService instance = WeaveRuntimeService.getInstance(project); @@ -50,11 +52,11 @@ protected JavaParameters createJavaParameters() { //Set user.dir to module home final String workingDirectory = model.getWorkingDirectory(); - if (StringUtils.isNotBlank(workingDirectory)) { + if (isNotBlank(workingDirectory)) { javaParams.getVMParametersList().addProperty("user.dir", workingDirectory); } - if (StringUtils.isNotBlank(model.getOutputPath())) { + if (isNotBlank(model.getOutputPath())) { javaParams.getProgramParametersList().add("-output", model.getOutputPath()); } diff --git a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/runner/WeaveTestRunnerCommandLine.java b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/runner/WeaveTestRunnerCommandLine.java index 7d790a24..252908b9 100644 --- a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/runner/WeaveTestRunnerCommandLine.java +++ b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/runner/WeaveTestRunnerCommandLine.java @@ -17,19 +17,17 @@ import com.intellij.execution.ui.ConsoleView; import com.intellij.openapi.module.Module; import com.intellij.openapi.roots.ProjectRootManager; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import org.mule.tooling.lang.dw.launcher.configuration.ui.test.WeaveTestBaseRunnerConfig; +import org.mule.tooling.lang.dw.testintegration.WeaveTestFramework; import java.util.List; -import java.util.Objects; -import static java.util.Objects.requireNonNull; +import static org.apache.commons.lang3.StringUtils.isNotBlank; public class WeaveTestRunnerCommandLine extends WeaveCommandLineState { - - //Mule Main Class - + public static final String TEST_RUNNER_CLASS_NAME = "org.mule.weave.v2.module.test.runner.TestRunner"; private final boolean isDebug; private WeaveTestBaseRunnerConfig configuration; @@ -48,7 +46,7 @@ protected JavaParameters createJavaParameters() throws ExecutionException { javaParams.setJdk(manager.getProjectSdk()); // All modules to use the same things javaParams.configureByModule(module, JavaParameters.JDK_AND_CLASSES_AND_TESTS); - javaParams.setMainClass(WeaveRunnerHelper.WEAVE_RUNNER_MAIN_CLASS); + javaParams.setMainClass(TEST_RUNNER_CLASS_NAME); //Add default vm parameters WeaveRunnerHelper.setupDefaultVMParams(javaParams); @@ -56,7 +54,7 @@ protected JavaParameters createJavaParameters() throws ExecutionException { javaParams.getVMParametersList().addProperty("updateResult", "true"); } - if (StringUtils.isNotBlank(configuration.getTestToRun())) { + if (isNotBlank(configuration.getTestToRun())) { javaParams.getVMParametersList().addProperty("testToRun", configuration.getTestToRun()); } @@ -70,7 +68,6 @@ protected JavaParameters createJavaParameters() throws ExecutionException { } ParametersList params = javaParams.getProgramParametersList(); - params.add("--wtest"); params.add("-testlistener"); params.add("intellij"); @@ -84,7 +81,6 @@ protected JavaParameters createJavaParameters() throws ExecutionException { params.add(test); } - // All done, run it return javaParams; } @@ -94,8 +90,8 @@ protected JavaParameters createJavaParameters() throws ExecutionException { public ExecutionResult execute(@NotNull Executor executor, @NotNull ProgramRunner runner) throws ExecutionException { ProcessHandler processHandler = startProcess(); RunConfiguration runConfiguration = getConfiguration(); - TestConsoleProperties properties = new SMTRunnerConsoleProperties(runConfiguration, "WeaveTest", executor); - ConsoleView console = SMTestRunnerConnectionUtil.createAndAttachConsole("WeaveTest", processHandler, properties); + TestConsoleProperties properties = new SMTRunnerConsoleProperties(runConfiguration, WeaveTestFramework.WEAVE_TEST, executor); + ConsoleView console = SMTestRunnerConnectionUtil.createAndAttachConsole(WeaveTestFramework.WEAVE_TEST, processHandler, properties); return new DefaultExecutionResult(console, processHandler, createActions(console, processHandler)); } diff --git a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/ui/test/WeaveIntegrationTestConfiguration.java b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/ui/test/WeaveIntegrationTestConfiguration.java index 712a125a..eafd1db3 100644 --- a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/ui/test/WeaveIntegrationTestConfiguration.java +++ b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/ui/test/WeaveIntegrationTestConfiguration.java @@ -12,7 +12,7 @@ import com.intellij.openapi.util.JDOMExternalizerUtil; import com.intellij.openapi.util.WriteExternalException; import com.intellij.openapi.vfs.VirtualFile; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.jdom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/ui/test/WeaveTestBaseRunnerConfig.java b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/ui/test/WeaveTestBaseRunnerConfig.java index 29cbc518..7402dff3 100644 --- a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/ui/test/WeaveTestBaseRunnerConfig.java +++ b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/ui/test/WeaveTestBaseRunnerConfig.java @@ -2,11 +2,12 @@ import com.intellij.execution.configurations.JavaParameters; import com.intellij.openapi.module.Module; -import org.apache.commons.lang.StringUtils; import org.mule.tooling.lang.dw.launcher.configuration.WeaveBasedConfiguration; import java.util.List; +import static org.apache.commons.lang3.StringUtils.isNotBlank; + public interface WeaveTestBaseRunnerConfig extends WeaveBasedConfiguration { Module getModule(); @@ -22,7 +23,7 @@ default boolean isUpdateResult() { default void addAdditionalVMParameters(JavaParameters javaParams) { final String vmOptions = getVmOptions(); - if (StringUtils.isNotBlank(vmOptions)) + if (isNotBlank(vmOptions)) javaParams.getVMParametersList().add(vmOptions); } diff --git a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/ui/test/WeaveTestConfiguration.java b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/ui/test/WeaveTestConfiguration.java index ef1791e1..f58ce273 100644 --- a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/ui/test/WeaveTestConfiguration.java +++ b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/ui/test/WeaveTestConfiguration.java @@ -11,7 +11,7 @@ import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.JDOMExternalizerUtil; import com.intellij.openapi.util.WriteExternalException; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.jdom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -20,6 +20,7 @@ import java.util.*; import static java.util.Optional.ofNullable; +import static org.apache.commons.lang3.StringUtils.isBlank; public class WeaveTestConfiguration extends ModuleBasedConfiguration implements ModuleRunProfile, WeaveTestBaseRunnerConfig { @@ -95,7 +96,7 @@ public Collection getValidModules() { @Override public void checkConfiguration() throws RuntimeConfigurationException { - if (StringUtils.isBlank(weaveFile)) { + if (isBlank(weaveFile)) { throw new RuntimeConfigurationException(getTests() + " weave file can not be empty."); } if (getModule() == null) { diff --git a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/ui/test/WeaveTestConfigurationProducer.java b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/ui/test/WeaveTestConfigurationProducer.java index 5a97f688..744bad84 100644 --- a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/ui/test/WeaveTestConfigurationProducer.java +++ b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/launcher/configuration/ui/test/WeaveTestConfigurationProducer.java @@ -7,7 +7,7 @@ import com.intellij.openapi.util.Ref; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import org.mule.tooling.lang.dw.WeaveFileType; import org.mule.tooling.lang.dw.parser.psi.WeaveDocument; @@ -18,7 +18,7 @@ import java.util.Optional; -import static org.apache.commons.lang.StringUtils.capitalize; +import static org.apache.commons.lang3.StringUtils.capitalize; public class WeaveTestConfigurationProducer extends JavaRunConfigurationProducerBase { protected WeaveTestConfigurationProducer() { diff --git a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/preview/PreviewToolWindowFactory.java b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/preview/PreviewToolWindowFactory.java index 113b1f27..77e13825 100644 --- a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/preview/PreviewToolWindowFactory.java +++ b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/preview/PreviewToolWindowFactory.java @@ -46,7 +46,7 @@ private String getDisplayName(@NotNull Project project) { } private ContentFactory getContentFactory() { - return ContentFactory.SERVICE.getInstance(); + return ContentFactory.getInstance(); } @Nullable diff --git a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/service/agent/WeaveAgentService.java b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/service/agent/WeaveAgentService.java index ba563f0f..4a551e55 100644 --- a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/service/agent/WeaveAgentService.java +++ b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/service/agent/WeaveAgentService.java @@ -49,6 +49,7 @@ import com.intellij.util.net.NetUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.mule.tooling.commons.AnypointNotification; import org.mule.tooling.lang.dw.launcher.configuration.runner.WeaveRunnerHelper; import org.mule.tooling.lang.dw.settings.DataWeaveSettingsState; import org.mule.weave.v2.agent.api.event.*; @@ -225,7 +226,7 @@ public void onTextAvailable(@NotNull ProcessEvent event, @NotNull Key outputType i = i + 1; } } catch (Throwable e) { - Notifications.Bus.notify(new Notification(WEAVE_NOTIFICATION, "Unable to start agent", "Unable to start agent. Reason: \n" + e.getMessage(), NotificationType.ERROR)); + Notifications.Bus.notify(new Notification(AnypointNotification.ANYPOINT_NOTIFICATION, "Unable to start agent", "Unable to start agent. Reason: \n" + e.getMessage(), NotificationType.ERROR)); LOG.warn("\"Unable to start agent. Reason: \\n\" + e.getMessage()", e); disable(); return; @@ -245,7 +246,7 @@ public void failToConnect(String reason) { @Override public void connectedSuccessfully() { indicator.setText2("Agent connected successfully"); - Notifications.Bus.notify(new Notification(WEAVE_NOTIFICATION, "Server started", "Weave Server started and is reachable at port " + finalFreePort, NotificationType.INFORMATION)); + Notifications.Bus.notify(new Notification(AnypointNotification.ANYPOINT_NOTIFICATION, "Server started", "Weave Server started and is reachable at port " + finalFreePort, NotificationType.INFORMATION)); LOG.info("Weave Server started and is reachable at port " + finalFreePort); } @@ -308,7 +309,7 @@ public void run(@NotNull ProgressIndicator indicator) { }); if (!connected) { - Notifications.Bus.notify(new Notification(WEAVE_NOTIFICATION, "Client not connected", "Unable to connect to client", NotificationType.INFORMATION)); + Notifications.Bus.notify(new Notification(AnypointNotification.ANYPOINT_NOTIFICATION, "Client not connected", "Unable to connect to client", NotificationType.INFORMATION)); } } @@ -329,7 +330,7 @@ public void onPreviewExecuted(PreviewExecutedEvent result) { @Override public void onUnexpectedError(UnexpectedServerErrorEvent unexpectedServerErrorEvent) { - Notifications.Bus.notify(new Notification(WEAVE_NOTIFICATION, "[data-weave-agent] Unexpected error at 'runPreview'", + Notifications.Bus.notify(new Notification(AnypointNotification.ANYPOINT_NOTIFICATION, "[data-weave-agent] Unexpected error at 'runPreview'", "Unexpected error at 'runPreview' caused by: \n" + unexpectedServerErrorEvent.stacktrace(), NotificationType.ERROR)); } }); @@ -371,7 +372,7 @@ public boolean checkClientConnected(Runnable onConnected) { if (client != null && client.isConnected()) { onConnected.run(); } else { - Notifications.Bus.notify(new Notification(WEAVE_NOTIFICATION, "Unable to connect", "Client is not able to connect to runtime", NotificationType.WARNING)); + Notifications.Bus.notify(new Notification(AnypointNotification.ANYPOINT_NOTIFICATION, "Unable to connect", "Client is not able to connect to runtime", NotificationType.WARNING)); LOG.warn("Unable to connect; Client is " + client); } return true; diff --git a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/testintegration/WeaveTestFramework.java b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/testintegration/WeaveTestFramework.java index 0e820856..fa76c799 100644 --- a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/testintegration/WeaveTestFramework.java +++ b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/testintegration/WeaveTestFramework.java @@ -23,10 +23,12 @@ public class WeaveTestFramework implements TestFramework { + public static final String WEAVE_TEST = "WeaveTest"; + @NotNull @Override public String getName() { - return "WeaveTest"; + return WEAVE_TEST; } @NotNull diff --git a/data-weave-plugin/src/main/resources/META-INF/plugin.xml b/data-weave-plugin/src/main/resources/META-INF/plugin.xml index 59af4afa..05f52b6b 100644 --- a/data-weave-plugin/src/main/resources/META-INF/plugin.xml +++ b/data-weave-plugin/src/main/resources/META-INF/plugin.xml @@ -483,7 +483,6 @@ - @@ -542,8 +541,11 @@ - + + + +