File tree Expand file tree Collapse file tree
src/test/java/com/digitalsanctuary/spring/user/persistence/model Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .digitalsanctuary .spring .user .persistence .model ;
2+
3+ import static org .assertj .core .api .Assertions .assertThat ;
4+ import java .lang .reflect .Field ;
5+ import jakarta .persistence .Column ;
6+ import org .hibernate .Length ;
7+ import org .junit .jupiter .api .DisplayName ;
8+ import org .junit .jupiter .params .ParameterizedTest ;
9+ import org .junit .jupiter .params .provider .ValueSource ;
10+
11+ @ DisplayName ("WebAuthnCredential Column Mapping Tests" )
12+ class WebAuthnCredentialColumnMappingTest {
13+
14+ @ ParameterizedTest
15+ @ ValueSource (strings = {"attestationObject" , "attestationClientDataJson" , "publicKey" })
16+ @ DisplayName ("should use Length.LONG32 on byte[] fields for cross-database BLOB compatibility" )
17+ void shouldUseLengthLong32OnBlobFields (String fieldName ) throws NoSuchFieldException {
18+ Field field = WebAuthnCredential .class .getDeclaredField (fieldName );
19+ Column column = field .getAnnotation (Column .class );
20+ assertThat (column )
21+ .as ("Field '%s' must have @Column annotation" , fieldName )
22+ .isNotNull ();
23+ assertThat (column .length ())
24+ .as ("Field '%s' @Column length must be Length.LONG32 (%d) to auto-upgrade "
25+ + "to LONGBLOB on MariaDB/MySQL and remain bytea on PostgreSQL" ,
26+ fieldName , Length .LONG32 )
27+ .isEqualTo (Length .LONG32 );
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments