-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(364): provide CorrelationDataProviders and test for payload+meta (…
- Loading branch information
1 parent
f4da660
commit b0a307f
Showing
11 changed files
with
173 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
extension/jgiven/core/src/main/kotlin/aggregate/AggregateTestFixtureExt.kt
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
extension/jgiven/core/src/main/kotlin/aggregate/_reflection.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.holixon.axon.testing.jgiven.aggregate | ||
|
||
import io.holixon.axon.testing.jgiven.AxonJGiven.getDeclaredAccessibleField | ||
import io.holixon.axon.testing.jgiven.AxonJGiven.getDeclaredAccessibleMethod | ||
import org.axonframework.test.aggregate.AggregateTestFixture | ||
import org.axonframework.test.aggregate.ResultValidator | ||
import java.lang.reflect.Field | ||
import java.lang.reflect.Method | ||
|
||
internal object AggregateTestFixtureReflection { | ||
|
||
private val method_buildResultValidator: Method = AggregateTestFixture::class.java.getDeclaredAccessibleMethod("buildResultValidator") | ||
private val field_aggregateIdentifier: Field = AggregateTestFixture::class.java.getDeclaredAccessibleField("aggregateIdentifier") | ||
|
||
@Suppress("UNCHECKED_CAST") | ||
fun <T> buildResultValidator(fixture: AggregateTestFixture<T>): ResultValidator<T> = method_buildResultValidator.invoke(fixture) as ResultValidator<T> | ||
|
||
val <T> AggregateTestFixture<T>.aggregateIdentifier: String? get() = field_aggregateIdentifier.get(this) as String? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
extension/jgiven/core/src/test/kotlin/aggregate/AggregateTestFixtureBuilderTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package io.holixon.axon.testing.jgiven.aggregate | ||
|
||
import com.tngtech.jgiven.annotation.ProvidedScenarioState | ||
import io.holixon.axon.testing.jgiven.AxonJGiven | ||
import io.holixon.axon.testing.jgiven.AxonJGivenTestFixtures.AggregateFixtureScenarioTest | ||
import io.holixon.axon.testing.jgiven.AxonJGivenTestFixtures.CreateDummyAggregate | ||
import io.holixon.axon.testing.jgiven.AxonJGivenTestFixtures.DummyAggregate | ||
import io.holixon.axon.testing.jgiven.AxonJGivenTestFixtures.DummyAggregateCreated | ||
import io.toolisticon.testing.jgiven.GIVEN | ||
import io.toolisticon.testing.jgiven.THEN | ||
import io.toolisticon.testing.jgiven.WHEN | ||
import org.axonframework.commandhandling.CommandMessage | ||
import org.axonframework.messaging.MessageDispatchInterceptor | ||
import org.axonframework.messaging.correlation.SimpleCorrelationDataProvider | ||
import org.junit.jupiter.api.Nested | ||
import org.junit.jupiter.api.Test | ||
import java.util.function.BiFunction | ||
|
||
internal class AggregateTestFixtureBuilderTest { | ||
|
||
@Nested | ||
inner class RegisterCorrelationDataProvider : AggregateFixtureScenarioTest<DummyAggregate>() { | ||
|
||
private fun addFooMetaToEveryCommand(value: String) = MessageDispatchInterceptor<CommandMessage<*>> { | ||
BiFunction { _, cmd -> cmd.andMetaData(mapOf("foo" to value)) } | ||
} | ||
|
||
@ProvidedScenarioState | ||
val fixture = AxonJGiven.aggregateTestFixtureBuilder<DummyAggregate>() | ||
.registerCommandDispatchInterceptor(addFooMetaToEveryCommand("bar")) | ||
.registerCorrelationDataProvider(SimpleCorrelationDataProvider("foo")) | ||
.build() | ||
|
||
@Test | ||
fun `metaData foo=bar is propagated to event`() { | ||
GIVEN.noPriorActivity() | ||
|
||
WHEN.command(CreateDummyAggregate("1")) | ||
|
||
THEN | ||
.expectEventWithMetaData(DummyAggregateCreated("1"), "foo" to "bar") | ||
} | ||
} | ||
|
||
|
||
@Nested | ||
inner class EmptyFixture : AggregateFixtureScenarioTest<DummyAggregate>() { | ||
|
||
@ProvidedScenarioState | ||
val fixture = AxonJGiven.aggregateTestFixtureBuilder<DummyAggregate>().build() | ||
|
||
@Test | ||
fun `create aggregate`() { | ||
GIVEN | ||
.noPriorActivity() | ||
|
||
WHEN | ||
.command(CreateDummyAggregate("1")) | ||
|
||
THEN | ||
.expectEvent(DummyAggregateCreated("1")) | ||
} | ||
|
||
@Test | ||
fun `just no events`() { | ||
GIVEN | ||
.noPriorActivity() | ||
|
||
THEN | ||
.expectNoEvents() | ||
} | ||
} | ||
|
||
} |
40 changes: 0 additions & 40 deletions
40
extension/jgiven/core/src/test/kotlin/aggregate/DummyAggregateTest.kt
This file was deleted.
Oops, something went wrong.