Skip to content

Improve/fix Kotlin code examples #809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
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
6 changes: 3 additions & 3 deletions src/docs/antora/modules/ROOT/pages/documentation.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down
10 changes: 5 additions & 5 deletions src/docs/antora/modules/ROOT/pages/events.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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()
}
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -586,7 +586,7 @@ class OrderIntegrationTests {

// …
assertThat(events)
.contains(OrderCompleted::class)
.contains(OrderCompleted::class.java)
.matching(OrderCompleted::getOrderId, reference.getId())
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/docs/antora/modules/ROOT/pages/fundamentals.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()
----
======

Expand Down
32 changes: 16 additions & 16 deletions src/docs/antora/modules/ROOT/pages/testing.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Kotlin::
scenario.publish(MyApplicationEvent(…)).…

// Start with a bean invocation
scenario.stimulate(() -> someBean.someMethod(…)).…
scenario.stimulate(Runnable { someBean.someMethod(…) }).…
----
======

Expand Down Expand Up @@ -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 -> … }
----
======

Expand All @@ -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 -> … }
----
======

Expand All @@ -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 -> …);
Expand All @@ -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 -> … }
----
======

Expand All @@ -348,7 +348,7 @@ class MyTests {

@Override
Function<ConditionFactory, ConditionFactory> getDefaultCustomizer(Method method, ApplicationContext context) {
return it -> …;
return conditionFactory -> …;
}
}
}
Expand All @@ -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<ConditionFactory, ConditionFactory> {
return it -> …
override fun getDefaultCustomizer(method: Method, context: ApplicationContext): UnaryOperator<ConditionFactory> {
return UnaryOperator { conditionFactory -> … }
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/docs/antora/modules/ROOT/pages/verification.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down