This is an automated email from the ASF dual-hosted git repository.

hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/main by this push:
     new 795cebde90 Fix #5369 Unit Test: Enhance Unit Test Dialog (#6047)
795cebde90 is described below

commit 795cebde90a1fe40c37b0361599eee32fd79a95f
Author: Sergio Ramazzina <[email protected]>
AuthorDate: Sun Dec 7 13:02:48 2025 +0100

    Fix #5369 Unit Test: Enhance Unit Test Dialog (#6047)
    
    Reverted some changes erroneously added
---
 .../org/apache/hop/testing/PipelineUnitTest.java   |  2 +-
 .../hop/ui/testing/PipelineUnitTestEditor.java     | 73 +++++++++++++++++++---
 .../ui/testing/messages/messages_en_US.properties  |  5 +-
 .../ui/testing/messages/messages_it_IT.properties  |  2 +-
 4 files changed, 71 insertions(+), 11 deletions(-)

diff --git 
a/plugins/misc/testing/src/main/java/org/apache/hop/testing/PipelineUnitTest.java
 
b/plugins/misc/testing/src/main/java/org/apache/hop/testing/PipelineUnitTest.java
index d0dbd5aa95..61e8d7c4c0 100644
--- 
a/plugins/misc/testing/src/main/java/org/apache/hop/testing/PipelineUnitTest.java
+++ 
b/plugins/misc/testing/src/main/java/org/apache/hop/testing/PipelineUnitTest.java
@@ -84,7 +84,7 @@ public class PipelineUnitTest extends HopMetadataBase 
implements Cloneable, IHop
     type = TestType.DEVELOPMENT;
     databaseReplacements = new ArrayList<>();
     variableValues = new ArrayList<>();
-    basePath = null;
+    basePath = "${" + DataSetConst.VARIABLE_HOP_UNIT_TESTS_FOLDER + "}";
     autoOpening = true;
   }
 
diff --git 
a/plugins/misc/testing/src/main/java/org/apache/hop/ui/testing/PipelineUnitTestEditor.java
 
b/plugins/misc/testing/src/main/java/org/apache/hop/ui/testing/PipelineUnitTestEditor.java
index 2d0f90a941..a74b0f1177 100644
--- 
a/plugins/misc/testing/src/main/java/org/apache/hop/ui/testing/PipelineUnitTestEditor.java
+++ 
b/plugins/misc/testing/src/main/java/org/apache/hop/ui/testing/PipelineUnitTestEditor.java
@@ -19,6 +19,7 @@ package org.apache.hop.ui.testing;
 
 import java.util.Collections;
 import java.util.List;
+import org.apache.commons.lang.StringUtils;
 import org.apache.hop.core.Const;
 import org.apache.hop.core.database.DatabaseMeta;
 import org.apache.hop.core.exception.HopException;
@@ -31,6 +32,7 @@ import 
org.apache.hop.testing.PipelineUnitTestDatabaseReplacement;
 import org.apache.hop.testing.VariableValue;
 import org.apache.hop.testing.util.DataSetConst;
 import org.apache.hop.ui.core.PropsUi;
+import org.apache.hop.ui.core.dialog.BaseDialog;
 import org.apache.hop.ui.core.metadata.MetadataEditor;
 import org.apache.hop.ui.core.metadata.MetadataManager;
 import org.apache.hop.ui.core.widget.ColumnInfo;
@@ -45,6 +47,7 @@ import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Listener;
 import org.eclipse.swt.widgets.TableItem;
@@ -150,14 +153,23 @@ public class PipelineUnitTestEditor extends 
MetadataEditor<PipelineUnitTest> {
     FormData fdlPipelineFilename = new FormData();
     fdlPipelineFilename.top = new FormAttachment(lastControl, margin);
     fdlPipelineFilename.left = new FormAttachment(0, 0);
-    fdlPipelineFilename.right = new FormAttachment(middle, -margin);
+    fdlPipelineFilename.right = new FormAttachment(middle, 0);
     wlPipelineFilename.setLayoutData(fdlPipelineFilename);
+
+    Button wbPipelineFilename = new Button(parent, SWT.PUSH);
+    PropsUi.setLook(wbPipelineFilename);
+    wbPipelineFilename.setText(BaseMessages.getString(PKG, 
"PipelineUnitTestDialog.Button.Browse"));
+    FormData fdbPipelineFilename = new FormData();
+    fdbPipelineFilename.right = new FormAttachment(99, 0);
+    fdbPipelineFilename.top = new FormAttachment(wlPipelineFilename, 0, 
SWT.CENTER);
+    wbPipelineFilename.setLayoutData(fdbPipelineFilename);
+    wbPipelineFilename.addListener(SWT.Selection, 
this::browsePipelineFilename);
     wPipelineFilename = new Text(parent, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
     PropsUi.setLook(wPipelineFilename);
     FormData fdPipelineFilename = new FormData();
     fdPipelineFilename.top = new FormAttachment(wlPipelineFilename, 0, 
SWT.CENTER);
-    fdPipelineFilename.left = new FormAttachment(middle, 0);
-    fdPipelineFilename.right = new FormAttachment(100, 0);
+    fdPipelineFilename.left = new FormAttachment(middle, margin);
+    fdPipelineFilename.right = new FormAttachment(wbPipelineFilename, -margin);
     wPipelineFilename.setLayoutData(fdPipelineFilename);
     lastControl = wPipelineFilename;
 
@@ -188,14 +200,24 @@ public class PipelineUnitTestEditor extends 
MetadataEditor<PipelineUnitTest> {
     FormData fdlBasePath = new FormData();
     fdlBasePath.top = new FormAttachment(lastControl, margin);
     fdlBasePath.left = new FormAttachment(0, 0);
-    fdlBasePath.right = new FormAttachment(middle, -margin);
+    fdlBasePath.right = new FormAttachment(middle, 0);
     wlBasePath.setLayoutData(fdlBasePath);
+
+    Button wbBasePath = new Button(parent, SWT.PUSH);
+    PropsUi.setLook(wbBasePath);
+    wbBasePath.setText(BaseMessages.getString(PKG, 
"PipelineUnitTestDialog.Button.Browse"));
+    FormData fdbBasePath = new FormData();
+    fdbBasePath.right = new FormAttachment(99, 0);
+    fdbBasePath.top = new FormAttachment(wlBasePath, 0, SWT.CENTER);
+    wbBasePath.setLayoutData(fdbBasePath);
+    wbBasePath.addListener(SWT.Selection, this::browseTestPathDir);
+
     wBasePath = new TextVar(manager.getVariables(), parent, SWT.SINGLE | 
SWT.LEFT | SWT.BORDER);
     PropsUi.setLook(wBasePath);
     FormData fdBasePath = new FormData();
-    fdBasePath.top = new FormAttachment(wlBasePath, 0, SWT.CENTER);
-    fdBasePath.left = new FormAttachment(middle, 0);
-    fdBasePath.right = new FormAttachment(100, 0);
+    fdBasePath.top = new FormAttachment(wbBasePath, 0, SWT.CENTER);
+    fdBasePath.left = new FormAttachment(middle, margin);
+    fdBasePath.right = new FormAttachment(wbBasePath, -margin);
     wBasePath.setLayoutData(fdBasePath);
     lastControl = wBasePath;
 
@@ -318,6 +340,7 @@ public class PipelineUnitTestEditor extends 
MetadataEditor<PipelineUnitTest> {
     fdVariableValues.right = new FormAttachment(100, 0);
     fdVariableValues.bottom = new FormAttachment(100, -2 * margin);
     wVariableValues.setLayoutData(fdVariableValues);
+    lastControl = wVariableValues;
 
     setWidgetsContent();
 
@@ -335,6 +358,42 @@ public class PipelineUnitTestEditor extends 
MetadataEditor<PipelineUnitTest> {
     wVariableValues.addModifyListener(modifyListener);
   }
 
+  private void browsePipelineFilename(Event event) {
+
+    String pipelineFilename = BaseDialog.presentFileDialog(this.getShell(), 
null, null, false);
+
+    // Set the name to the base folder if the name is empty
+    //
+    try {
+      if (pipelineFilename != null && 
StringUtils.isEmpty(wPipelineFilename.getText())) {
+        PipelineUnitTest pipelineUnitTest = this.getMetadata();
+        pipelineUnitTest.setRelativeFilename(manager.getVariables(), 
pipelineFilename);
+        
wPipelineFilename.setText(Const.NVL(pipelineUnitTest.getPipelineFilename(), 
""));
+      }
+    } catch (Exception e) {
+      LogChannel.UI.logError("Error getting pipelineFilename", e);
+      // Don't change the name
+    }
+  }
+
+  private void browseTestPathDir(Event event) {
+
+    String testPathDir = BaseDialog.presentFileDialog(this.getShell(), null, 
null, true);
+
+    // Set the name to the base folder if the name is empty
+    //
+    try {
+      if (testPathDir != null && 
StringUtils.isEmpty(wPipelineFilename.getText())) {
+        /* PipelineUnitTest pipelineUnitTest = this.getMetadata();
+        pipelineUnitTest.setRelativeFilename(manager.getVariables(), 
testPathDir);*/
+        wBasePath.setText(Const.NVL(testPathDir, ""));
+      }
+    } catch (Exception e) {
+      LogChannel.UI.logError("Error getting testPathDir", e);
+      // Don't change the name
+    }
+  }
+
   @Override
   public void setWidgetsContent() {
     PipelineUnitTest pipelineUnitTest = this.getMetadata();
diff --git 
a/plugins/misc/testing/src/main/resources/org/apache/hop/ui/testing/messages/messages_en_US.properties
 
b/plugins/misc/testing/src/main/resources/org/apache/hop/ui/testing/messages/messages_en_US.properties
index f0398e792b..bd0fde2762 100644
--- 
a/plugins/misc/testing/src/main/resources/org/apache/hop/ui/testing/messages/messages_en_US.properties
+++ 
b/plugins/misc/testing/src/main/resources/org/apache/hop/ui/testing/messages/messages_en_US.properties
@@ -39,7 +39,8 @@ EditRowsDialog.ErrorConvertingData=There was an error 
converting string values i
 EditRowsDialog.NoRowMeta.Message=No row metadata was specified so no rows can 
be edited.
 EditRowsDialog.NoRowMeta.Text=No row metadata
 PipelineUnitTestDialog.AutoOpen.Label=Select this test automatically
-PipelineUnitTestDialog.BasePath.Label=Base test path (or use 
HOP_UNIT_TESTS_FOLDER)
+PipelineUnitTestDialog.BasePath.Label=Base test path 
+PipelineUnitTestDialog.Button.Browse=Browse...
 PipelineUnitTestDialog.DbReplacement.ColumnInfo.OriginalDb=Original DB
 PipelineUnitTestDialog.DbReplacement.ColumnInfo.ReplacementDb=Replacement DB
 PipelineUnitTestDialog.DbReplacements.Label=Replace a database connection with 
another:
@@ -50,7 +51,7 @@ PipelineUnitTestDialog.PipelineFilename.Label=The pipeline to 
test
 PipelineUnitTestDialog.TestType.Label=Type of test
 PipelineUnitTestDialog.VariableValues.ColumnInfo.VariableName=Name
 PipelineUnitTestDialog.VariableValues.ColumnInfo.VariableValue=Value
-PipelineUnitTestDialog.VariableValues.Label=Variables
+PipelineUnitTestDialog.VariableValues.Label=Parameters and variables
 PipelineUnitTestSetLocationDialog.ColumnInfo.DatasetField=Dataset field
 PipelineUnitTestSetLocationDialog.ColumnInfo.TransformField=transform field
 PipelineUnitTestSetLocationDialog.DatasetName.Label=Dataset
diff --git 
a/plugins/misc/testing/src/main/resources/org/apache/hop/ui/testing/messages/messages_it_IT.properties
 
b/plugins/misc/testing/src/main/resources/org/apache/hop/ui/testing/messages/messages_it_IT.properties
index 8d2f7437de..8c579dd224 100644
--- 
a/plugins/misc/testing/src/main/resources/org/apache/hop/ui/testing/messages/messages_it_IT.properties
+++ 
b/plugins/misc/testing/src/main/resources/org/apache/hop/ui/testing/messages/messages_it_IT.properties
@@ -39,7 +39,7 @@ EditRowsDialog.ErrorConvertingData=Si \u00E8 verificato un 
errore durante la con
 EditRowsDialog.NoRowMeta.Message=Non sono stati specificati metadati quindi 
nessuna riga pu\u00F2 essere modificata.
 EditRowsDialog.NoRowMeta.Text=Non ci sono metadati di riga
 PipelineUnitTestDialog.AutoOpen.Label=Seleziona questo test automaticamente?
-PipelineUnitTestDialog.BasePath.Label=Percorso base ai test (oppure usa 
HOP_UNIT_TESTS_FOLDER)
+PipelineUnitTestDialog.BasePath.Label=Percorso base ai test 
 PipelineUnitTestDialog.DbReplacement.ColumnInfo.OriginalDb=DB Originale
 PipelineUnitTestDialog.DbReplacement.ColumnInfo.ReplacementDb=DB di 
sostituzione
 PipelineUnitTestDialog.DbReplacements.Label=Sostituisci una connessione al 
database con un''altra:

Reply via email to