diff --git a/src/main/kotlin/org/eclipse/tractusx/managedidentitywallets/plugins/Scheduler.kt b/src/main/kotlin/org/eclipse/tractusx/managedidentitywallets/plugins/Scheduler.kt index 9efb8e617..a473cee1e 100644 --- a/src/main/kotlin/org/eclipse/tractusx/managedidentitywallets/plugins/Scheduler.kt +++ b/src/main/kotlin/org/eclipse/tractusx/managedidentitywallets/plugins/Scheduler.kt @@ -26,6 +26,9 @@ import com.github.kagkarlsson.scheduler.task.schedule.Schedules import io.ktor.application.* import kotlinx.coroutines.runBlocking import org.eclipse.tractusx.managedidentitywallets.Services +import org.eclipse.tractusx.managedidentitywallets.persistence.entities.SchedulerTasks +import org.jetbrains.exposed.sql.SchemaUtils +import org.jetbrains.exposed.sql.transactions.transaction import org.postgresql.ds.PGSimpleDataSource import org.sqlite.SQLiteDataSource import java.sql.DriverManager @@ -63,6 +66,12 @@ fun initDatabase(jdbcUrl: String): DataSource { // just a keepAliveConnection DriverManager.getConnection(jdbcUrl) + transaction { + // Create missing tables + SchemaUtils.createMissingTablesAndColumns(SchedulerTasks) + commit() + } + return dataSource } else { val dataSource = PGSimpleDataSource() diff --git a/src/test/kotlin/org/eclipse/tractusx/managedidentitywallets/ApplicationTest.kt b/src/test/kotlin/org/eclipse/tractusx/managedidentitywallets/ApplicationTest.kt index 48e02472d..e81c982cf 100644 --- a/src/test/kotlin/org/eclipse/tractusx/managedidentitywallets/ApplicationTest.kt +++ b/src/test/kotlin/org/eclipse/tractusx/managedidentitywallets/ApplicationTest.kt @@ -84,6 +84,7 @@ class ApplicationTest { put("auth.redirectUrl", System.getenv("CX_AUTH_REDIRECT_URL") ?: "http://localhost:8080/callback") put("bpdm.datapoolUrl", System.getenv("BPDM_DATAPOOL_URL") ?: "http://0.0.0.0:8080") + put("bpdm.pullDataAtHour", System.getenv("BPDM_PULL_DATA_AT_HOUR") ?: "23") } // just a keepAliveConnection DriverManager.getConnection(jdbcUrl) @@ -1611,4 +1612,23 @@ class ApplicationTest { } } + + @Test + fun testJobs() { + withTestApplication({ + setupEnvironment(environment) + configurePersistence() + configureOpenAPI() + configureSecurity() + configureRouting(walletService) + appRoutes(walletService, bpdService) + configureSerialization() + configureJobs() + Services.walletService = walletService + Services.businessPartnerDataService = bpdService + }) { + // expecting a successfull start + assertTrue(true) + } + } }