gyfora commented on code in PR #23490:
URL: https://github.com/apache/flink/pull/23490#discussion_r1368565363


##########
flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/Java17RecordHelperTest.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * 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.flink.api.java.typeutils.runtime;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.lang.reflect.Field;
+import java.util.Arrays;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/** Tests for the @{@link JavaRecordHelper}. */
+class Java17RecordHelperTest {
+
+    Field[] fields;
+
+    record TestRecord(int i1, int i2, String s1, String s2) {}
+
+    @BeforeEach
+    void setup() {
+        fields = TestRecord.class.getDeclaredFields();
+    }
+
+    @Test
+    void testNoDefaultOrParamMapping() {
+        JavaRecordHelper<TestRecord> helper = 
JavaRecordHelper.create(TestRecord.class, fields);
+        JavaRecordHelper<TestRecord>.JavaRecordBuilder builder = 
helper.newBuilder();
+        builder.setParam(1, 100);
+        builder.setParam(0, 50);
+        builder.setParam(3, "test");
+
+        assertThat(builder.build()).isEqualTo(new TestRecord(50, 100, null, 
"test"));
+    }
+
+    @Test
+    void testNewFieldsAdded() {
+        // Test restoring from fields [i2, s1]
+        JavaRecordHelper<TestRecord> helper =
+                JavaRecordHelper.create(TestRecord.class, 
Arrays.copyOfRange(fields, 1, 3));
+
+        JavaRecordHelper<TestRecord>.JavaRecordBuilder builder = 
helper.newBuilder();
+        builder.setParam(0, 100);
+        builder.setParam(1, "test");

Review Comment:
   I renamed this to `setField` and added javadoc, that feels more natural in 
the context where this is used. Given an internal class I prefer a short name + 
javadocs 



-- 
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: issues-unsubscr...@flink.apache.org

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

Reply via email to