Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.softwaremill.okapi.core

/**
* Shared no-op test doubles for okapi-core. A single source means a [TransactionRunner] contract
* change is a one-line edit, not a sweep across every scheduler/purger test.
*/

internal fun noOpTransactionRunner() = object : TransactionRunner {
override fun <T> runInTransaction(block: () -> T): T = block()
}
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,6 @@ class OutboxPurgerTest : FunSpec({
}
})

private fun noOpTransactionRunner() = object : TransactionRunner {
override fun <T> runInTransaction(block: () -> T): T = block()
}

private fun stubStore(onRemove: (Instant, Int) -> Int = { _, _ -> 0 }) = object : OutboxStore {
override fun persist(entry: OutboxEntry) = entry
override fun claimPending(limit: Int) = emptyList<OutboxEntry>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ class OutboxSchedulerTest : FunSpec({
}
})

private fun noOpTransactionRunner() = object : TransactionRunner {
override fun <T> runInTransaction(block: () -> T): T = block()
}

private fun stubProcessor(onProcessNext: (Int) -> Unit): OutboxProcessor {
val store = object : OutboxStore {
override fun persist(entry: OutboxEntry) = entry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,3 @@ class DataSourceQualifierAutoConfigurationTest : FunSpec({
}
}
})

private fun noOpTransactionRunner() = object : TransactionRunner {
override fun <T> runInTransaction(block: () -> T): T = block()
}
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,3 @@ private fun canLoadClass(fqcn: String, classLoader: ClassLoader): Boolean = try
} catch (_: ClassNotFoundException) {
false
}

private fun noOpTransactionRunner() = object : TransactionRunner {
override fun <T> runInTransaction(block: () -> T): T = block()
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.softwaremill.okapi.core.MessageDeliverer
import com.softwaremill.okapi.core.OutboxEntry
import com.softwaremill.okapi.core.OutboxStatus
import com.softwaremill.okapi.core.OutboxStore
import com.softwaremill.okapi.core.TransactionRunner
import org.springframework.beans.factory.support.BeanDefinitionBuilder
import org.springframework.context.support.GenericApplicationContext
import java.time.Instant
Expand All @@ -31,6 +32,10 @@ internal fun stubDelivererWithType(t: String) = object : MessageDeliverer {
override fun deliver(entry: OutboxEntry) = DeliveryResult.Success
}

internal fun noOpTransactionRunner() = object : TransactionRunner {
override fun <T> runInTransaction(block: () -> T): T = block()
}

/**
* Registers a bean via [GenericApplicationContext.registerBeanDefinition], optionally `@Primary`.
* Collapses the `BeanDefinitionBuilder.genericBeanDefinition(...).beanDefinition.apply { isPrimary }`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,3 @@ private fun resolveSpringBootClass(vararg candidateFqcns: String): Class<*> {
}
} ?: error("None of $candidateFqcns resolves on this Spring Boot runtime; check spring-boot-starter-actuator on the test classpath.")
}

private fun noOpTransactionRunner() = object : TransactionRunner {
override fun <T> runInTransaction(block: () -> T): T = block()
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,3 @@ class OutboxPurgerAutoConfigurationTest : FunSpec({
scheduler.isRunning shouldBe false
}
})

private fun noOpTransactionRunner() = object : TransactionRunner {
override fun <T> runInTransaction(block: () -> T): T = block()
}