snuyanzin commented on code in PR #1877:
URL: https://github.com/apache/fluss/pull/1877#discussion_r2469783815
##########
fluss-client/src/test/java/org/apache/fluss/client/converter/PojoToRowConverterTest.java:
##########
@@ -168,4 +168,257 @@ public void testUnsupportedSchemaFieldTypeThrows() {
.hasMessageContaining("MAP")
.hasMessageContaining("mapField");
}
+
+ // ----------------------- Numeric Type Widening Tests
-----------------------
+
+ @Test
+ public void testByteToSmallIntWidening() {
+ RowType table = RowType.builder().field("value",
DataTypes.SMALLINT()).build();
+ RowType projection = table;
+
+ PojoToRowConverter<ByteFieldPojo> converter =
+ PojoToRowConverter.of(ByteFieldPojo.class, table, projection);
+
+ ByteFieldPojo pojo = new ByteFieldPojo();
+ pojo.value = (byte) 42;
+ GenericRow row = converter.toRow(pojo);
+
+ assertThat(row.getShort(0)).isEqualTo((short) 42);
+ }
+
+ @Test
+ public void testIntToBigIntWidening() {
+ RowType table = RowType.builder().field("orderId",
DataTypes.BIGINT()).build();
+ RowType projection = table;
+
+ PojoToRowConverter<IntFieldPojo> converter =
+ PojoToRowConverter.of(IntFieldPojo.class, table, projection);
+
+ IntFieldPojo pojo = new IntFieldPojo();
+ pojo.orderId = 123456;
+ GenericRow row = converter.toRow(pojo);
+
+ assertThat(row.getLong(0)).isEqualTo(123456L);
+ }
+
+ @Test
+ public void testShortToBigIntWidening() {
+ RowType table = RowType.builder().field("quantity",
DataTypes.BIGINT()).build();
+ RowType projection = table;
+
+ PojoToRowConverter<ShortFieldPojo> converter =
+ PojoToRowConverter.of(ShortFieldPojo.class, table, projection);
+
+ ShortFieldPojo pojo = new ShortFieldPojo();
+ pojo.quantity = (short) 999;
+ GenericRow row = converter.toRow(pojo);
+
+ assertThat(row.getLong(0)).isEqualTo(999L);
+ }
Review Comment:
all these and other tests in this class are pretty similar
can we parameterize them?
--
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]