Skip to content

Commit

Permalink
docs: update
Browse files Browse the repository at this point in the history
  • Loading branch information
osoykan committed Dec 17, 2024
1 parent 77b93b2 commit 75c3a87
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 5 deletions.
5 changes: 5 additions & 0 deletions docs/Components/04-wiremock.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
33 changes: 33 additions & 0 deletions docs/Components/10-bridge.md
Original file line number Diff line number Diff line change
@@ -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<YourBean> {
this.doSomething()
}

using<Bean1, Bean2> { 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`.
1 change: 1 addition & 0 deletions docs/Components/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
32 changes: 27 additions & 5 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand All @@ -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
```
Expand All @@ -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.

Expand Down

0 comments on commit 75c3a87

Please sign in to comment.