CLOVIS
08/21/2023, 5:21 PMOperation
annotation.
Reading the documentation, however, I don't understand how events emitted by the structure should be represented.
To give a bit more precision:
• incoming events are dated. It's possible that we do not receive them in the order in which they were initially created.
• there are complex rules w.r.t which outgoing events are emitted based on which incoming events.
We suspect our system breaks down in edge cases of:
• events which are processed in the incorrect order from their creation date
• events which are processed in parallel in a way that is incoherent with the rules.
As a simplification, we can represent the structure as:
data class Incoming(
val id: UUID,
val createdAt: Instant,
val payload: String,
)
data class Outgoing(
val id: UUID,
val createdAt: Instant,
val payload: String,
)
class SystemUnderTest(
val emit: (Outgoing) -> Unit,
) {
fun receive(event: Incoming) {
// complex logic...
emit(otherEvent1)
emit(otherEvent2) // in some cases...
// ...
}
}
What would a Lincheck model test for this class look like?
I assume something like:
class SUTTest {
private val emit: (Outgoing) -> Unit = // what here??
private val sut = SystemUnderTest(emit)
@Operation fun eventType1() { sut.receive(UUID.random(), Instant.random(), "1") }
@Operation fun eventType2() { sut.receive(UUID.random(), Instant.random(), "2") }
}
But I can't figure out how to represent the different kinds of outgoing events we expect, such that Lincheck can find incoherent sequences.Petter Måhlén
08/22/2023, 5:43 AMCLOVIS
08/22/2023, 7:59 AM