Skip to content

Commit

Permalink
micronaut framework implemented.
Browse files Browse the repository at this point in the history
  • Loading branch information
anilcan.gul committed Dec 9, 2024
1 parent 3702bc2 commit da33f06
Show file tree
Hide file tree
Showing 268 changed files with 4,491 additions and 10,045 deletions.
369 changes: 173 additions & 196 deletions README.md

Large diffs are not rendered by default.

Empty file removed api/stove.api
Empty file.
54 changes: 40 additions & 14 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import org.gradle.kotlin.dsl.libs
import org.gradle.plugins.ide.idea.model.IdeaModel
import org.jetbrains.dokka.gradle.DokkaMultiModuleTask
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
Expand All @@ -10,13 +9,12 @@ plugins {
alias(libs.plugins.testLogger)
alias(libs.plugins.kover)
alias(libs.plugins.detekt)
alias(libs.plugins.binaryCompatibilityValidator)
id("stove-publishing") apply false
idea
java
}
group = "com.trendyol"
version = CI.version(project)
version = version()

allprojects {
extra.set("dokka.outputDirectory", rootDir.resolve("docs"))
Expand All @@ -42,21 +40,41 @@ kover {
}
}
}
val related = subprojects.of("lib", "spring", "examples", "ktor")
val related = subprojects.of("lib", "spring", "examples", "ktor", "micronaut-starter")
dependencies {
related.forEach {
kover(it)
}
}

subprojects.of("lib", "spring", "examples", "ktor") {
subprojects.of("lib", "spring", "examples", "ktor", "micronaut-starter") {
apply {
plugin("kotlin")
plugin(rootProject.libs.plugins.spotless.get().pluginId)
plugin(rootProject.libs.plugins.dokka.get().pluginId)
plugin(rootProject.libs.plugins.testLogger.get().pluginId)
plugin(rootProject.libs.plugins.kover.get().pluginId)
plugin(rootProject.libs.plugins.detekt.get().pluginId)
plugin(
rootProject.libs.plugins.spotless
.get()
.pluginId
)
plugin(
rootProject.libs.plugins.dokka
.get()
.pluginId
)
plugin(
rootProject.libs.plugins.testLogger
.get()
.pluginId
)
plugin(
rootProject.libs.plugins.kover
.get()
.pluginId
)
plugin(
rootProject.libs.plugins.detekt
.get()
.pluginId
)
plugin("idea")
}

Expand All @@ -76,13 +94,12 @@ subprojects.of("lib", "spring", "examples", "ktor") {
testImplementation(libs.kotest.runner.junit5)
testImplementation(libs.kotest.framework.api)
testImplementation(libs.kotest.property)
testImplementation(libs.kotest.arrow)
detektPlugins(libs.detekt.formatting)
}

spotless {
kotlin {
ktlint(libs.versions.ktlint.get()).setEditorConfigPath(rootProject.layout.projectDirectory.file(".editorconfig"))
ktlint().setEditorConfigPath(rootProject.layout.projectDirectory.file(".editorconfig"))
targetExclude("build/", "generated/", "out/")
targetExcludeIfContentContains("generated")
targetExcludeIfContentContainsRegex("generated.*")
Expand Down Expand Up @@ -141,10 +158,11 @@ val publishedProjects = listOf(
"stove-testing-e2e-redis",
"stove-ktor-testing-e2e",
"stove-spring-testing-e2e",
"stove-spring-testing-e2e-kafka"
"stove-spring-testing-e2e-kafka",
"stove-micronaut-testing-e2e"
)

subprojects.of("lib", "spring", "ktor", filter = { p -> publishedProjects.contains(p.name) }) {
subprojects.of("lib", "spring", "ktor", "micronaut-starter", filter = { p -> publishedProjects.contains(p.name) }) {
apply {
plugin("java")
plugin("stove-publishing")
Expand All @@ -160,3 +178,11 @@ tasks.withType<DokkaMultiModuleTask>().configureEach {
outputDirectory.set(file(rootDir.resolve("docs/source")))
}

fun version(): String = when {
System.getenv("SNAPSHOT") != null -> {
println("SNAPSHOT: ${System.getenv("SNAPSHOT")}")
project.properties["snapshot"].toString()
}

else -> project.properties["version"].toString()
}
20 changes: 0 additions & 20 deletions buildSrc/src/main/kotlin/CI.kt

This file was deleted.

42 changes: 3 additions & 39 deletions docs/Components/01-couchbase.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@

## Configure

After getting the library from the maven source, while configuring TestSystem you will have access to `couchbase`
function.
After getting the library from the maven source, while configuring TestSystem you will have access to `withCouchbase` function.
This function configures the Couchbase Docker container that is going to be started.

Here you can define a `defaultBucket` name.
Here you can define a `defaultBucket` name.

!!! warning
Make sure that your application has the same bucket names.
Make sure that your application has the same bucket names.

```kotlin
TestSystem()
Expand All @@ -42,38 +41,3 @@ Your application will start with the physical dependencies that are spun-up by t
## Migrations

Stove provides a way to run migrations before the test starts.

```kotlin
class CouchbaseMigration : DatabaseMigration<Cluster> {
override val order: Int = 1

override suspend fun execute(connection: Cluster) {
val bucket = connection.bucket(CollectionConstants.BUCKET_NAME)
listOf(CollectionConstants.PRODUCT_COLLECTION).forEach { collection ->
bucket.collections.createCollection(bucket.defaultScope().name, collection)
}
connection.waitUntilReady(30.seconds)
}
}
```

You can define your migration class by implementing the `DatabaseMigration` interface. You can define the order of the
migration by overriding the `order` property. The migrations will be executed in the order of the `order` property.

After defining your migration class, you can pass it to the `migrations` function of the `couchbase` configuration.

```kotlin
TestSystem()
.with {
couchbase {
CouchbaseSystemOptions(defaultBucket = "test-bucket", configureExposedConfiguration = { cfg ->
listOf(
"couchbase.hosts=${cfg.hostsWithPort}",
"couchbase.username=${cfg.username}",
"couchbase.password=${cfg.password}"
)
}).migrations<CouchbaseMigration>()
}
}
.run()
```
1 change: 0 additions & 1 deletion docs/Components/02-kafka.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Kafka

There are two ways to work with Kafka in Stove.

## Standalone Kafka

Expand Down
20 changes: 0 additions & 20 deletions docs/Components/03-elasticsearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,3 @@
```

## Configure

After getting the library from the maven source, while configuring TestSystem you will have access to `elasticsearch`
function.
This function configures the Elasticsearch Docker container that is going to be started.

```kotlin
TestSystem()
.with {
elasticsearch {
ElasticsearchSystemOptions(configureExposedConfiguration = { cfg ->
listOf(
"elasticsearch.hosts=${cfg.hostsWithPort}",
"elasticsearch.username=${cfg.username}",
"elasticsearch.password=${cfg.password}"
)
})
}
}
.run()
```
17 changes: 0 additions & 17 deletions docs/Components/04-wiremock.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,3 @@
```

## Configure

After getting the library from the maven source, while configuring TestSystem you will have access to `wiremock`
function.

This will start an instance of Wiremock server. You can configure the port of the Wiremock server.

```kotlin
TestSystem()
.with {
wiremock {
WiremockSystemOptions(
port = 8080,
)
}
}
.run()
```
51 changes: 0 additions & 51 deletions docs/Components/05-http.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,3 @@

## Configure

After getting the library from the maven source, while configuring TestSystem you will have access to `http`

```kotlin
TestSystem()
.with {
http {
HttpClientSystemOptions(
baseUrl = "http://localhost:8080",
)
}
}
.run()
```

The other options that you can set are:
```kotlin
data class HttpClientSystemOptions(
/**
* Base URL of the HTTP client.
*/
val baseUrl: String,

/**
* Content converter for the HTTP client. Default is JacksonConverter. You can use GsonConverter or any other converter.
* If you want to use your own converter, you can implement ContentConverter interface.
*/
val contentConverter: ContentConverter = JacksonConverter(StoveSerde.jackson.default),

/**
* Timeout for the HTTP client. Default is 30 seconds.
*/
val timeout: Duration = 30.seconds,

/**
* Create client function for the HTTP client. Default is jsonHttpClient.
*/
val createClient: () -> io.ktor.client.HttpClient = { jsonHttpClient(timeout, contentConverter) }
)
```

## Usage

```kotlin
validate {
http {
get<YourResponse>("/relative-url") { actual ->
actual shouldBe expected
}
}
}
```
41 changes: 0 additions & 41 deletions docs/Components/06-postgresql.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,3 @@

## Configure

```kotlin
TestSystem()
.with {
postgresql {
PostgresqlSystemOptions {
listOf(
"postgresql.host=${it.host}",
"postgresql.port=${it.port}",
"postgresql.database=${it.database}",
"postgresql.username=${it.username}",
"postgresql.password=${it.password}"
)
}
}
}.run()
```

## Usage

```kotlin
TestSystem.validate {
postgresql {
shouldExecute(
"""
DROP TABLE IF EXISTS Dummies;
CREATE TABLE IF NOT EXISTS Dummies (
id serial PRIMARY KEY,
description VARCHAR (50) NOT NULL
);
""".trimIndent()
)
shouldExecute("INSERT INTO Dummies (description) VALUES ('${testCase.name.testName}')")
shouldQuery<IdAndDescription>("SELECT * FROM Dummies", mapper = {
IdAndDescription(it.getLong("id"), it.getString("description"))
}) { actual ->
actual.size shouldBeGreaterThan 0
actual.first().description shouldBe testCase.name.testName
}
}
}
```
42 changes: 0 additions & 42 deletions docs/Components/07-mongodb.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,3 @@

## Configure

```kotlin
TestSystem()
.with {
mongodb {
MongodbSystemOptions(
listOf(
"mongodb.host=${it.host}",
"mongodb.port=${it.port}",
"mongodb.database=${it.database}",
"mongodb.username=${it.username}",
"mongodb.password=${it.password}"
)
)
}
}
.run()
```

## Usage

```kotlin
test("should save and get with string objectId") {
val id = ObjectId()
validate {
mongodb {
save(
ExampleInstanceWithStringObjectId(
id = id.toHexString(),
aggregateId = id.toHexString(),
description = testCase.name.testName
),
id.toHexString()
)
shouldGet<ExampleInstanceWithStringObjectId>(id.toHexString()) { actual ->
actual.aggregateId shouldBe id.toHexString()
actual.description shouldBe testCase.name.testName
}
}
}
}
```

Loading

0 comments on commit da33f06

Please sign in to comment.