From 75c3a8743e08b057d624b9f3a1eb9b58a0d2dcf9 Mon Sep 17 00:00:00 2001 From: Oguzhan Soykan Date: Tue, 17 Dec 2024 10:48:58 +0100 Subject: [PATCH] docs: update --- docs/Components/04-wiremock.md | 5 +++++ docs/Components/10-bridge.md | 33 +++++++++++++++++++++++++++++++++ docs/Components/index.md | 1 + docs/index.md | 32 +++++++++++++++++++++++++++----- 4 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 docs/Components/10-bridge.md diff --git a/docs/Components/04-wiremock.md b/docs/Components/04-wiremock.md index 52db8a12..90b6581d 100644 --- a/docs/Components/04-wiremock.md +++ b/docs/Components/04-wiremock.md @@ -144,3 +144,8 @@ test("behavioural tests") { Here we define a behaviour for the `/get-behaviour` endpoint. Initially, it returns a 503 status code with a message. Then, it returns a 200 status code with a `TestDto` object. + +!!! Note + + You can define multiple behaviours for the same endpoint, but it should start with `initially`. `Then` can be used + multiple times. diff --git a/docs/Components/10-bridge.md b/docs/Components/10-bridge.md new file mode 100644 index 00000000..b7a192a7 --- /dev/null +++ b/docs/Components/10-bridge.md @@ -0,0 +1,33 @@ +# Bridge + +Bridge component is used for accessing the DI container of the application. When the application is started, the bridge +is +created and the DI container is accessed in the tests. + +If you want to access to the beans of the application, you can simply do: + +```kotlin +// setup +TestSystem() + .with { + //other deps... + bridge() + } + +// while writing tests +validate { + using { + this.doSomething() + } + + using { bean1, bean2 -> + bean1.doSomething() + bean2.doSomething() + } +} +``` + +Both Spring-Boot and Ktor have `bridge` function built-in, so you don't have to add any extra dependency than +`com-trendyol:stove-ktor-testing-e2e` or `com-trendyol-stove-spring-testing-e2e`. If you are using Spring-Boot, the +bridge will be referring to the`ApplicationContext` and if you are using Ktor, it will be referring to the +`Application`. diff --git a/docs/Components/index.md b/docs/Components/index.md index c5f8869f..da3759ec 100644 --- a/docs/Components/index.md +++ b/docs/Components/index.md @@ -11,3 +11,4 @@ All the dependencies are pluggable. Stove supports: - [MongoDB](07-mongodb.md) - [Mssql](08-mssql.md) - [Redis](09-redis.md) +- [Bridge](10-bridge.md) diff --git a/docs/index.md b/docs/index.md index 29fa9a3c..93971b23 100644 --- a/docs/index.md +++ b/docs/index.md @@ -110,6 +110,7 @@ Stove supports the following components: - [Couchbase](Components/01-couchbase.md) - [Wiremock](Components/04-wiremock.md) - [HTTP](Components/05-http.md) +- [Bridge](Components/10-bridge.md) === "Gradle" @@ -744,6 +745,28 @@ override any dependency from the testing side that is being `time` related or `c ## Advanced +### Global Variables + +#### DEFAULT_REGISTRY + +The default container registry is `docker.io`. You can change it by setting the `DEFAULT_REGISTRY` variable. + +```kotlin +DEFAULT_REGISTRY = "your.registry.com" +``` + +This will effect all the components Stove wide. Or you can set it for each individual component by setting the`registry` +property, example for Kafka: + +```kotlin +KafkaSystemOptions( + containerOptions = KafkaContainerOptions( + registry = "your.registry.com", + tag = "latest" + ), +) +``` + ### Serializing and Deserializing Each component has its own serialization and deserialization mechanism. You can align Stove's serialization and @@ -763,7 +786,7 @@ and add your own serializer and deserializer. `StoveSerde` also keeps the reference to the aforementioned libraries: ```kotlin -StoveSerde.jackson +StoveSerde.jackson StoveSerde.gson StoveSerde.kotlinx ``` @@ -786,11 +809,10 @@ StoveSerde.kotlinx.anyStringSerde(yourJson()) When it comes to handling the time, no one wants to wait for 30 minutes for a scheduler job, or for a delayed task to be able to test it. In these situations what we need to do is `advancing` the time, or replacing the effect of the time for our needs. This -may require you -to change your code, too. Because, we might need to provide a time-free implementation to an interface, or we might need -to extract it to an interface if not properly implemented. +may require you to change your code, too. Because, we might need to provide a time-free implementation to an interface, +or we might need to extract it to an interface if not properly implemented. -For example, in international-service project we have a delayed command executor that accepts a task and a time for it +For example, imagine we have a delayed command executor that accepts a task and a time for it to delay it until it is right time to execute. But, in tests we need to replace this behaviour with the time-effect free implementation.