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"); + } }