chore(tests+config): enhance EntriesIsolationIntegrationTest and add missing Spring metadata

- Improved schema isolation logic with constants for tenant schemas and search path management in PostgreSQL.
- Added `withTenant` utility in `TenantContextHolder` to simplify tenant context usage.
- Removed unused imports, variables, and helper functions (`random()` and redundant `NennungRepository` references).
- Included missing `multitenancy.*` configuration keys in `additional-spring-configuration-metadata.json` to address IDE warnings.
This commit is contained in:
2026-04-14 12:39:53 +02:00
parent f961b6e771
commit a15cc5971f
4 changed files with 55 additions and 50 deletions
@@ -3,7 +3,17 @@ package at.mocode.entries.service.tenant
object TenantContextHolder {
private val tl = ThreadLocal<Tenant?>()
fun set(tenant: Tenant) { tl.set(tenant) }
fun set(tenant: Tenant?) { tl.set(tenant) }
fun clear() { tl.remove() }
fun current(): Tenant? = tl.get()
inline fun <T> withTenant(tenant: Tenant, block: () -> T): T {
val old = current()
set(tenant)
try {
return block()
} finally {
set(old)
}
}
}
@@ -0,0 +1,16 @@
{
"properties": [
{
"name": "multitenancy.registry.type",
"type": "java.lang.String",
"description": "Type of tenant registry (jdbc or inmem).",
"defaultValue": "jdbc"
},
{
"name": "multitenancy.defaultSchemas",
"type": "java.lang.String",
"description": "Comma-separated list of default schemas for inmem registry.",
"defaultValue": "public"
}
]
}