twalthr commented on code in PR #19262: URL: https://github.com/apache/flink/pull/19262#discussion_r867705630
########## flink-table/flink-table-runtime/src/test/java/org/apache/flink/table/data/DataStructureConvertersTest.java: ########## @@ -367,36 +365,40 @@ public static List<TestSpec> testData() { @Parameter public TestSpec testSpec; - @Rule public ExpectedException thrown = ExpectedException.none(); - @Test public void testConversions() { - if (testSpec.expectedErrorMessage != null) { - thrown.expect(TableException.class); - thrown.expectMessage(equalTo(testSpec.expectedErrorMessage)); - } for (Map.Entry<Class<?>, Object> from : testSpec.conversions.entrySet()) { final DataType fromDataType = testSpec.dataType.bridgedTo(from.getKey()); - final DataStructureConverter<Object, Object> fromConverter = - simulateSerialization(DataStructureConverters.getConverter(fromDataType)); - fromConverter.open(DataStructureConvertersTest.class.getClassLoader()); - - final Object internalValue = fromConverter.toInternalOrNull(from.getValue()); - - final Object anotherValue = testSpec.conversionsWithAnotherValue.get(from.getKey()); - if (anotherValue != null) { - fromConverter.toInternalOrNull(anotherValue); - } - - for (Map.Entry<Class<?>, Object> to : testSpec.conversions.entrySet()) { - final DataType toDataType = testSpec.dataType.bridgedTo(to.getKey()); - - final DataStructureConverter<Object, Object> toConverter = - simulateSerialization(DataStructureConverters.getConverter(toDataType)); - toConverter.open(DataStructureConvertersTest.class.getClassLoader()); - - assertThat(toConverter.toExternalOrNull(internalValue)).isEqualTo(to.getValue()); + if (testSpec.expectedErrorMessage != null) { + assertThatThrownBy( + () -> + simulateSerialization( Review Comment: remove in the `simulateSerialization` in this case ########## flink-table/flink-table-runtime/src/test/java/org/apache/flink/table/runtime/typeutils/RowDataSerializerTest.java: ########## @@ -347,26 +345,24 @@ public void testCopy() { @Test public void testWrongCopy() { - thrown.expect(IllegalArgumentException.class); - serializer.copy(new GenericRowData(serializer.getArity() + 1)); + assertThatThrownBy(() -> serializer.copy(new GenericRowData(serializer.getArity() + 1))) + .isInstanceOf(IllegalArgumentException.class); } @Test public void testWrongCopyReuse() { - thrown.expect(IllegalArgumentException.class); for (RowData row : testData) { - checkDeepEquals( - row, serializer.copy(row, new GenericRowData(row.getArity() + 1)), false); + assertThatThrownBy( + () -> + checkDeepEquals( + row, + serializer.copy( + row, new GenericRowData(row.getArity() + 1)), + false)) + .isInstanceOf(IllegalArgumentException.class); } } /** Class used for concurrent testing with KryoSerializer. */ - private static class WrappedString { Review Comment: I'm sure this had a deeper meaning. Let's keep it. -- 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