You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/08/08 02:51:02 UTC

[GitHub] [inlong] EMsnap commented on a diff in pull request #5388: [INLONG-5387][Manager][Sort] Support encrypt records

EMsnap commented on code in PR #5388:
URL: https://github.com/apache/inlong/pull/5388#discussion_r939782631


##########
inlong-sort/sort-core/src/test/java/org/apache/inlong/sort/function/EncryptFunctionTest.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * 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.inlong.sort.function;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.java.typeutils.RowTypeInfo;
+import org.apache.flink.streaming.api.datastream.DataStream;
+import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.table.api.EnvironmentSettings;
+import org.apache.flink.table.api.Table;
+import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
+import org.apache.flink.test.util.AbstractTestBase;
+import org.apache.flink.types.Row;
+import org.apache.flink.util.CloseableIterator;
+import org.apache.inlong.sort.formats.common.StringFormatInfo;
+import org.apache.inlong.sort.protocol.FieldInfo;
+import org.apache.inlong.sort.protocol.transformation.StringConstantParam;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Test for {@link EncryptFunction}
+ * and {@link org.apache.inlong.sort.protocol.transformation.function.EncryptFunction}
+ */
+public class EncryptFunctionTest extends AbstractTestBase {
+
+    /**
+     * Test for RegexpReplaceFirst
+     *
+     * @throws Exception The exception may throw when test RegexpReplaceFirst
+     */
+    @Test
+    public void testEncryptFunction() throws Exception {
+        EnvironmentSettings settings = EnvironmentSettings
+                .newInstance()
+                .useBlinkPlanner()
+                .inStreamingMode()
+                .build();
+        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
+        env.setParallelism(1);
+        env.enableCheckpointing(10000);
+        StreamTableEnvironment tableEnv = StreamTableEnvironment.create(env, settings);
+        // step 1. Register custom function of REGEXP_REPLACE_FIRST
+        tableEnv.createTemporaryFunction("ENCRYPT", EncryptFunction.class);
+        // step 2. Generate test data and convert to DataStream
+        List<Row> data = new ArrayList<>();
+        data.add(Row.of("abc"));
+        TypeInformation<?>[] types = {
+                BasicTypeInfo.STRING_TYPE_INFO};
+//        data.add(Row.of(12));

Review Comment:
   remove useless annotation



-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org