@@ -212,22 +212,6 @@ public void testRowWithMissingFields() {
212212 assertThat (convertedPojo .offsetDateTimeField ).isNull ();
213213 }
214214
215- @ Test
216- public void testFieldAccessFailureThrows () {
217- RowType rowType = RowType .builder ().field ("intField" , DataTypes .INT ()).build ();
218-
219- PojoConverterUtils <FinalFieldPojo > converter =
220- PojoConverterUtils .getConverter (FinalFieldPojo .class , rowType );
221-
222- GenericRow row = new GenericRow (1 );
223- row .setField (0 , 42 );
224-
225- assertThatThrownBy (() -> converter .fromRow (row ))
226- .isInstanceOf (IllegalStateException .class )
227- .hasMessageContaining ("Failed to set field" )
228- .hasMessageContaining ("intField" );
229- }
230-
231215 @ Test
232216 public void testNoDefaultConstructorPojoThrows () {
233217 RowType rowType = RowType .builder ().field ("intField" , DataTypes .INT ()).build ();
@@ -257,61 +241,53 @@ public void testFromRowThrowsWhenDefaultConstructorThrows() {
257241 @ Test
258242 public void testToRowThrowsForNonBigDecimal () {
259243 RowType rowType = RowType .builder ().field ("decimalField" , DataTypes .DECIMAL (10 , 2 )).build ();
260- PojoConverterUtils <DecimalWrongTypePojo > converter =
261- PojoConverterUtils .getConverter (DecimalWrongTypePojo .class , rowType );
262- DecimalWrongTypePojo pojo = new DecimalWrongTypePojo ("not-a-decimal" );
263- assertThatThrownBy (() -> converter .toRow (pojo ))
244+ assertThatThrownBy (
245+ () -> PojoConverterUtils .getConverter (DecimalWrongTypePojo .class , rowType ))
264246 .isInstanceOf (IllegalArgumentException .class )
265- .hasMessageContaining ("not a BigDecimal " )
247+ .hasMessageContaining ("incompatible with Fluss type " )
266248 .hasMessageContaining ("decimalField" );
267249 }
268250
269251 @ Test
270252 public void testToRowThrowsForNonLocalDate () {
271253 RowType rowType = RowType .builder ().field ("dateField" , DataTypes .DATE ()).build ();
272- PojoConverterUtils <DateWrongTypePojo > converter =
273- PojoConverterUtils .getConverter (DateWrongTypePojo .class , rowType );
274- DateWrongTypePojo pojo = new DateWrongTypePojo ("2025-01-01" );
275- assertThatThrownBy (() -> converter .toRow (pojo ))
254+ assertThatThrownBy (() -> PojoConverterUtils .getConverter (DateWrongTypePojo .class , rowType ))
276255 .isInstanceOf (IllegalArgumentException .class )
277- .hasMessageContaining ("not a LocalDate " )
256+ .hasMessageContaining ("incompatible with Fluss type " )
278257 .hasMessageContaining ("dateField" );
279258 }
280259
281260 @ Test
282261 public void testToRowThrowsForNonLocalTime () {
283262 RowType rowType = RowType .builder ().field ("timeField" , DataTypes .TIME ()).build ();
284- PojoConverterUtils <TimeWrongTypePojo > converter =
285- PojoConverterUtils .getConverter (TimeWrongTypePojo .class , rowType );
286- TimeWrongTypePojo pojo = new TimeWrongTypePojo ("15:00:00" );
287- assertThatThrownBy (() -> converter .toRow (pojo ))
263+ assertThatThrownBy (() -> PojoConverterUtils .getConverter (TimeWrongTypePojo .class , rowType ))
288264 .isInstanceOf (IllegalArgumentException .class )
289- .hasMessageContaining ("not a LocalTime " )
265+ .hasMessageContaining ("incompatible with Fluss type " )
290266 .hasMessageContaining ("timeField" );
291267 }
292268
293269 @ Test
294270 public void testToRowThrowsForNonLocalDateTime () {
295271 RowType rowType = RowType .builder ().field ("timestampField" , DataTypes .TIMESTAMP ()).build ();
296- PojoConverterUtils < TimestampWrongTypePojo > converter =
297- PojoConverterUtils . getConverter ( TimestampWrongTypePojo . class , rowType );
298- TimestampWrongTypePojo pojo = new TimestampWrongTypePojo ( "2025-01-01T12:00:00" );
299- assertThatThrownBy (() -> converter . toRow ( pojo ))
272+ assertThatThrownBy (
273+ () ->
274+ PojoConverterUtils . getConverter (
275+ TimestampWrongTypePojo . class , rowType ))
300276 .isInstanceOf (IllegalArgumentException .class )
301- .hasMessageContaining ("not a LocalDateTime " )
277+ .hasMessageContaining ("incompatible with Fluss type " )
302278 .hasMessageContaining ("timestampField" );
303279 }
304280
305281 @ Test
306282 public void testToRowThrowsForNonInstantOrOffsetDateTime () {
307283 RowType rowType =
308284 RowType .builder ().field ("timestampLtzField" , DataTypes .TIMESTAMP_LTZ ()).build ();
309- PojoConverterUtils < TimestampLtzWrongTypePojo > converter =
310- PojoConverterUtils . getConverter ( TimestampLtzWrongTypePojo . class , rowType );
311- TimestampLtzWrongTypePojo pojo = new TimestampLtzWrongTypePojo ( "2025-01-01T12:00:00Z" );
312- assertThatThrownBy (() -> converter . toRow ( pojo ))
285+ assertThatThrownBy (
286+ () ->
287+ PojoConverterUtils . getConverter (
288+ TimestampLtzWrongTypePojo . class , rowType ))
313289 .isInstanceOf (IllegalArgumentException .class )
314- .hasMessageContaining ("not an Instant or OffsetDateTime " )
290+ .hasMessageContaining ("incompatible with Fluss type " )
315291 .hasMessageContaining ("timestampLtzField" );
316292 }
317293
@@ -320,20 +296,21 @@ public void testFromRowThrowsForTimestampLtzUnsupportedTargetType() {
320296 RowType rowType =
321297 RowType .builder ().field ("timestampLtzField" , DataTypes .TIMESTAMP_LTZ ()).build ();
322298
323- // Create a valid row using a POJO with Instant
299+ // Create a valid row using a POJO with Instant (ensure default constructor exists)
324300 ValidTimestampLtzInstantPojo valid =
325301 new ValidTimestampLtzInstantPojo (Instant .parse ("2025-07-23T15:01:30Z" ));
326302 PojoConverterUtils <ValidTimestampLtzInstantPojo > validConverter =
327303 PojoConverterUtils .getConverter (ValidTimestampLtzInstantPojo .class , rowType );
328304 GenericRow row = validConverter .toRow (valid );
305+ assertThat (row ).isNotNull ();
329306
330- // Try to read with a POJO that uses unsupported LocalDateTime for TIMESTAMP_LTZ
331- PojoConverterUtils < TimestampLtzLocalDateTimePojo > invalidConverter =
332- PojoConverterUtils . getConverter ( TimestampLtzLocalDateTimePojo . class , rowType );
333-
334- assertThatThrownBy (() -> invalidConverter . fromRow ( row ))
307+ // Creating a converter for a POJO that uses unsupported LocalDateTime should fail fast
308+ assertThatThrownBy (
309+ () ->
310+ PojoConverterUtils . getConverter (
311+ TimestampLtzLocalDateTimePojo . class , rowType ))
335312 .isInstanceOf (IllegalArgumentException .class )
336- .hasMessageContaining ("Cannot convert from TimestampData " )
313+ .hasMessageContaining ("incompatible with Fluss type " )
337314 .hasMessageContaining ("timestampLtzField" );
338315 }
339316
@@ -446,6 +423,8 @@ public TimestampLtzWrongTypePojo(String timestampLtzField) {
446423 public static class ValidTimestampLtzInstantPojo {
447424 private Instant timestampLtzField ;
448425
426+ public ValidTimestampLtzInstantPojo () {}
427+
449428 public ValidTimestampLtzInstantPojo (Instant timestampLtzField ) {
450429 this .timestampLtzField = timestampLtzField ;
451430 }
0 commit comments