Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ru.tinkoff.kora.database.symbol.processor

import org.intellij.lang.annotations.Language
import ru.tinkoff.kora.ksp.common.AbstractSymbolProcessorTest
import ru.tinkoff.kora.ksp.common.KotlinCompilation

abstract class AbstractRepositoryTest : AbstractSymbolProcessorTest() {

Expand All @@ -14,7 +15,9 @@ abstract class AbstractRepositoryTest : AbstractSymbolProcessorTest() {
}

protected fun compile(connectionFactory: Any, arguments: List<*>, @Language("kotlin") vararg sources: String): TestObject {
compile0(listOf(RepositorySymbolProcessorProvider()), *sources)
KotlinCompilation()
.withClasspathJar("java-driver-core")
.compile(listOf(RepositorySymbolProcessorProvider()), *sources)
.assertSuccess()

val realArgs = arrayOfNulls<Any>(arguments.size + 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ abstract class AbstractCassandraRepositoryTest : AbstractRepositoryTest() {
import ru.tinkoff.kora.database.cassandra.mapper.parameter.*;

import java.util.concurrent.CompletionStage;
import reactor.core.publisher.*;

import com.datastax.oss.driver.api.core.cql.*;
import com.datastax.oss.driver.api.core.data.*;
""".trimIndent()
}

protected fun compile(arguments: List<*>, @Language("kotlin") vararg sources: String) = compile(executor, arguments, *sources)


}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package ru.tinkoff.kora.database.symbol.processor.cassandra

import org.junit.jupiter.api.Test
import ru.tinkoff.kora.kora.app.ksp.KoraAppProcessorProvider
import ru.tinkoff.kora.ksp.common.KotlinCompilation

class CassandraExtensionTest : AbstractCassandraRepositoryTest() {
@Test
fun testEntityRowMapper() {
compile0(
KotlinCompilation().withClasspathJar("java-driver-core").compile(
listOf(KoraAppProcessorProvider(), CassandraEntitySymbolProcessorProvider()),
"""
@KoraApp
Expand All @@ -25,7 +26,7 @@ class CassandraExtensionTest : AbstractCassandraRepositoryTest() {

@Test
fun testEntityListResultSetMapper() {
compile0(
KotlinCompilation().withClasspathJar("java-driver-core").compile(
listOf(KoraAppProcessorProvider(), CassandraEntitySymbolProcessorProvider()),
"""
@KoraApp
Expand All @@ -44,7 +45,7 @@ class CassandraExtensionTest : AbstractCassandraRepositoryTest() {

@Test
fun testEntitySingleResultSetMapper() {
compile0(
KotlinCompilation().withClasspathJar("java-driver-core").compile(
listOf(KoraAppProcessorProvider(), CassandraEntitySymbolProcessorProvider()),
"""
@KoraApp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import org.junit.jupiter.api.Test
import org.mockito.kotlin.*
import ru.tinkoff.kora.database.cassandra.mapper.result.CassandraResultSetMapper
import ru.tinkoff.kora.database.cassandra.mapper.result.CassandraRowMapper
import ru.tinkoff.kora.ksp.common.KotlinCompilation

class CassandraMapperTests : AbstractCassandraRepositoryTest() {

@Test
fun testRowMapperGenerated() {
compile0(
KotlinCompilation().withClasspathJar("java-driver-core").compile(
listOf(CassandraEntitySymbolProcessorProvider()),
"""
@EntityCassandra
Expand Down Expand Up @@ -42,7 +43,7 @@ class CassandraMapperTests : AbstractCassandraRepositoryTest() {

@Test
fun testResultSetMapperGenerated() {
compile0(
KotlinCompilation().withClasspathJar("java-driver-core").compile(
listOf(CassandraEntitySymbolProcessorProvider()),
"""
@EntityCassandra
Expand Down Expand Up @@ -76,7 +77,7 @@ class CassandraMapperTests : AbstractCassandraRepositoryTest() {

@Test
fun testListResultSetMapperGenerated() {
compile0(
KotlinCompilation().withClasspathJar("java-driver-core").compile(
listOf(CassandraEntitySymbolProcessorProvider()),
"""
@EntityCassandra
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import ru.tinkoff.kora.database.cassandra.mapper.result.CassandraRowColumnMapper
import ru.tinkoff.kora.database.symbol.processor.AbstractRepositoryTest
import ru.tinkoff.kora.database.symbol.processor.RepositorySymbolProcessorProvider
import ru.tinkoff.kora.database.symbol.processor.cassandra.udt.CassandraUdtSymbolProcessorProvider
import ru.tinkoff.kora.ksp.common.KotlinCompilation
import kotlin.reflect.KClass

class CassandraUdtTest : AbstractRepositoryTest() {
@Test
fun testUdt() {
compile0(
KotlinCompilation().withClasspathJar("java-driver-core").compile(
listOf(CassandraUdtSymbolProcessorProvider()),
"""
@ru.tinkoff.kora.database.cassandra.annotation.UDT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package ru.tinkoff.kora.camunda.zeebe.worker.symbol.processor

import org.assertj.core.api.Assertions.assertThat
import org.intellij.lang.annotations.Language
import org.junit.jupiter.api.Test
import ru.tinkoff.kora.camunda.zeebe.worker.KoraJobWorker
import ru.tinkoff.kora.ksp.common.AbstractSymbolProcessorTest
import ru.tinkoff.kora.ksp.common.KotlinCompilation
import java.lang.reflect.Method
import java.util.*

Expand All @@ -18,9 +20,13 @@ class ZeebeWorkerDeferredTests : AbstractSymbolProcessorTest() {
""".trimIndent()
}

fun compile(@Language("kotlin") vararg sources: String) = KotlinCompilation()
.withClasspathJar("zeebe-client-java")
.compile(listOf(ZeebeWorkerSymbolProcessorProvider()), *sources)

@Test
fun workerNoVars() {
compile0(listOf(ZeebeWorkerSymbolProcessorProvider()),
compile(
"""
@Component
class Handler {
Expand All @@ -44,7 +50,7 @@ class ZeebeWorkerDeferredTests : AbstractSymbolProcessorTest() {

@Test
fun workerVars() {
compile0(listOf(ZeebeWorkerSymbolProcessorProvider()),
compile(
"""
@Component
class Handler {
Expand All @@ -71,7 +77,7 @@ class ZeebeWorkerDeferredTests : AbstractSymbolProcessorTest() {

@Test
fun workerVar() {
compile0(listOf(ZeebeWorkerSymbolProcessorProvider()),
compile(
"""
@Component
class Handler {
Expand All @@ -96,7 +102,7 @@ class ZeebeWorkerDeferredTests : AbstractSymbolProcessorTest() {

@Test
fun workerReturnVars() {
compile0(listOf(ZeebeWorkerSymbolProcessorProvider()),
compile(
"""
@Component
class Handler {
Expand All @@ -123,7 +129,7 @@ class ZeebeWorkerDeferredTests : AbstractSymbolProcessorTest() {

@Test
fun workerContext() {
compile0(listOf(ZeebeWorkerSymbolProcessorProvider()),
compile(
"""
@Component
class Handler {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package ru.tinkoff.kora.camunda.zeebe.worker.symbol.processor

import org.assertj.core.api.Assertions.assertThat
import org.intellij.lang.annotations.Language
import org.junit.jupiter.api.Test
import ru.tinkoff.kora.camunda.zeebe.worker.KoraJobWorker
import ru.tinkoff.kora.ksp.common.AbstractSymbolProcessorTest
import ru.tinkoff.kora.ksp.common.KotlinCompilation
import java.lang.reflect.Method
import java.util.*

Expand All @@ -16,9 +18,13 @@ class ZeebeWorkerTests : AbstractSymbolProcessorTest() {
""".trimIndent()
}

fun compile(@Language("kotlin") vararg sources: String) = KotlinCompilation()
.withClasspathJar("zeebe-client-java")
.compile(listOf(ZeebeWorkerSymbolProcessorProvider()), *sources)

@Test
fun workerNoVars() {
compile0(listOf(ZeebeWorkerSymbolProcessorProvider()),
compile(
"""
@Component
class Handler {
Expand All @@ -42,7 +48,7 @@ class ZeebeWorkerTests : AbstractSymbolProcessorTest() {

@Test
fun workerVars() {
compile0(listOf(ZeebeWorkerSymbolProcessorProvider()),
compile(
"""
@Component
class Handler {
Expand All @@ -69,7 +75,7 @@ class ZeebeWorkerTests : AbstractSymbolProcessorTest() {

@Test
fun workerVar() {
compile0(listOf(ZeebeWorkerSymbolProcessorProvider()),
compile(
"""
@Component
class Handler {
Expand All @@ -94,7 +100,7 @@ class ZeebeWorkerTests : AbstractSymbolProcessorTest() {

@Test
fun workerReturnVars() {
compile0(listOf(ZeebeWorkerSymbolProcessorProvider()),
compile(
"""
@Component
class Handler {
Expand All @@ -121,7 +127,7 @@ class ZeebeWorkerTests : AbstractSymbolProcessorTest() {

@Test
fun workerContext() {
compile0(listOf(ZeebeWorkerSymbolProcessorProvider()),
compile(
"""
@Component
class Handler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ru.tinkoff.kora.s3.client.symbol.processor
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import ru.tinkoff.kora.ksp.common.AbstractSymbolProcessorTest
import ru.tinkoff.kora.ksp.common.KotlinCompilation

class S3AwsClientTests : AbstractSymbolProcessorTest() {

Expand All @@ -19,7 +20,15 @@ class S3AwsClientTests : AbstractSymbolProcessorTest() {
""".trimIndent()
}

fun compile0(vararg src: String) = compile0(listOf(S3ClientSymbolProcessorProvider()), *src)
fun compile0(vararg src: String) = KotlinCompilation()
.withClasspathJar("s3")
.withClasspathJar("aws-core")
.withClasspathJar("sdk-core")
.withClasspathJar("utils")
.withClasspathJar("http-client-spi")
.withClasspathJar("reactor-core")
.withClasspathJar("reactive-streams")
.compile(listOf(S3ClientSymbolProcessorProvider()), *src)

@Test
fun clientGetAws() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ru.tinkoff.kora.s3.client.symbol.processor
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import ru.tinkoff.kora.ksp.common.AbstractSymbolProcessorTest
import ru.tinkoff.kora.ksp.common.KotlinCompilation

class S3AwsSuspendClientTests : AbstractSymbolProcessorTest() {

Expand All @@ -18,7 +19,15 @@ class S3AwsSuspendClientTests : AbstractSymbolProcessorTest() {
import software.amazon.awssdk.services.s3.model.*
""".trimIndent()
}
fun compile0(vararg src: String) = compile0(listOf(S3ClientSymbolProcessorProvider()), *src)
fun compile0(vararg src: String) = KotlinCompilation()
.withClasspathJar("s3")
.withClasspathJar("aws-core")
.withClasspathJar("sdk-core")
.withClasspathJar("utils")
.withClasspathJar("http-client-spi")
.withClasspathJar("reactor-core")
.withClasspathJar("reactive-streams")
.compile(listOf(S3ClientSymbolProcessorProvider()), *src)

@Test
fun clientGetAws() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package ru.tinkoff.kora.s3.client.symbol.processor

import org.assertj.core.api.Assertions
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import ru.tinkoff.kora.ksp.common.AbstractSymbolProcessorTest
import ru.tinkoff.kora.ksp.common.KotlinCompilation

class S3KoraClientTests : AbstractSymbolProcessorTest() {

Expand All @@ -19,7 +19,10 @@ class S3KoraClientTests : AbstractSymbolProcessorTest() {
import software.amazon.awssdk.services.s3.model.*;
""".trimIndent()
}
fun compile0(vararg src: String) = compile0(listOf(S3ClientSymbolProcessorProvider()), *src)

fun compile0(vararg src: String) = KotlinCompilation()
.withClasspathJar("s3")
.compile(listOf(S3ClientSymbolProcessorProvider()), *src)

// Get
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ru.tinkoff.kora.s3.client.symbol.processor
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import ru.tinkoff.kora.ksp.common.AbstractSymbolProcessorTest
import ru.tinkoff.kora.ksp.common.KotlinCompilation

class S3KoraSuspendClientTests : AbstractSymbolProcessorTest() {

Expand All @@ -18,7 +19,10 @@ class S3KoraSuspendClientTests : AbstractSymbolProcessorTest() {
import software.amazon.awssdk.services.s3.model.*;
""".trimIndent()
}
fun compile0(vararg src: String) = compile0(listOf(S3ClientSymbolProcessorProvider()), *src)

fun compile0(vararg src: String) = KotlinCompilation()
.withClasspathJar("s3")
.compile(listOf(S3ClientSymbolProcessorProvider()), *src)

@Test
fun clientConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.junit.jupiter.api.Test
import ru.tinkoff.kora.kora.app.ksp.KoraAppProcessorProvider
import ru.tinkoff.kora.ksp.common.AbstractSymbolProcessorTest
import ru.tinkoff.kora.ksp.common.GraphUtil.toGraph
import ru.tinkoff.kora.ksp.common.KotlinCompilation
import java.util.*

class GrpcClientExtensionTest : AbstractSymbolProcessorTest() {
Expand All @@ -26,7 +27,12 @@ class GrpcClientExtensionTest : AbstractSymbolProcessorTest() {
}
}
""".trimIndent()
super.compile0(listOf(GrpcClientStubForSymbolProcessorProvider(), KoraAppProcessorProvider()), *patchedSources)
KotlinCompilation()
.withClasspathJar("grpc-api")
.withClasspathJar("grpc-stub")
.withClasspathJar("grpc-kotlin-stub")
.withClasspathJar("netty-transport")
.compile(listOf(GrpcClientStubForSymbolProcessorProvider(), KoraAppProcessorProvider()), *patchedSources)
compileResult.assertSuccess()
loadClass("TestAppGraph").toGraph().use { g ->
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.util.function.Function;

import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.*;
import static com.datastax.oss.driver.api.core.config.DefaultDriverOption.CONNECTION_WARN_INIT_ERROR;

public record CassandraParams(String host, int port, String dc, String keyspace, String username, String password) {
public CqlSession getSession() {
Expand All @@ -27,6 +26,7 @@ public CqlSession getSession() {
if (username != null && password != null) {
b.withAuthCredentials(username, password);
}

return b.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ru.tinkoff.kora.json.common.JsonReader
import ru.tinkoff.kora.json.common.JsonWriter
import ru.tinkoff.kora.kora.app.ksp.KoraAppProcessorProvider
import ru.tinkoff.kora.ksp.common.AbstractSymbolProcessorTest
import ru.tinkoff.kora.ksp.common.KotlinCompilation
import java.nio.charset.StandardCharsets

abstract class AbstractJsonSymbolProcessorTest : AbstractSymbolProcessorTest() {
Expand All @@ -22,7 +23,9 @@ abstract class AbstractJsonSymbolProcessorTest : AbstractSymbolProcessorTest() {
}

protected open fun compile(@Language("kotlin") vararg sources: String) {
compile0(listOf(JsonSymbolProcessorProvider(), KoraAppProcessorProvider()), *sources)
KotlinCompilation()
.withClasspathJar("jackson-core")
.compile(listOf(JsonSymbolProcessorProvider(), KoraAppProcessorProvider()), *sources)
.assertSuccess()
}

Expand Down
Loading