44import io .teaql .core .BaseEntity ;
55import io .teaql .core .EntityKey ;
66import io .teaql .core .UserContext ;
7+ import io .teaql .core .SchemaExecutor ;
78import io .teaql .core .businessid .*;
89import io .teaql .core .meta .EntityDescriptor ;
910import io .teaql .core .meta .EntityMetaFactory ;
@@ -137,7 +138,14 @@ public void sqliteAllocatorIsExplicitCrossInstanceAndRestartSafe() throws Except
137138 LocalDate .of (2026 , 9 , 20 )));
138139
139140 try (Connection schemaConnection = open (databasePath )) {
140- new JdbcBusinessIdAllocator (database (schemaConnection )).ensureSchema (null );
141+ JdbcBusinessIdAllocator allocator =
142+ new JdbcBusinessIdAllocator (database (schemaConnection ));
143+ UserContext context = context (LocalDate .of (2026 , 9 , 20 ), allocator );
144+ context .putAttribute (
145+ SchemaExecutor .class .getName (),
146+ noOpSchemaExecutor ());
147+ context .ensureSchema ();
148+ Assert .assertNotNull (context .businessIds ());
141149 }
142150
143151 CountDownLatch start = new CountDownLatch (1 );
@@ -179,7 +187,12 @@ public void sqliteAllocatorIsExplicitCrossInstanceAndRestartSafe() throws Except
179187 }
180188
181189 private static UserContext context (LocalDate date ) {
182- TeaQLRuntime runtime = TeaQLRuntime .builder ()
190+ return context (date , null );
191+ }
192+
193+ private static UserContext context (
194+ LocalDate date , JdbcBusinessIdAllocator businessIdInfrastructure ) {
195+ TeaQLRuntime .Builder builder = TeaQLRuntime .builder ()
183196 .metadata (new EntityMetaFactory () {
184197 @ Override
185198 public EntityDescriptor resolveEntityDescriptor (String type ) {
@@ -194,8 +207,11 @@ public List<EntityDescriptor> allEntityDescriptors() {
194207 return List .of ();
195208 }
196209 })
197- .executionLogging (false )
198- .build ();
210+ .executionLogging (false );
211+ if (businessIdInfrastructure != null ) {
212+ builder .businessIdInfrastructure (businessIdInfrastructure );
213+ }
214+ TeaQLRuntime runtime = builder .build ();
199215 DefaultUserContext context = new DefaultUserContext (runtime );
200216 context .putAttribute (BusinessClock .class .getName (),
201217 (BusinessClock ) ignored -> date );
@@ -212,6 +228,20 @@ private static Connection open(Path path) throws SQLException {
212228 return connection ;
213229 }
214230
231+ private static SchemaExecutor noOpSchemaExecutor () {
232+ return (SchemaExecutor ) java .lang .reflect .Proxy .newProxyInstance (
233+ SchemaExecutor .class .getClassLoader (),
234+ new Class <?>[] {SchemaExecutor .class },
235+ (proxy , method , args ) -> {
236+ if (method .getName ().equals ("ensureSchema" )) return null ;
237+ Class <?> resultType = method .getReturnType ();
238+ if (resultType == boolean .class ) return false ;
239+ if (resultType == int .class ) return 0 ;
240+ if (resultType == long .class ) return 0L ;
241+ return null ;
242+ });
243+ }
244+
215245 private static TeaQLDatabase database (Connection connection ) {
216246 return new TeaQLDatabase () {
217247 @ Override
0 commit comments