4242import org .hibernate .type .descriptor .java .OffsetTimeJavaType ;
4343import org .hibernate .type .descriptor .java .ZonedDateTimeJavaType ;
4444
45+ import org .hibernate .testing .orm .junit .DomainModel ;
46+ import org .hibernate .testing .orm .junit .SessionFactory ;
47+ import org .hibernate .testing .orm .junit .SessionFactoryScope ;
4548import org .junit .jupiter .api .Assertions ;
4649import org .junit .jupiter .api .Test ;
4750
4851import static org .junit .jupiter .api .Assertions .assertInstanceOf ;
4952import static org .junit .jupiter .api .Assertions .assertThrows ;
5053
54+ @ DomainModel
55+ @ SessionFactory
5156public class DateSubclassesUnwrapTest {
52-
53- private static final WrapperOptions wrapperOptions = new WrapperOptions () {
54- @ Override
55- public SharedSessionContractImplementor getSession () {
56- return null ;
57- }
58-
59- @ Override
60- public SessionFactoryImplementor getSessionFactory () {
61- return null ;
62- }
63-
64- public boolean useStreamForLobBinding () {
65- return false ;
66- }
67-
68- @ Override
69- public int getPreferredSqlTypeCodeForBoolean () {
70- return 0 ;
71- }
72-
73- public LobCreator getLobCreator () {
74- return NonContextualLobCreator .INSTANCE ;
75- }
76-
77- @ Override
78- public TimeZone getJdbcTimeZone () {
79- return null ;
80- }
81-
82- private final Dialect dialect = new H2Dialect () {
83- @ Override
84- public boolean useConnectionToCreateLob () {
85- return false ;
86- }
87- };
88-
89- @ Override
90- public Dialect getDialect () {
91- return dialect ;
92- }
93- };
94-
9557 @ Test
96- void testJdbcTimestampJavaType () {
58+ void testJdbcTimestampJavaType (SessionFactoryScope scope ) {
59+ final WrapperOptions wrapperOptions = scope .getSessionFactory ().getWrapperOptions ();
9760 final JdbcTimestampJavaType javaType = JdbcTimestampJavaType .INSTANCE ;
9861 final Date date = new Date ();
9962
@@ -104,7 +67,8 @@ void testJdbcTimestampJavaType() {
10467 }
10568
10669 @ Test
107- void testJdbcDateJavaType () {
70+ void testJdbcDateJavaType (SessionFactoryScope scope ) {
71+ final WrapperOptions wrapperOptions = scope .getSessionFactory ().getWrapperOptions ();
10872 final JdbcDateJavaType javaType = JdbcDateJavaType .INSTANCE ;
10973 final Date date = new Date ();
11074
@@ -115,7 +79,8 @@ void testJdbcDateJavaType() {
11579 }
11680
11781 @ Test
118- void testJdbcTimeJavaType () {
82+ void testJdbcTimeJavaType (SessionFactoryScope scope ) {
83+ final WrapperOptions wrapperOptions = scope .getSessionFactory ().getWrapperOptions ();
11984 final JdbcTimeJavaType javaType = JdbcTimeJavaType .INSTANCE ;
12085 final Date date = new Date ();
12186
@@ -129,7 +94,8 @@ void testJdbcTimeJavaType() {
12994 }
13095
13196 @ Test
132- void testDateJavaType () {
97+ void testDateJavaType (SessionFactoryScope scope ) {
98+ final WrapperOptions wrapperOptions = scope .getSessionFactory ().getWrapperOptions ();
13399 final DateJavaType javaType = DateJavaType .INSTANCE ;
134100 final Date date = new Date ();
135101
@@ -140,7 +106,8 @@ void testDateJavaType() {
140106 }
141107
142108 @ Test
143- void testInstantJavaType () {
109+ void testInstantJavaType (SessionFactoryScope scope ) {
110+ final WrapperOptions wrapperOptions = scope .getSessionFactory ().getWrapperOptions ();
144111 final InstantJavaType javaType = InstantJavaType .INSTANCE ;
145112 final Instant instant = Instant .now ();
146113
@@ -151,7 +118,8 @@ void testInstantJavaType() {
151118 }
152119
153120 @ Test
154- void testLocalDateJavaType () {
121+ void testLocalDateJavaType (SessionFactoryScope scope ) {
122+ final WrapperOptions wrapperOptions = scope .getSessionFactory ().getWrapperOptions ();
155123 final LocalDateJavaType javaType = LocalDateJavaType .INSTANCE ;
156124 final LocalDate date = LocalDate .now ();
157125
@@ -162,7 +130,8 @@ void testLocalDateJavaType() {
162130 }
163131
164132 @ Test
165- void testLocalDateTimeJavaType () {
133+ void testLocalDateTimeJavaType (SessionFactoryScope scope ) {
134+ final WrapperOptions wrapperOptions = scope .getSessionFactory ().getWrapperOptions ();
166135 final LocalDateTimeJavaType javaType = LocalDateTimeJavaType .INSTANCE ;
167136 final LocalDateTime dateTime = LocalDateTime .now ();
168137
@@ -173,7 +142,8 @@ void testLocalDateTimeJavaType() {
173142 }
174143
175144 @ Test
176- void testLocalTimeJavaType () {
145+ void testLocalTimeJavaType (SessionFactoryScope scope ) {
146+ final WrapperOptions wrapperOptions = scope .getSessionFactory ().getWrapperOptions ();
177147 final LocalTimeJavaType javaType = LocalTimeJavaType .INSTANCE ;
178148 final LocalTime time = LocalTime .now ();
179149
@@ -184,7 +154,8 @@ void testLocalTimeJavaType() {
184154 }
185155
186156 @ Test
187- void testOffsetDateTimeJavaType () {
157+ void testOffsetDateTimeJavaType (SessionFactoryScope scope ) {
158+ final WrapperOptions wrapperOptions = scope .getSessionFactory ().getWrapperOptions ();
188159 final OffsetDateTimeJavaType javaType = OffsetDateTimeJavaType .INSTANCE ;
189160 final OffsetDateTime dateTime = OffsetDateTime .now ();
190161
@@ -195,7 +166,8 @@ void testOffsetDateTimeJavaType() {
195166 }
196167
197168 @ Test
198- void testOffsetTimeJavaType () {
169+ void testOffsetTimeJavaType (SessionFactoryScope scope ) {
170+ final WrapperOptions wrapperOptions = scope .getSessionFactory ().getWrapperOptions ();
199171 final OffsetTimeJavaType javaType = OffsetTimeJavaType .INSTANCE ;
200172 final OffsetTime time = OffsetTime .now ();
201173
@@ -207,7 +179,8 @@ void testOffsetTimeJavaType() {
207179 }
208180
209181 @ Test
210- void testZonedDateTimeJavaType () {
182+ void testZonedDateTimeJavaType (SessionFactoryScope scope ) {
183+ final WrapperOptions wrapperOptions = scope .getSessionFactory ().getWrapperOptions ();
211184 final ZonedDateTimeJavaType javaType = ZonedDateTimeJavaType .INSTANCE ;
212185 final ZonedDateTime dateTime = ZonedDateTime .now ();
213186
@@ -218,7 +191,8 @@ void testZonedDateTimeJavaType() {
218191 }
219192
220193 @ Test
221- void testCalendarDateJavaType () {
194+ void testCalendarDateJavaType (SessionFactoryScope scope ) {
195+ final WrapperOptions wrapperOptions = scope .getSessionFactory ().getWrapperOptions ();
222196 final CalendarDateJavaType javaType = CalendarDateJavaType .INSTANCE ;
223197 final Calendar calendar = Calendar .getInstance ();
224198
@@ -229,7 +203,8 @@ void testCalendarDateJavaType() {
229203 }
230204
231205 @ Test
232- void testCalendarJavaType () {
206+ void testCalendarJavaType (SessionFactoryScope scope ) {
207+ final WrapperOptions wrapperOptions = scope .getSessionFactory ().getWrapperOptions ();
233208 final CalendarJavaType javaType = CalendarJavaType .INSTANCE ;
234209 final Calendar calendar = Calendar .getInstance ();
235210
@@ -240,7 +215,8 @@ void testCalendarJavaType() {
240215 }
241216
242217 @ Test
243- void testCalendarTimeJavaType () {
218+ void testCalendarTimeJavaType (SessionFactoryScope scope ) {
219+ final WrapperOptions wrapperOptions = scope .getSessionFactory ().getWrapperOptions ();
244220 final CalendarTimeJavaType javaType = CalendarTimeJavaType .INSTANCE ;
245221 final Calendar calendar = Calendar .getInstance ();
246222
0 commit comments