yfsn666 commented on code in PR #10854:
URL: https://github.com/apache/inlong/pull/10854#discussion_r1730286272


##########
inlong-sdk/transform-sdk/src/test/java/org/apache/inlong/sdk/transform/process/TestTransformStringFunctionsProcessor.java:
##########
@@ -184,6 +186,36 @@ public void testTrimFunction() throws Exception {
         Assert.assertEquals(output3.get(0), "result=in long");
     }
 
+    @Test
+    public void testReverseFunction() throws Exception {
+        String transformSql1 = "select reverse(string1) from source";
+        TransformConfig config1 = new TransformConfig(transformSql1);
+        TransformProcessor<String, String> processor1 = TransformProcessor
+                .create(config1, 
SourceDecoderFactory.createCsvDecoder(csvSource),
+                        SinkEncoderFactory.createKvEncoder(kvSink));
+        // case1: reverse('apple')
+        List<String> output1 = 
processor1.transform("apple|banana|cloud|2|1|3", new HashMap<>());
+        Assert.assertEquals(1, output1.size());
+        Assert.assertEquals(output1.get(0), "result=elppa");
+        // case2: reverse('ban ana ')
+        String transformSql2 = "select reverse(string2) from source";
+        TransformConfig config2 = new TransformConfig(transformSql2);
+        TransformProcessor<String, String> processor2 = TransformProcessor
+                .create(config2, 
SourceDecoderFactory.createCsvDecoder(csvSource),
+                        SinkEncoderFactory.createKvEncoder(kvSink));
+        List<String> output2 = processor2.transform("apple|ban ana 
|cloud|2|1|3", new HashMap<>());
+        Assert.assertEquals(1, output2.size());
+        Assert.assertEquals(output2.get(0), "result= ana nab");
+        // case3: reverse(12345)
+        List<String> output3 = 
processor1.transform("12345|banana|cloud|2|1|3", new HashMap<>());
+        Assert.assertEquals(1, output3.size());
+        Assert.assertEquals(output3.get(0), "result=54321");
+        // 4: reverse(null)

Review Comment:
   ```suggestion
           // case4: reverse(null)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to