From 55262f932027f8bf4426a2794ca00083977c8e9e Mon Sep 17 00:00:00 2001 From: Nathan Xu Date: Tue, 8 Jul 2025 21:44:58 -0400 Subject: [PATCH] add missing unsupported ResultSet data types --- .../mongodb/hibernate/jdbc/MongoResultSetTests.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/test/java/com/mongodb/hibernate/jdbc/MongoResultSetTests.java b/src/test/java/com/mongodb/hibernate/jdbc/MongoResultSetTests.java index 1b8f35db..21579efe 100644 --- a/src/test/java/com/mongodb/hibernate/jdbc/MongoResultSetTests.java +++ b/src/test/java/com/mongodb/hibernate/jdbc/MongoResultSetTests.java @@ -29,6 +29,7 @@ import com.mongodb.client.MongoCursor; import java.math.BigDecimal; import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; import java.util.Calendar; import java.util.List; import java.util.UUID; @@ -239,6 +240,13 @@ void testGettersForObject() throws SQLException { () -> assertEquals(objectId, mongoResultSet.getObject(1, ObjectId.class)), () -> assertFalse(mongoResultSet.wasNull())); } + + @Test + void testGettersForUnsupportedTypes() { + assertAll( + () -> assertThrowsSQLFeatureNotSupportedException(() -> mongoResultSet.getShort(1)), + () -> assertThrowsSQLFeatureNotSupportedException(() -> mongoResultSet.getFloat(1))); + } } private void checkMethodsWithOpenPrecondition(Consumer asserter) { @@ -284,4 +292,9 @@ private static void assertThrowsTypeMismatchException(Executable executable) { var exception = assertThrows(SQLException.class, executable); assertThat(exception.getMessage()).startsWith("Failed to get value from column"); } + + private static void assertThrowsSQLFeatureNotSupportedException(Executable executable) { + var exception = assertThrows(SQLFeatureNotSupportedException.class, executable); + assertThat(exception.getMessage()).matches("get(\\w+) not implemented"); + } }