From 101557094298e08e6d66ed54a1cdb068a4bbacf3 Mon Sep 17 00:00:00 2001 From: Nils Breunese Date: Thu, 12 Sep 2024 12:42:30 +0200 Subject: [PATCH] GH-809 - Fix and improve Kotlin code examples in reference documentation. --- .../modules/ROOT/pages/documentation.adoc | 6 ++-- .../antora/modules/ROOT/pages/events.adoc | 10 +++--- .../modules/ROOT/pages/fundamentals.adoc | 4 +-- .../antora/modules/ROOT/pages/testing.adoc | 32 +++++++++---------- .../modules/ROOT/pages/verification.adoc | 2 +- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/docs/antora/modules/ROOT/pages/documentation.adoc b/src/docs/antora/modules/ROOT/pages/documentation.adoc index 05766e83..3a5b081a 100644 --- a/src/docs/antora/modules/ROOT/pages/documentation.adoc +++ b/src/docs/antora/modules/ROOT/pages/documentation.adoc @@ -39,7 +39,7 @@ Kotlin:: [source, kotlin, role="secondary"] ---- class DocumentationTests { - private val modules = ApplicationModules.of(Application::class) + private val modules = ApplicationModules.of(Application::class.java) @Test fun writeDocumentationSnippets() { @@ -240,7 +240,7 @@ Kotlin:: ---- class DocumentationTests { - private val modules = ApplicationModules.of(Application::class) + private val modules = ApplicationModules.of(Application::class.java) @Test fun writeDocumentationSnippets() { @@ -336,7 +336,7 @@ Kotlin:: ---- class DocumentationTests { - private val modules = ApplicationModules.of(Application::class) + private val modules = ApplicationModules.of(Application::class.java) @Test fun writeDocumentationSnippets() { diff --git a/src/docs/antora/modules/ROOT/pages/events.adoc b/src/docs/antora/modules/ROOT/pages/events.adoc index 8c7544f8..c70ddce5 100644 --- a/src/docs/antora/modules/ROOT/pages/events.adoc +++ b/src/docs/antora/modules/ROOT/pages/events.adoc @@ -465,7 +465,7 @@ class ExternalizationConfiguration { return EventExternalizationConfiguration.externalizing() // <1> .select(EventExternalizationConfiguration.annotatedAsExternalized()) // <2> - .mapping(SomeEvent.class, it -> …) // <3> + .mapping(SomeEvent.class, event -> …) // <3> .routeKey(WithKeyProperty.class, WithKeyProperty::getKey) // <4> .build(); } @@ -483,8 +483,8 @@ class ExternalizationConfiguration { EventExternalizationConfiguration.externalizing() // <1> .select(EventExternalizationConfiguration.annotatedAsExternalized()) // <2> - .mapping(SomeEvent::class, it -> …) // <3> - .routeKey(WithKeyProperty::class, WithKeyProperty::getKey) // <4> + .mapping(SomeEvent::class.java) { event -> … } // <3> + .routeKey(WithKeyProperty::class.java, WithKeyProperty::getKey) // <4> .build() } } @@ -541,7 +541,7 @@ class OrderIntegrationTests { fun someTestMethod(events: PublishedEvents events) { // … - var matchingMapped = events.ofType(OrderCompleted::class) + val matchingMapped = events.ofType(OrderCompleted::class.java) .matching(OrderCompleted::getOrderId, reference.getId()) assertThat(matchingMapped).hasSize(1) @@ -586,7 +586,7 @@ class OrderIntegrationTests { // … assertThat(events) - .contains(OrderCompleted::class) + .contains(OrderCompleted::class.java) .matching(OrderCompleted::getOrderId, reference.getId()) } } diff --git a/src/docs/antora/modules/ROOT/pages/fundamentals.adoc b/src/docs/antora/modules/ROOT/pages/fundamentals.adoc index a4ed4422..f1cb8b20 100644 --- a/src/docs/antora/modules/ROOT/pages/fundamentals.adoc +++ b/src/docs/antora/modules/ROOT/pages/fundamentals.adoc @@ -39,7 +39,7 @@ Kotlin:: + [source, kotlin, role="secondary"] ---- -var modules = ApplicationModules.of(Application::class) +val modules = ApplicationModules.of(Application::class.java) ---- ====== The `modules` will contain an in-memory representation of the application module arrangement derived from the codebase. @@ -102,7 +102,7 @@ Kotlin:: + [source, kotlin, role="secondary"] ---- -ApplicationModules.of(Application::class, JavaClass.Predicates.resideInAPackage("com.example.db")).verify() +ApplicationModules.of(Application::class.java, JavaClass.Predicates.resideInAPackage("com.example.db")).verify() ---- ====== diff --git a/src/docs/antora/modules/ROOT/pages/testing.adoc b/src/docs/antora/modules/ROOT/pages/testing.adoc index 62ff2ed9..0e357e7f 100644 --- a/src/docs/antora/modules/ROOT/pages/testing.adoc +++ b/src/docs/antora/modules/ROOT/pages/testing.adoc @@ -179,7 +179,7 @@ Kotlin:: scenario.publish(MyApplicationEvent(…)).… // Start with a bean invocation -scenario.stimulate(() -> someBean.someMethod(…)).… +scenario.stimulate(Runnable { someBean.someMethod(…) }).… ---- ====== @@ -263,9 +263,9 @@ Kotlin:: [source, kotlin, role="secondary"] ---- scenario.publish(new MyApplicationEvent(…)) - .andWaitForEventOfType(SomeOtherEvent::class) - .matching(event -> …) - .toArriveAndVerify(event -> …) + .andWaitForEventOfType(SomeOtherEvent::class.java) + .matching { event -> … } + .toArriveAndVerify { event -> … } ---- ====== @@ -287,9 +287,9 @@ Kotlin:: + [source, kotlin, role="secondary"] ---- -scenario.publish(new MyApplicationEvent(…)) - .andWaitForStateChange(() -> someBean.someMethod(…))) - .andVerify(result -> …) +scenario.publish(MyApplicationEvent(…)) + .andWaitForStateChange { someBean.someMethod(…) } + .andVerify { result -> … } ---- ====== @@ -310,7 +310,7 @@ Java:: [source, java, subs="+quotes", role="primary"] ---- scenario.publish(new MyApplicationEvent(…)) - **.customize(it -> it.atMost(Duration.ofSeconds(2)))** + **.customize(conditionFactory -> conditionFactory.atMost(Duration.ofSeconds(2)))** .andWaitForEventOfType(SomeOtherEvent.class) .matching(event -> …) .toArriveAndVerify(event -> …); @@ -320,10 +320,10 @@ Kotlin:: [source, kotlin, subs="+quotes", role="secondary"] ---- scenario.publish(MyApplicationEvent(…)) - **.customize(it -> it.atMost(Duration.ofSeconds(2)))** - .andWaitForEventOfType(SomeOtherEvent::class) - .matching(event -> …) - .toArriveAndVerify(event -> …) + **.customize { it.atMost(Duration.ofSeconds(2)) }** + .andWaitForEventOfType(SomeOtherEvent::class.java) + .matching { event -> … } + .toArriveAndVerify { event -> … } ---- ====== @@ -348,7 +348,7 @@ class MyTests { @Override Function getDefaultCustomizer(Method method, ApplicationContext context) { - return it -> …; + return conditionFactory -> …; } } } @@ -361,14 +361,14 @@ Kotlin:: class MyTests { @Test - fun myTestCase(scenario : Scenario) { + fun myTestCase(scenario: Scenario) { // scenario will be pre-customized with logic defined in MyCustomizer } class MyCustomizer : ScenarioCustomizer { - override fun getDefaultCustomizer(method : Method, context : ApplicationContext) : Function { - return it -> … + override fun getDefaultCustomizer(method: Method, context: ApplicationContext): UnaryOperator { + return UnaryOperator { conditionFactory -> … } } } } diff --git a/src/docs/antora/modules/ROOT/pages/verification.adoc b/src/docs/antora/modules/ROOT/pages/verification.adoc index 52b3fea2..ba6dc418 100644 --- a/src/docs/antora/modules/ROOT/pages/verification.adoc +++ b/src/docs/antora/modules/ROOT/pages/verification.adoc @@ -16,7 +16,7 @@ Kotlin:: + [source, kotlin, role="secondary"] ---- -ApplicationModules.of(Application::class).verify() +ApplicationModules.of(Application::class.java).verify() ---- ====== The verification includes the following rules: