You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hop.apache.org by mc...@apache.org on 2026/03/27 14:37:15 UTC

(hop) branch main updated: Issue #6888 (Sorted Merge XML cleanup) (#6889)

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

mcasters 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 cc09b8ecd2 Issue #6888 (Sorted Merge XML cleanup) (#6889)
cc09b8ecd2 is described below

commit cc09b8ecd2fba5078acb19730d9ba4e6f8ec310a
Author: Matt Casters <ma...@gmail.com>
AuthorDate: Fri Mar 27 15:37:09 2026 +0100

    Issue #6888 (Sorted Merge XML cleanup) (#6889)
    
    * Issues #6888 (Sorted Merge XML cleanup)
    
    * Issues #6888 (Sorted Merge XML cleanup)
    
    * Issues #6888 (Sorted Merge XML cleanup)
    
    * Issues #6888 (Removed obsolete test)
---
 .../hop/core/row/value/ValueMetaBaseTest.java      |  22 ---
 .../mdi/0050-sorted-merge-template.hpl             |  64 +++++++
 .../mdi/0050-sorted-merge-validate.hpl             | 150 +++++++++++++++++
 integration-tests/mdi/0050-sorted-merge.hpl        | 153 +++++++++++++++++
 .../mdi/datasets/golden-sorted-merge.csv           |   5 +
 integration-tests/mdi/main-0050-sorted-merge.hwf   | 113 +++++++++++++
 .../mdi/metadata/dataset/golden-sorted-merge.json  |  24 +++
 .../unit-test/0050-sorted-merge-validate UNIT.json |  32 ++++
 .../transforms/sortedmerge/SortedMerge.java        | 147 ++++++++---------
 .../transforms/sortedmerge/SortedMergeDialog.java  | 108 +++++-------
 .../transforms/sortedmerge/SortedMergeMeta.java    | 183 ++++++---------------
 .../sortedmerge/SortedMergeMetaInjectionTest.java  |  40 -----
 .../sortedmerge/SortedMergeMetaTest.java           |  81 ++-------
 .../src/test/resources/sorted-merge.xml            |  31 ++++
 14 files changed, 749 insertions(+), 404 deletions(-)

diff --git a/core/src/test/java/org/apache/hop/core/row/value/ValueMetaBaseTest.java b/core/src/test/java/org/apache/hop/core/row/value/ValueMetaBaseTest.java
index a3d6b88abc..6b4de423f1 100644
--- a/core/src/test/java/org/apache/hop/core/row/value/ValueMetaBaseTest.java
+++ b/core/src/test/java/org/apache/hop/core/row/value/ValueMetaBaseTest.java
@@ -39,8 +39,6 @@ import java.io.ByteArrayOutputStream;
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
 import java.math.BigDecimal;
 import java.net.InetAddress;
 import java.sql.PreparedStatement;
@@ -70,9 +68,6 @@ import org.apache.hop.core.exception.HopXmlException;
 import org.apache.hop.core.logging.HopLogStore;
 import org.apache.hop.core.logging.HopLoggingEvent;
 import org.apache.hop.core.logging.IHopLoggingEventListener;
-import org.apache.hop.core.logging.ILogChannel;
-import org.apache.hop.core.logging.LoggingObject;
-import org.apache.hop.core.logging.LoggingRegistry;
 import org.apache.hop.core.plugins.PluginRegistry;
 import org.apache.hop.core.row.IValueMeta;
 import org.apache.hop.core.variables.IVariables;
@@ -705,23 +700,6 @@ class ValueMetaBaseTest {
     assertEquals(0, events.size());
   }
 
-  @Test
-  void testValueMetaBaseOnlyHasOneLogger() throws NoSuchFieldException, IllegalAccessException {
-    Field log = ValueMetaBase.class.getDeclaredField("log");
-    assertTrue(Modifier.isStatic(log.getModifiers()));
-    assertTrue(Modifier.isFinal(log.getModifiers()));
-    log.setAccessible(true);
-    try {
-      assertEquals(
-          LoggingRegistry.getInstance()
-              .findExistingLoggingSource(new LoggingObject("ValueMetaBase"))
-              .getLogChannelId(),
-          ((ILogChannel) log.get(null)).getLogChannelId());
-    } finally {
-      log.setAccessible(false);
-    }
-  }
-
   Date local(int year, int month, int dat, int hrs, int min, int sec, int ms) {
     GregorianCalendar cal = new GregorianCalendar(year, month - 1, dat, hrs, min, sec);
     cal.set(Calendar.MILLISECOND, ms);
diff --git a/integration-tests/mdi/0050-sorted-merge-template.hpl b/integration-tests/mdi/0050-sorted-merge-template.hpl
new file mode 100644
index 0000000000..584316a64f
--- /dev/null
+++ b/integration-tests/mdi/0050-sorted-merge-template.hpl
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<pipeline>
+  <info>
+    <name>0050-sorted-merge-template</name>
+    <name_sync_with_filename>Y</name_sync_with_filename>
+    <description/>
+    <extended_description/>
+    <pipeline_version/>
+    <pipeline_type>Normal</pipeline_type>
+    <parameters>
+    </parameters>
+    <capture_transform_performance>N</capture_transform_performance>
+    <transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
+    <transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
+    <created_user>-</created_user>
+    <created_date>2026/03/26 22:33:45.896</created_date>
+    <modified_user>-</modified_user>
+    <modified_date>2026/03/26 22:33:45.896</modified_date>
+  </info>
+  <notepads>
+  </notepads>
+  <order>
+  </order>
+  <transform>
+    <name>Sorted merge</name>
+    <type>SortedMerge</type>
+    <description/>
+    <distribute>Y</distribute>
+    <custom_distribution/>
+    <copies>1</copies>
+    <partitioning>
+      <method>none</method>
+      <schema_name/>
+    </partitioning>
+    <fields>
+</fields>
+    <attributes/>
+    <GUI>
+      <xloc>208</xloc>
+      <yloc>112</yloc>
+    </GUI>
+  </transform>
+  <transform_error_handling>
+  </transform_error_handling>
+  <attributes/>
+</pipeline>
diff --git a/integration-tests/mdi/0050-sorted-merge-validate.hpl b/integration-tests/mdi/0050-sorted-merge-validate.hpl
new file mode 100644
index 0000000000..c89e10e655
--- /dev/null
+++ b/integration-tests/mdi/0050-sorted-merge-validate.hpl
@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<pipeline>
+  <info>
+    <name>0050-sorted-merge-validate</name>
+    <name_sync_with_filename>Y</name_sync_with_filename>
+    <description/>
+    <extended_description/>
+    <pipeline_version/>
+    <pipeline_type>Normal</pipeline_type>
+    <parameters>
+    </parameters>
+    <capture_transform_performance>N</capture_transform_performance>
+    <transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
+    <transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
+    <created_user>-</created_user>
+    <created_date>2026/03/26 22:36:22.380</created_date>
+    <modified_user>-</modified_user>
+    <modified_date>2026/03/26 22:36:22.380</modified_date>
+  </info>
+  <notepads>
+  </notepads>
+  <order>
+    <hop>
+      <from>/tmp/sorted-merge.hpl fields</from>
+      <to>validate</to>
+      <enabled>Y</enabled>
+    </hop>
+  </order>
+  <transform>
+    <name>/tmp/sorted-merge.hpl fields</name>
+    <type>getXMLData</type>
+    <description/>
+    <distribute>Y</distribute>
+    <custom_distribution/>
+    <copies>1</copies>
+    <partitioning>
+      <method>none</method>
+      <schema_name/>
+    </partitioning>
+    <IsAFile>N</IsAFile>
+    <IsIgnoreEmptyFile>N</IsIgnoreEmptyFile>
+    <IsInFields>N</IsInFields>
+    <XmlField/>
+    <addresultfile>N</addresultfile>
+    <doNotFailIfNoFile>Y</doNotFailIfNoFile>
+    <encoding>UTF-8</encoding>
+    <extensionFieldName/>
+    <fields>
+      <field>
+        <currency/>
+        <decimal/>
+        <element_type>Node</element_type>
+        <format/>
+        <group/>
+        <length>-1</length>
+        <name>name</name>
+        <precision>-1</precision>
+        <repeat>N</repeat>
+        <result_type>valueof</result_type>
+        <trim_type>none</trim_type>
+        <type>String</type>
+        <xPath>name</xPath>
+      </field>
+      <field>
+        <currency/>
+        <decimal/>
+        <element_type>Node</element_type>
+        <format/>
+        <group/>
+        <length>-1</length>
+        <name>ascending</name>
+        <precision>-1</precision>
+        <repeat>N</repeat>
+        <result_type>valueof</result_type>
+        <trim_type>none</trim_type>
+        <type>Boolean</type>
+        <xPath>ascending</xPath>
+      </field>
+    </fields>
+    <file>
+      <exclude_filemask/>
+      <file_required>N</file_required>
+      <filemask/>
+      <include_subfolders>N</include_subfolders>
+      <name>${java.io.tmpdir}/sorted-merge.hpl</name>
+    </file>
+    <hiddenFieldName/>
+    <ignorecomments>N</ignorecomments>
+    <include>N</include>
+    <include_field/>
+    <lastModificationTimeFieldName/>
+    <limit>0</limit>
+    <loopxpath>/pipeline/transform/fields/field</loopxpath>
+    <namespaceaware>N</namespaceaware>
+    <pathFieldName/>
+    <prunePath/>
+    <readurl>N</readurl>
+    <rootUriNameFieldName/>
+    <rownum>N</rownum>
+    <rownum_field/>
+    <shortFileFieldName/>
+    <sizeFieldName/>
+    <uriNameFieldName/>
+    <usetoken>N</usetoken>
+    <validating>N</validating>
+    <attributes/>
+    <GUI>
+      <xloc>176</xloc>
+      <yloc>112</yloc>
+    </GUI>
+  </transform>
+  <transform>
+    <name>validate</name>
+    <type>Dummy</type>
+    <description/>
+    <distribute>Y</distribute>
+    <custom_distribution/>
+    <copies>1</copies>
+    <partitioning>
+      <method>none</method>
+      <schema_name/>
+    </partitioning>
+    <attributes/>
+    <GUI>
+      <xloc>368</xloc>
+      <yloc>112</yloc>
+    </GUI>
+  </transform>
+  <transform_error_handling>
+  </transform_error_handling>
+  <attributes/>
+</pipeline>
diff --git a/integration-tests/mdi/0050-sorted-merge.hpl b/integration-tests/mdi/0050-sorted-merge.hpl
new file mode 100644
index 0000000000..e1bcfe8d97
--- /dev/null
+++ b/integration-tests/mdi/0050-sorted-merge.hpl
@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<pipeline>
+  <info>
+    <name>0050-sorted-merge</name>
+    <name_sync_with_filename>Y</name_sync_with_filename>
+    <description/>
+    <extended_description/>
+    <pipeline_version/>
+    <pipeline_type>Normal</pipeline_type>
+    <parameters>
+    </parameters>
+    <capture_transform_performance>N</capture_transform_performance>
+    <transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
+    <transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
+    <created_user>-</created_user>
+    <created_date>2026/03/26 22:33:45.896</created_date>
+    <modified_user>-</modified_user>
+    <modified_date>2026/03/26 22:33:45.896</modified_date>
+  </info>
+  <notepads>
+  </notepads>
+  <order>
+    <hop>
+      <from>fields</from>
+      <to>0050-sorted-merge-template.hpl</to>
+      <enabled>Y</enabled>
+    </hop>
+  </order>
+  <transform>
+    <name>0050-sorted-merge-template.hpl</name>
+    <type>MetaInject</type>
+    <description/>
+    <distribute>Y</distribute>
+    <custom_distribution/>
+    <copies>1</copies>
+    <partitioning>
+      <method>none</method>
+      <schema_name/>
+    </partitioning>
+    <allow_empty_stream_on_execution>N</allow_empty_stream_on_execution>
+    <create_parent_folder>Y</create_parent_folder>
+    <filename>${PROJECT_HOME}/0050-sorted-merge-template.hpl</filename>
+    <mappings>
+      <mapping>
+        <source_field>field</source_field>
+        <source_transform>fields</source_transform>
+        <target_attribute_key>FIELD_NAME</target_attribute_key>
+        <target_detail>Y</target_detail>
+        <target_transform_name>Sorted merge</target_transform_name>
+      </mapping>
+      <mapping>
+        <source_field>asc</source_field>
+        <source_transform>fields</source_transform>
+        <target_attribute_key>ASCENDING</target_attribute_key>
+        <target_detail>Y</target_detail>
+        <target_transform_name>Sorted merge</target_transform_name>
+      </mapping>
+    </mappings>
+    <no_execution>N</no_execution>
+    <run_configuration>local</run_configuration>
+    <source_output_fields>
+</source_output_fields>
+    <source_transform/>
+    <stream_source_transform/>
+    <stream_target_transform/>
+    <target_file>${java.io.tmpdir}/sorted-merge.hpl</target_file>
+    <attributes/>
+    <GUI>
+      <xloc>416</xloc>
+      <yloc>144</yloc>
+    </GUI>
+  </transform>
+  <transform>
+    <name>fields</name>
+    <type>DataGrid</type>
+    <description/>
+    <distribute>Y</distribute>
+    <custom_distribution/>
+    <copies>1</copies>
+    <partitioning>
+      <method>none</method>
+      <schema_name/>
+    </partitioning>
+    <data>
+      <line>
+        <item>field1</item>
+        <item>Y</item>
+      </line>
+      <line>
+        <item>field2</item>
+        <item>N</item>
+      </line>
+      <line>
+        <item>field3</item>
+        <item>Y</item>
+      </line>
+      <line>
+        <item>field4</item>
+        <item>N</item>
+      </line>
+    </data>
+    <fields>
+      <field>
+        <length>-1</length>
+        <precision>-1</precision>
+        <currency/>
+        <set_empty_string>N</set_empty_string>
+        <name>field</name>
+        <format/>
+        <group/>
+        <decimal/>
+        <type>String</type>
+      </field>
+      <field>
+        <length>-1</length>
+        <precision>-1</precision>
+        <currency/>
+        <set_empty_string>N</set_empty_string>
+        <name>asc</name>
+        <format/>
+        <group/>
+        <decimal/>
+        <type>Boolean</type>
+      </field>
+    </fields>
+    <attributes/>
+    <GUI>
+      <xloc>176</xloc>
+      <yloc>144</yloc>
+    </GUI>
+  </transform>
+  <transform_error_handling>
+  </transform_error_handling>
+  <attributes/>
+</pipeline>
diff --git a/integration-tests/mdi/datasets/golden-sorted-merge.csv b/integration-tests/mdi/datasets/golden-sorted-merge.csv
new file mode 100644
index 0000000000..498cc5b73e
--- /dev/null
+++ b/integration-tests/mdi/datasets/golden-sorted-merge.csv
@@ -0,0 +1,5 @@
+name,ascending
+field1,Y
+field2,N
+field3,Y
+field4,N
diff --git a/integration-tests/mdi/main-0050-sorted-merge.hwf b/integration-tests/mdi/main-0050-sorted-merge.hwf
new file mode 100644
index 0000000000..5b1a1458c0
--- /dev/null
+++ b/integration-tests/mdi/main-0050-sorted-merge.hwf
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<workflow>
+  <name>main-0050-sorted-merge</name>
+  <name_sync_with_filename>Y</name_sync_with_filename>
+  <description/>
+  <extended_description/>
+  <workflow_version/>
+  <created_user>-</created_user>
+  <created_date>2026/03/26 22:33:28.878</created_date>
+  <modified_user>-</modified_user>
+  <modified_date>2026/03/26 22:33:28.878</modified_date>
+  <parameters>
+    </parameters>
+  <actions>
+    <action>
+      <name>Start</name>
+      <description/>
+      <type>SPECIAL</type>
+      <attributes/>
+      <DayOfMonth>1</DayOfMonth>
+      <doNotWaitOnFirstExecution>N</doNotWaitOnFirstExecution>
+      <hour>12</hour>
+      <intervalMinutes>60</intervalMinutes>
+      <intervalSeconds>0</intervalSeconds>
+      <minutes>0</minutes>
+      <repeat>N</repeat>
+      <schedulerType>0</schedulerType>
+      <weekDay>1</weekDay>
+      <parallel>N</parallel>
+      <xloc>112</xloc>
+      <yloc>112</yloc>
+      <attributes_hac/>
+    </action>
+    <action>
+      <name>0050-sorted-merge</name>
+      <description/>
+      <type>PIPELINE</type>
+      <attributes/>
+      <add_date>N</add_date>
+      <add_time>N</add_time>
+      <clear_files>N</clear_files>
+      <clear_rows>N</clear_rows>
+      <create_parent_folder>N</create_parent_folder>
+      <exec_per_row>N</exec_per_row>
+      <filename>${PROJECT_HOME}/0050-sorted-merge.hpl</filename>
+      <loglevel>Basic</loglevel>
+      <parameters>
+        <pass_all_parameters>Y</pass_all_parameters>
+      </parameters>
+      <params_from_previous>N</params_from_previous>
+      <run_configuration>local</run_configuration>
+      <set_append_logfile>N</set_append_logfile>
+      <set_logfile>N</set_logfile>
+      <wait_until_finished>Y</wait_until_finished>
+      <parallel>N</parallel>
+      <xloc>288</xloc>
+      <yloc>112</yloc>
+      <attributes_hac/>
+    </action>
+    <action>
+      <name>0050-sorted-merge-validate UNIT</name>
+      <description/>
+      <type>RunPipelineTests</type>
+      <attributes/>
+      <test_names>
+        <test_name>
+          <name>0050-sorted-merge-validate UNIT</name>
+        </test_name>
+      </test_names>
+      <parallel>N</parallel>
+      <xloc>512</xloc>
+      <yloc>112</yloc>
+      <attributes_hac/>
+    </action>
+  </actions>
+  <hops>
+    <hop>
+      <from>Start</from>
+      <to>0050-sorted-merge</to>
+      <enabled>Y</enabled>
+      <evaluation>Y</evaluation>
+      <unconditional>Y</unconditional>
+    </hop>
+    <hop>
+      <from>0050-sorted-merge</from>
+      <to>0050-sorted-merge-validate UNIT</to>
+      <enabled>Y</enabled>
+      <evaluation>Y</evaluation>
+      <unconditional>N</unconditional>
+    </hop>
+  </hops>
+  <notepads>
+  </notepads>
+  <attributes/>
+</workflow>
diff --git a/integration-tests/mdi/metadata/dataset/golden-sorted-merge.json b/integration-tests/mdi/metadata/dataset/golden-sorted-merge.json
new file mode 100644
index 0000000000..3c0cbb99fc
--- /dev/null
+++ b/integration-tests/mdi/metadata/dataset/golden-sorted-merge.json
@@ -0,0 +1,24 @@
+{
+  "base_filename": "golden-sorted-merge.csv",
+  "name": "golden-sorted-merge",
+  "description": "",
+  "dataset_fields": [
+    {
+      "field_comment": "",
+      "field_length": -1,
+      "field_type": 2,
+      "field_precision": -1,
+      "field_name": "name",
+      "field_format": ""
+    },
+    {
+      "field_comment": "",
+      "field_length": -1,
+      "field_type": 4,
+      "field_precision": -1,
+      "field_name": "ascending",
+      "field_format": ""
+    }
+  ],
+  "folder_name": ""
+}
\ No newline at end of file
diff --git a/integration-tests/mdi/metadata/unit-test/0050-sorted-merge-validate UNIT.json b/integration-tests/mdi/metadata/unit-test/0050-sorted-merge-validate UNIT.json
new file mode 100644
index 0000000000..a58b909a18
--- /dev/null
+++ b/integration-tests/mdi/metadata/unit-test/0050-sorted-merge-validate UNIT.json	
@@ -0,0 +1,32 @@
+{
+  "database_replacements": [],
+  "autoOpening": true,
+  "description": "",
+  "persist_filename": "",
+  "test_type": "UNIT_TEST",
+  "variableValues": [],
+  "basePath": "${HOP_UNIT_TESTS_FOLDER}",
+  "golden_data_sets": [
+    {
+      "field_mappings": [
+        {
+          "transform_field": "name",
+          "data_set_field": "name"
+        },
+        {
+          "transform_field": "ascending",
+          "data_set_field": "ascending"
+        }
+      ],
+      "field_order": [
+        "name"
+      ],
+      "data_set_name": "golden-sorted-merge",
+      "transform_name": "validate"
+    }
+  ],
+  "input_data_sets": [],
+  "name": "0050-sorted-merge-validate UNIT",
+  "trans_test_tweaks": [],
+  "pipeline_filename": "./0050-sorted-merge-validate.hpl"
+}
\ No newline at end of file
diff --git a/plugins/transforms/sortedmerge/src/main/java/org/apache/hop/pipeline/transforms/sortedmerge/SortedMerge.java b/plugins/transforms/sortedmerge/src/main/java/org/apache/hop/pipeline/transforms/sortedmerge/SortedMerge.java
index 8162a6a568..d418dbbe6c 100644
--- a/plugins/transforms/sortedmerge/src/main/java/org/apache/hop/pipeline/transforms/sortedmerge/SortedMerge.java
+++ b/plugins/transforms/sortedmerge/src/main/java/org/apache/hop/pipeline/transforms/sortedmerge/SortedMerge.java
@@ -57,70 +57,7 @@ public class SortedMerge extends BaseTransform<SortedMergeMeta, SortedMergeData>
     if (first) {
       first = false;
 
-      // Read one row from all rowsets...
-      //
-      data.sortedBuffer = new ArrayList<>();
-      data.rowMeta = null;
-
-      // If one of the inputRowSets holds a null row (the input yields
-      // 0 rows), then the null rowSet is removed from the InputRowSet buffer..
-      // (BaseTransform.getRowFrom())
-      // which throws this loop off by one (the next set never gets processed).
-      // Instead of modifying BaseTransform, I figure reversing the loop here would
-      // effect change in less areas. If the reverse loop causes a problem, please
-      List<IRowSet> inputRowSets = getInputRowSets();
-      for (int i = inputRowSets.size() - 1; i >= 0 && !isStopped(); i--) {
-
-        IRowSet rowSet = inputRowSets.get(i);
-        Object[] row = getRowFrom(rowSet);
-        if (row != null) {
-          // Add this row to the sortedBuffer...
-          // Which is not yet sorted, we'll get to that later.
-          //
-          data.sortedBuffer.add(new RowSetRow(rowSet, rowSet.getRowMeta(), row));
-          if (data.rowMeta == null) {
-            data.rowMeta = rowSet.getRowMeta().clone();
-          }
-
-          // What fields do we compare on and in what order?
-
-          // Better cache the location of the partitioning column
-          // First time operation only
-          //
-          if (data.fieldIndices == null) {
-            // Get the indexes of the specified sort fields...
-            data.fieldIndices = new int[meta.getFieldName().length];
-            for (int f = 0; f < data.fieldIndices.length; f++) {
-              data.fieldIndices[f] = data.rowMeta.indexOfValue(meta.getFieldName()[f]);
-              if (data.fieldIndices[f] < 0) {
-                throw new HopTransformException(
-                    "Unable to find fieldname ["
-                        + meta.getFieldName()[f]
-                        + "] in row : "
-                        + data.rowMeta);
-              }
-
-              data.rowMeta
-                  .getValueMeta(data.fieldIndices[f])
-                  .setSortedDescending(!meta.getAscending()[f]);
-            }
-          }
-        }
-
-        data.comparator =
-            (o1, o2) -> {
-              try {
-                return o1.getRowMeta().compare(o1.getRowData(), o2.getRowData(), data.fieldIndices);
-              } catch (HopValueException e) {
-                return 0; // TODO see if we should fire off alarms over here... Perhaps throw a
-                // RuntimeException.
-              }
-            };
-
-        // Now sort the sortedBuffer for the first time.
-        //
-        Collections.sort(data.sortedBuffer, data.comparator);
-      }
+      getRowSortedFirstCall();
     }
 
     // If our sorted buffer is empty, it means we're done...
@@ -170,33 +107,87 @@ public class SortedMerge extends BaseTransform<SortedMergeMeta, SortedMergeData>
     return outputRowData;
   }
 
+  private void getRowSortedFirstCall() throws HopTransformException {
+    // Read one row from all rowsets...
+    //
+    data.sortedBuffer = new ArrayList<>();
+    data.rowMeta = null;
+
+    // If one of the inputRowSets holds a null row (the input yields
+    // 0 rows), then the null rowSet is removed from the InputRowSet buffer..
+    // (BaseTransform.getRowFrom())
+    // which throws this loop off by one (the next set never gets processed).
+    // Instead of modifying BaseTransform, I figure reversing the loop here would
+    // effect change in less areas. If the reverse loop causes a problem, please
+    List<IRowSet> inputRowSets = getInputRowSets();
+    for (int i = inputRowSets.size() - 1; i >= 0 && !isStopped(); i--) {
+
+      IRowSet rowSet = inputRowSets.get(i);
+      Object[] row = getRowFrom(rowSet);
+      if (row != null) {
+        // Add this row to the sortedBuffer...
+        // Which is not yet sorted, we'll get to that later.
+        //
+        data.sortedBuffer.add(new RowSetRow(rowSet, rowSet.getRowMeta(), row));
+        if (data.rowMeta == null) {
+          data.rowMeta = rowSet.getRowMeta().clone();
+        }
+
+        // What fields do we compare on and in what order?
+
+        // Better cache the location of the partitioning column
+        // First time operation only
+        //
+        if (data.fieldIndices == null) {
+          // Get the indexes of the specified sort fields...
+          data.fieldIndices = new int[meta.getMergeFields().size()];
+          for (int f = 0; f < data.fieldIndices.length; f++) {
+            SortedMergeMeta.MergeField mergeField = meta.getMergeFields().get(i);
+            data.fieldIndices[f] = data.rowMeta.indexOfValue(mergeField.getFieldName());
+            if (data.fieldIndices[f] < 0) {
+              throw new HopTransformException(
+                  "Unable to find fieldname ["
+                      + mergeField.getFieldName()
+                      + "] in row : "
+                      + data.rowMeta);
+            }
+
+            data.rowMeta
+                .getValueMeta(data.fieldIndices[f])
+                .setSortedDescending(!mergeField.isAscending());
+          }
+        }
+      }
+
+      data.comparator =
+          (o1, o2) -> {
+            try {
+              return o1.getRowMeta().compare(o1.getRowData(), o2.getRowData(), data.fieldIndices);
+            } catch (HopValueException e) {
+              return 0; // TODO see if we should fire off alarms over here... Perhaps throw a
+              // RuntimeException.
+            }
+          };
+
+      // Now sort the sortedBuffer for the first time.
+      //
+      data.sortedBuffer.sort(data.comparator);
+    }
+  }
+
   @Override
   public boolean processRow() throws HopException {
-
     Object[] row = getRowSorted(); // get row, sorted
     if (row == null) { // no more input to be expected...
-
       setOutputDone();
       return false;
     }
 
     putRow(data.rowMeta, row); // copy row to possible alternate rowset(s).
-
     if (checkFeedback(getLinesRead()) && isBasic()) {
       logBasic(BaseMessages.getString(PKG, "SortedMerge.Log.LineNumber") + getLinesRead());
     }
 
     return true;
   }
-
-  @Override
-  public boolean init() {
-
-    if (super.init()) {
-
-      // Add init code here.
-      return true;
-    }
-    return false;
-  }
 }
diff --git a/plugins/transforms/sortedmerge/src/main/java/org/apache/hop/pipeline/transforms/sortedmerge/SortedMergeDialog.java b/plugins/transforms/sortedmerge/src/main/java/org/apache/hop/pipeline/transforms/sortedmerge/SortedMergeDialog.java
index 56a359d466..7b83117deb 100644
--- a/plugins/transforms/sortedmerge/src/main/java/org/apache/hop/pipeline/transforms/sortedmerge/SortedMergeDialog.java
+++ b/plugins/transforms/sortedmerge/src/main/java/org/apache/hop/pipeline/transforms/sortedmerge/SortedMergeDialog.java
@@ -41,7 +41,6 @@ import org.eclipse.swt.layout.FormAttachment;
 import org.eclipse.swt.layout.FormData;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.TableItem;
 
 public class SortedMergeDialog extends BaseTransformDialog {
@@ -85,35 +84,23 @@ public class SortedMergeDialog extends BaseTransformDialog {
     fdlFields.top = new FormAttachment(wSpacer, margin);
     wlFields.setLayoutData(fdlFields);
 
-    final int FieldsCols = 2;
-    final int FieldsRows = input.getFieldName().length;
-
-    colinf = new ColumnInfo[FieldsCols];
-    colinf[0] =
-        new ColumnInfo(
-            BaseMessages.getString(PKG, "SortedMergeDialog.Fieldname.Column"),
-            ColumnInfo.COLUMN_TYPE_CCOMBO,
-            new String[] {""},
-            false);
-    colinf[1] =
-        new ColumnInfo(
-            BaseMessages.getString(PKG, "SortedMergeDialog.Ascending.Column"),
-            ColumnInfo.COLUMN_TYPE_CCOMBO,
-            new String[] {
+    colinf =
+        new ColumnInfo[] {
+          new ColumnInfo(
+              BaseMessages.getString(PKG, "SortedMergeDialog.Fieldname.Column"),
+              ColumnInfo.COLUMN_TYPE_CCOMBO,
+              new String[] {""},
+              false),
+          new ColumnInfo(
+              BaseMessages.getString(PKG, "SortedMergeDialog.Ascending.Column"),
+              ColumnInfo.COLUMN_TYPE_CCOMBO,
               BaseMessages.getString(PKG, "System.Combo.Yes"),
-              BaseMessages.getString(PKG, CONST_SYSTEM_COMBO_NO)
-            });
+              BaseMessages.getString(PKG, CONST_SYSTEM_COMBO_NO))
+        };
 
     wFields =
         new TableView(
-            variables,
-            shell,
-            SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI,
-            colinf,
-            FieldsRows,
-            lsMod,
-            props);
-
+            variables, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, 1, lsMod, props);
     FormData fdFields = new FormData();
     fdFields.left = new FormAttachment(0, 0);
     fdFields.top = new FormAttachment(wlFields, margin);
@@ -123,25 +110,7 @@ public class SortedMergeDialog extends BaseTransformDialog {
 
     //
     // Search the fields in the background
-
-    final Runnable runnable =
-        () -> {
-          TransformMeta transformMeta = pipelineMeta.findTransform(transformName);
-          if (transformMeta != null) {
-            try {
-              IRowMeta row = pipelineMeta.getPrevTransformFields(variables, transformMeta);
-
-              // Remember these fields...
-              for (int i = 0; i < row.size(); i++) {
-                inputFields.add(row.getValueMeta(i).getName());
-              }
-              setComboBoxes();
-            } catch (HopException e) {
-              logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
-            }
-          }
-        };
-    new Thread(runnable).start();
+    new Thread(this::searchPreviousFields).start();
 
     getData();
     input.setChanged(changed);
@@ -151,6 +120,23 @@ public class SortedMergeDialog extends BaseTransformDialog {
     return transformName;
   }
 
+  private void searchPreviousFields() {
+    TransformMeta transformMeta = pipelineMeta.findTransform(transformName);
+    if (transformMeta != null) {
+      try {
+        IRowMeta row = pipelineMeta.getPrevTransformFields(variables, transformMeta);
+
+        // Remember these fields...
+        for (int i = 0; i < row.size(); i++) {
+          inputFields.add(row.getValueMeta(i).getName());
+        }
+        setComboBoxes();
+      } catch (HopException e) {
+        logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
+      }
+    }
+  }
+
   protected void setComboBoxes() {
     // Something was changed in the row.
     //
@@ -160,23 +146,16 @@ public class SortedMergeDialog extends BaseTransformDialog {
 
   /** Copy information from the meta-data input to the dialog fields. */
   public void getData() {
-    Table table = wFields.table;
-    if (input.getFieldName().length > 0) {
-      table.removeAll();
-    }
-    for (int i = 0; i < input.getFieldName().length; i++) {
-      TableItem ti = new TableItem(table, SWT.NONE);
-      ti.setText(0, "" + (i + 1));
-      ti.setText(1, input.getFieldName()[i]);
+    for (SortedMergeMeta.MergeField field : input.getMergeFields()) {
+      TableItem ti = new TableItem(wFields.table, SWT.NONE);
+      ti.setText(1, Const.NVL(field.getFieldName(), ""));
       ti.setText(
           2,
-          input.getAscending()[i]
+          field.isAscending()
               ? BaseMessages.getString(PKG, "System.Combo.Yes")
               : BaseMessages.getString(PKG, CONST_SYSTEM_COMBO_NO));
     }
-
-    wFields.setRowNums();
-    wFields.optWidth(true);
+    wFields.optimizeTableView();
   }
 
   private void cancel() {
@@ -192,15 +171,14 @@ public class SortedMergeDialog extends BaseTransformDialog {
 
     transformName = wTransformName.getText(); // return value
 
-    int nrFields = wFields.nrNonEmpty();
-
-    input.allocate(nrFields);
+    input.getMergeFields().clear();
+    for (TableItem ti : wFields.getNonEmptyItems()) {
+      SortedMergeMeta.MergeField field = new SortedMergeMeta.MergeField();
+      input.getMergeFields().add(field);
 
-    for (int i = 0; i < nrFields; i++) {
-      TableItem ti = wFields.getNonEmpty(i);
-      input.getFieldName()[i] = ti.getText(1);
-      input.getAscending()[i] =
-          !BaseMessages.getString(PKG, CONST_SYSTEM_COMBO_NO).equalsIgnoreCase(ti.getText(2));
+      field.setFieldName(ti.getText(1));
+      field.setAscending(
+          !BaseMessages.getString(PKG, CONST_SYSTEM_COMBO_NO).equalsIgnoreCase(ti.getText(2)));
     }
 
     // Show a warning (optional)
diff --git a/plugins/transforms/sortedmerge/src/main/java/org/apache/hop/pipeline/transforms/sortedmerge/SortedMergeMeta.java b/plugins/transforms/sortedmerge/src/main/java/org/apache/hop/pipeline/transforms/sortedmerge/SortedMergeMeta.java
index 4ace1f9bec..961b86b29d 100644
--- a/plugins/transforms/sortedmerge/src/main/java/org/apache/hop/pipeline/transforms/sortedmerge/SortedMergeMeta.java
+++ b/plugins/transforms/sortedmerge/src/main/java/org/apache/hop/pipeline/transforms/sortedmerge/SortedMergeMeta.java
@@ -17,32 +17,26 @@
 
 package org.apache.hop.pipeline.transforms.sortedmerge;
 
+import java.util.ArrayList;
 import java.util.List;
+import lombok.Getter;
+import lombok.Setter;
 import org.apache.hop.core.CheckResult;
 import org.apache.hop.core.Const;
 import org.apache.hop.core.ICheckResult;
 import org.apache.hop.core.annotations.Transform;
 import org.apache.hop.core.exception.HopTransformException;
-import org.apache.hop.core.exception.HopXmlException;
-import org.apache.hop.core.injection.AfterInjection;
-import org.apache.hop.core.injection.Injection;
-import org.apache.hop.core.injection.InjectionSupported;
 import org.apache.hop.core.row.IRowMeta;
 import org.apache.hop.core.row.IValueMeta;
-import org.apache.hop.core.util.Utils;
 import org.apache.hop.core.variables.IVariables;
-import org.apache.hop.core.xml.XmlHandler;
 import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.metadata.api.HopMetadataProperty;
 import org.apache.hop.metadata.api.IHopMetadataProvider;
 import org.apache.hop.pipeline.PipelineMeta;
 import org.apache.hop.pipeline.PipelineMeta.PipelineType;
 import org.apache.hop.pipeline.transform.BaseTransformMeta;
 import org.apache.hop.pipeline.transform.TransformMeta;
-import org.w3c.dom.Node;
 
-@InjectionSupported(
-    localizationPrefix = "SortedMerge.Injection.",
-    groups = {"FIELDS"})
 @Transform(
     id = "SortedMerge",
     image = "sortedmerge.svg",
@@ -51,90 +45,31 @@ import org.w3c.dom.Node;
     categoryDescription = "i18n:org.apache.hop.pipeline.transform:BaseTransform.Category.Transform",
     keywords = "i18n::SortedMergeMeta.keyword",
     documentationUrl = "/pipeline/transforms/sortedmerge.html")
+@Getter
+@Setter
 public class SortedMergeMeta extends BaseTransformMeta<SortedMerge, SortedMergeData> {
   private static final Class<?> PKG = SortedMergeMeta.class;
   public static final String CONST_FIELD = "field";
 
-  /** order by which fields? */
-  @Injection(name = "FIELD_NAME", group = "FIELDS")
-  private String[] fieldName;
+  @HopMetadataProperty(
+      key = "field",
+      groupKey = "fields",
+      injectionGroupKey = "FIELDS",
+      injectionGroupDescription = "SortedMerge.Injection.FIELDS")
+  private List<MergeField> mergeFields;
 
-  /** false : descending, true=ascending */
-  @Injection(name = "ASCENDING", group = "FIELDS")
-  private boolean[] ascending;
-
-  @Override
-  public void loadXml(Node transformNode, IHopMetadataProvider metadataProvider)
-      throws HopXmlException {
-    readData(transformNode);
+  public SortedMergeMeta() {
+    mergeFields = new ArrayList<>();
   }
 
-  public void allocate(int nrFields) {
-    fieldName = new String[nrFields]; // order by
-    ascending = new boolean[nrFields];
-  }
-
-  @Override
-  public void setDefault() {
-    int nrFields = 0;
-
-    allocate(nrFields);
-
-    for (int i = 0; i < nrFields; i++) {
-      fieldName[i] = CONST_FIELD + i;
-    }
+  public SortedMergeMeta(SortedMergeMeta m) {
+    this();
+    m.mergeFields.forEach(f -> this.mergeFields.add(new MergeField(f)));
   }
 
   @Override
   public Object clone() {
-    SortedMergeMeta retval = (SortedMergeMeta) super.clone();
-
-    int nrFields = fieldName.length;
-
-    retval.allocate(nrFields);
-    System.arraycopy(fieldName, 0, retval.fieldName, 0, nrFields);
-    System.arraycopy(ascending, 0, retval.ascending, 0, nrFields);
-
-    return retval;
-  }
-
-  private void readData(Node transformNode) throws HopXmlException {
-    try {
-      Node fields = XmlHandler.getSubNode(transformNode, "fields");
-      int nrFields = XmlHandler.countNodes(fields, CONST_FIELD);
-
-      allocate(nrFields);
-
-      for (int i = 0; i < nrFields; i++) {
-        Node fnode = XmlHandler.getSubNodeByNr(fields, CONST_FIELD, i);
-
-        fieldName[i] = XmlHandler.getTagValue(fnode, "name");
-        String asc = XmlHandler.getTagValue(fnode, "ascending");
-        if (asc.equalsIgnoreCase("Y")) {
-          ascending[i] = true;
-        } else {
-          ascending[i] = false;
-        }
-      }
-    } catch (Exception e) {
-      throw new HopXmlException("Unable to load transform info from XML", e);
-    }
-  }
-
-  @Override
-  public String getXml() {
-    StringBuilder retval = new StringBuilder();
-
-    retval.append("    <fields>" + Const.CR);
-    for (int i = 0; i < fieldName.length; i++) {
-      retval.append("      <field>" + Const.CR);
-      retval.append("        " + XmlHandler.addTagValue("name", fieldName[i]));
-      retval.append("        " + XmlHandler.addTagValue("ascending", ascending[i]));
-      retval.append("        </field>" + Const.CR);
-    }
-    retval.append("      </fields>" + Const.CR);
-
-    return retval.toString();
+    return new SortedMergeMeta(this);
   }
 
   @Override
@@ -147,13 +82,11 @@ public class SortedMergeMeta extends BaseTransformMeta<SortedMerge, SortedMergeD
       IHopMetadataProvider metadataProvider)
       throws HopTransformException {
     // Set the sorted properties: ascending/descending
-    for (int i = 0; i < fieldName.length; i++) {
-      int idx = inputRowMeta.indexOfValue(fieldName[i]);
+    for (MergeField field : mergeFields) {
+      int idx = inputRowMeta.indexOfValue(field.getFieldName());
       if (idx >= 0) {
         IValueMeta valueMeta = inputRowMeta.getValueMeta(idx);
-        valueMeta.setSortedDescending(!ascending[i]);
-
-        // TODO: add case insensivity
+        valueMeta.setSortedDescending(field.isAscending());
       }
     }
   }
@@ -184,10 +117,10 @@ public class SortedMergeMeta extends BaseTransformMeta<SortedMerge, SortedMergeD
       boolean errorFound = false;
 
       // Starting from selected fields in ...
-      for (String s : fieldName) {
-        int idx = prev.indexOfValue(s);
+      for (MergeField field : mergeFields) {
+        int idx = prev.indexOfValue(field.getFieldName());
         if (idx < 0) {
-          errorMessage += "\t\t" + s + Const.CR;
+          errorMessage += "\t\t" + field.getFieldName() + Const.CR;
           errorFound = true;
         }
       }
@@ -199,7 +132,7 @@ public class SortedMergeMeta extends BaseTransformMeta<SortedMerge, SortedMergeD
         cr = new CheckResult(ICheckResult.TYPE_RESULT_ERROR, errorMessage, transformMeta);
         remarks.add(cr);
       } else {
-        if (fieldName.length > 0) {
+        if (!mergeFields.isEmpty()) {
           cr =
               new CheckResult(
                   ICheckResult.TYPE_RESULT_OK,
@@ -242,34 +175,6 @@ public class SortedMergeMeta extends BaseTransformMeta<SortedMerge, SortedMergeD
     }
   }
 
-  /**
-   * @return the ascending
-   */
-  public boolean[] getAscending() {
-    return ascending;
-  }
-
-  /**
-   * @param ascending the ascending to set
-   */
-  public void setAscending(boolean[] ascending) {
-    this.ascending = ascending;
-  }
-
-  /**
-   * @return the fieldName
-   */
-  public String[] getFieldName() {
-    return fieldName;
-  }
-
-  /**
-   * @param fieldName the fieldName to set
-   */
-  public void setFieldName(String[] fieldName) {
-    this.fieldName = fieldName;
-  }
-
   @Override
   public PipelineType[] getSupportedPipelineTypes() {
     return new PipelineType[] {
@@ -277,17 +182,33 @@ public class SortedMergeMeta extends BaseTransformMeta<SortedMerge, SortedMergeD
     };
   }
 
-  /**
-   * If we use injection we can have different arrays lengths. We need synchronize them for
-   * consistency behavior with UI
-   */
-  @AfterInjection
-  public void afterInjectionSynchronization() {
-    int nrFields = (fieldName == null) ? -1 : fieldName.length;
-    if (nrFields <= 0) {
-      return;
+  @Getter
+  @Setter
+  public static class MergeField {
+    @HopMetadataProperty(
+        key = "name",
+        injectionKey = "FIELD_NAME",
+        injectionKeyDescription = "SortedMerge.Injection.FIELD_NAME")
+    private String fieldName;
+
+    @HopMetadataProperty(
+        key = "ascending",
+        injectionKey = "ASCENDING",
+        injectionKeyDescription = "SortedMerge.Injection.ASCENDING")
+    private boolean ascending;
+
+    public MergeField() {}
+
+    public MergeField(MergeField f) {
+      this();
+      this.ascending = f.ascending;
+      this.fieldName = f.fieldName;
+    }
+
+    public MergeField(String fieldName, boolean ascending) {
+      this();
+      this.ascending = ascending;
+      this.fieldName = fieldName;
     }
-    boolean[][] rtn = Utils.normalizeArrays(nrFields, ascending);
-    ascending = rtn[0];
   }
 }
diff --git a/plugins/transforms/sortedmerge/src/test/java/org/apache/hop/pipeline/transforms/sortedmerge/SortedMergeMetaInjectionTest.java b/plugins/transforms/sortedmerge/src/test/java/org/apache/hop/pipeline/transforms/sortedmerge/SortedMergeMetaInjectionTest.java
deleted file mode 100644
index e877c06f3b..0000000000
--- a/plugins/transforms/sortedmerge/src/test/java/org/apache/hop/pipeline/transforms/sortedmerge/SortedMergeMetaInjectionTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hop.pipeline.transforms.sortedmerge;
-
-import org.apache.hop.core.injection.BaseMetadataInjectionTestJunit5;
-import org.apache.hop.junit.rules.RestoreHopEngineEnvironmentExtension;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
-
-class SortedMergeMetaInjectionTest extends BaseMetadataInjectionTestJunit5<SortedMergeMeta> {
-  @RegisterExtension
-  static RestoreHopEngineEnvironmentExtension env = new RestoreHopEngineEnvironmentExtension();
-
-  @BeforeEach
-  void setup() throws Exception {
-    setup(new SortedMergeMeta());
-  }
-
-  @Test
-  void test() throws Exception {
-    check("FIELD_NAME", () -> meta.getFieldName()[0]);
-    check("ASCENDING", () -> meta.getAscending()[0]);
-  }
-}
diff --git a/plugins/transforms/sortedmerge/src/test/java/org/apache/hop/pipeline/transforms/sortedmerge/SortedMergeMetaTest.java b/plugins/transforms/sortedmerge/src/test/java/org/apache/hop/pipeline/transforms/sortedmerge/SortedMergeMetaTest.java
index 9519c15511..f5054a4884 100644
--- a/plugins/transforms/sortedmerge/src/test/java/org/apache/hop/pipeline/transforms/sortedmerge/SortedMergeMetaTest.java
+++ b/plugins/transforms/sortedmerge/src/test/java/org/apache/hop/pipeline/transforms/sortedmerge/SortedMergeMetaTest.java
@@ -18,78 +18,23 @@
 package org.apache.hop.pipeline.transforms.sortedmerge;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.hop.core.exception.HopException;
-import org.apache.hop.junit.rules.RestoreHopEngineEnvironmentExtension;
-import org.apache.hop.pipeline.transforms.loadsave.LoadSaveTester;
-import org.apache.hop.pipeline.transforms.loadsave.validator.ArrayLoadSaveValidator;
-import org.apache.hop.pipeline.transforms.loadsave.validator.BooleanLoadSaveValidator;
-import org.apache.hop.pipeline.transforms.loadsave.validator.IFieldLoadSaveValidator;
-import org.apache.hop.pipeline.transforms.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator;
-import org.apache.hop.pipeline.transforms.loadsave.validator.StringLoadSaveValidator;
+import org.apache.hop.pipeline.transform.TransformSerializationTestUtil;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
 
 class SortedMergeMetaTest {
-  @RegisterExtension
-  static RestoreHopEngineEnvironmentExtension env = new RestoreHopEngineEnvironmentExtension();
-
   @Test
-  void testRoundTrips() throws HopException {
-    List<String> attributes = Arrays.asList("name", "ascending");
-
-    Map<String, String> getterMap = new HashMap<>();
-    getterMap.put("name", "getFieldName");
-    getterMap.put("ascending", "getAscending");
-
-    Map<String, String> setterMap = new HashMap<>();
-    setterMap.put("name", "setFieldName");
-    setterMap.put("ascending", "setAscending");
-
-    Map<String, IFieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<>();
-    IFieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator =
-        new ArrayLoadSaveValidator<>(new StringLoadSaveValidator(), 25);
-    IFieldLoadSaveValidator<boolean[]> booleanArrayLoadSaveValidator =
-        new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 25);
-
-    fieldLoadSaveValidatorAttributeMap.put("name", stringArrayLoadSaveValidator);
-    fieldLoadSaveValidatorAttributeMap.put("ascending", booleanArrayLoadSaveValidator);
-
-    LoadSaveTester loadSaveTester =
-        new LoadSaveTester(
-            SortedMergeMeta.class,
-            attributes,
-            getterMap,
-            setterMap,
-            fieldLoadSaveValidatorAttributeMap,
-            new HashMap<>());
-
-    loadSaveTester.testSerialization();
-  }
-
-  @Test
-  void testPDI16559() throws Exception {
-    SortedMergeMeta sortedMerge = new SortedMergeMeta();
-    sortedMerge.setFieldName(new String[] {"field1", "field2", "field3", "field4", "field5"});
-    sortedMerge.setAscending(new boolean[] {false, true});
-
-    try {
-      String badXml = sortedMerge.getXml();
-      fail("Before calling afterInjectionSynchronization, should have thrown an ArrayIndexOOB");
-    } catch (Exception expected) {
-      // Do Nothing
-    }
-    sortedMerge.afterInjectionSynchronization();
-    // run without a exception
-    String ktrXml = sortedMerge.getXml();
-
-    int targetSz = sortedMerge.getFieldName().length;
-
-    assertEquals(targetSz, sortedMerge.getAscending().length);
+  void testSerializationRoundTrip() throws Exception {
+    SortedMergeMeta meta =
+        TransformSerializationTestUtil.testSerialization(
+            "/sorted-merge.xml", SortedMergeMeta.class);
+
+    assertEquals(2, meta.getMergeFields().size());
+    assertEquals("field1", meta.getMergeFields().getFirst().getFieldName());
+    assertTrue(meta.getMergeFields().getFirst().isAscending());
+    assertEquals("field2", meta.getMergeFields().getLast().getFieldName());
+    assertFalse(meta.getMergeFields().getLast().isAscending());
   }
 }
diff --git a/plugins/transforms/sortedmerge/src/test/resources/sorted-merge.xml b/plugins/transforms/sortedmerge/src/test/resources/sorted-merge.xml
new file mode 100644
index 0000000000..bfb395c509
--- /dev/null
+++ b/plugins/transforms/sortedmerge/src/test/resources/sorted-merge.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~
+  -->
+<transform>
+    <fields>
+        <field>
+            <ascending>Y</ascending>
+            <name>field1</name>
+        </field>
+        <field>
+            <ascending>N</ascending>
+            <name>field2</name>
+        </field>
+    </fields>
+</transform>
+