fixing Gradle Probleme

This commit is contained in:
Stefan Mogeritsch 2025-10-09 13:11:31 +02:00
parent 1096f9e9e6
commit dbc17b9233
9 changed files with 80 additions and 77 deletions

View File

@ -38,7 +38,7 @@ allprojects {
subprojects {
// Note: Kotlin compiler configuration is handled by individual modules
// Root project doesn't apply Kotlin plugins, so we can't configure KotlinCompile tasks here
// a Root project doesn't apply Kotlin plugins, so we can't configure KotlinCompile tasks here
tasks.withType<Test>().configureEach {
useJUnitPlatform {
@ -47,7 +47,10 @@ subprojects {
// Configure CDS in auto-mode to prevent bootstrap classpath warnings
jvmArgs("-Xshare:auto", "-Djdk.instrument.traceUsage=false")
// Increase test JVM memory with a stable configuration
minHeapSize = "512m"
maxHeapSize = "2g"
// Parallel test execution for better performance
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
// Removed byte-buddy-agent configuration to fix Gradle 9.0.0 deprecation warning
// The agent configuration was causing Task.project access at execution time
}

View File

@ -133,18 +133,18 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
}
}
//// Configure duplicate handling strategy for distribution tasks
//tasks.withType<Tar> {
// duplicatesStrategy = DuplicatesStrategy.EXCLUDE
//}
//
//tasks.withType<Zip> {
// duplicatesStrategy = DuplicatesStrategy.EXCLUDE
//}
// Configure a duplicate handling strategy for distribution tasks
tasks.withType<Tar> {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
tasks.withType<Zip> {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
// Duplicate-Handling für Distribution
tasks.withType<Copy> {
duplicatesStrategy = DuplicatesStrategy.WARN // Statt EXCLUDE
duplicatesStrategy = DuplicatesStrategy.EXCLUDE // Statt EXCLUDE
}
tasks.withType<Sync> {

View File

@ -11,7 +11,8 @@ kotlin {
compilerOptions {
freeCompilerArgs.addAll(
"-opt-in=kotlin.time.ExperimentalTime",
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-opt-in=kotlin.uuid.ExperimentalUuidApi"
)
}
}

View File

@ -7,10 +7,8 @@ import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import java.util.*
import kotlin.time.Clock
import kotlin.time.Instant
import kotlin.uuid.ExperimentalUuidApi
import kotlin.uuid.Uuid
/**
@ -28,11 +26,10 @@ class JacksonEventSerializerTest {
serializer.registerEventType(SimpleTestEvent::class.java, "SimpleTestEvent")
}
@OptIn(ExperimentalUuidApi::class)
@Test
fun `should serialize and deserialize simple event correctly`() {
val aggregateId: Uuid = UUID.randomUUID()
val eventId: UUID? = UUID.randomUUID()
val aggregateId = Uuid.random()
val eventId = Uuid.random()
val timestamp = Clock.System.now()
val event = SimpleTestEvent(
@ -55,10 +52,10 @@ class JacksonEventSerializerTest {
@Test
fun `should handle serialization of complex event types with nested objects`() {
val aggregateId = UUID.randomUUID()
val eventId = UUID.randomUUID()
val aggregateId = Uuid.random()
val eventId = Uuid.random()
val timestamp = Clock.System.now()
val correlationId = UUID.randomUUID()
val correlationId = Uuid.random()
val event = ComplexTestEvent(
aggregateId = AggregateId(aggregateId),
@ -88,7 +85,7 @@ class JacksonEventSerializerTest {
@Test
fun `should throw exception for unregistered event types during deserialization`() {
val aggregateId = UUID.randomUUID()
val aggregateId = Uuid.random()
val unregisteredEvent = UnregisteredTestEvent(
aggregateId = AggregateId(aggregateId),
version = EventVersion(1L),
@ -109,7 +106,7 @@ class JacksonEventSerializerTest {
@Test
fun `should handle null optional values gracefully`() {
val aggregateId = UUID.randomUUID()
val aggregateId = Uuid.random()
val event = SimpleTestEvent(
aggregateId = AggregateId(aggregateId),
version = EventVersion(1L),
@ -130,11 +127,11 @@ class JacksonEventSerializerTest {
@Test
fun `should preserve event metadata correctly in serialization`() {
val aggregateId = UUID.randomUUID()
val eventId = UUID.randomUUID()
val aggregateId = Uuid.random()
val eventId = Uuid.random()
val timestamp = Clock.System.now()
val correlationId = UUID.randomUUID()
val causationId = UUID.randomUUID()
val correlationId = Uuid.random()
val causationId = Uuid.random()
val event = SimpleTestEvent(
aggregateId = AggregateId(aggregateId),
@ -187,7 +184,7 @@ class JacksonEventSerializerTest {
@Test
fun `should auto-register event types during serialization`() {
val newSerializer = JacksonEventSerializer()
val aggregateId = UUID.randomUUID()
val aggregateId = Uuid.random()
val event = SimpleTestEvent(
aggregateId = AggregateId(aggregateId),
@ -215,8 +212,8 @@ class JacksonEventSerializerTest {
val eventId = serializer.getEventId(testMap)
val version = serializer.getVersion(testMap)
assertEquals(UUID.fromString("123e4567-e89b-12d3-a456-426614174000"), aggregateId)
assertEquals(UUID.fromString("987fcdeb-51a2-43d1-9f12-123456789abc"), eventId)
assertEquals(Uuid.parse("123e4567-e89b-12d3-a456-426614174000"), aggregateId)
assertEquals(Uuid.parse("987fcdeb-51a2-43d1-9f12-123456789abc"), eventId)
assertEquals(42L, version)
}
@ -243,7 +240,7 @@ class JacksonEventSerializerTest {
override val version: EventVersion,
val name: String,
override val eventType: EventType = EventType("SimpleTestEvent"),
override val eventId: EventId = EventId(UUID.randomUUID()),
override val eventId: EventId = EventId(Uuid.random()),
override val timestamp: Instant = Clock.System.now(),
override val correlationId: CorrelationId? = null,
override val causationId: CausationId? = null
@ -254,7 +251,7 @@ class JacksonEventSerializerTest {
override val version: EventVersion,
val complexData: ComplexData,
override val eventType: EventType = EventType("ComplexTestEvent"),
override val eventId: EventId = EventId(UUID.randomUUID()),
override val eventId: EventId = EventId(Uuid.random()),
override val timestamp: Instant = Clock.System.now(),
override val correlationId: CorrelationId? = null,
override val causationId: CausationId? = null
@ -265,7 +262,7 @@ class JacksonEventSerializerTest {
override val version: EventVersion,
val data: String,
override val eventType: EventType = EventType("UnregisteredTestEvent"),
override val eventId: EventId = EventId(UUID.randomUUID()),
override val eventId: EventId = EventId(Uuid.random()),
override val timestamp: Instant = Clock.System.now(),
override val correlationId: CorrelationId? = null,
override val causationId: CausationId? = null

View File

@ -21,9 +21,9 @@ import org.testcontainers.containers.GenericContainer
import org.testcontainers.junit.jupiter.Container
import org.testcontainers.junit.jupiter.Testcontainers
import org.testcontainers.utility.DockerImageName
import java.util.*
import java.util.concurrent.*
import java.util.concurrent.atomic.AtomicInteger
import kotlin.uuid.Uuid
/**
* Consumer Resilience Tests - Important for Event-Processing reliability.
@ -167,7 +167,7 @@ class RedisEventConsumerResilienceTest {
@Test
fun `should handle multiple consumers processing events without conflicts`() {
val aggregateId = UUID.randomUUID()
val aggregateId = Uuid.random()
val latch = CountDownLatch(2)
val processedEvents = CopyOnWriteArrayList<DomainEvent>()
@ -232,7 +232,7 @@ class RedisEventConsumerResilienceTest {
@Test
fun `should handle consumer group creation and recovery`() {
// Test that a consumer group is created automatically during init()
val aggregateId = UUID.randomUUID()
val aggregateId = Uuid.random()
val latch = CountDownLatch(1)
val receivedEvents = CopyOnWriteArrayList<DomainEvent>()
@ -263,7 +263,7 @@ class RedisEventConsumerResilienceTest {
@Test
fun `should process events exactly once in consumer group`() {
val aggregateId = UUID.randomUUID()
val aggregateId = Uuid.random()
val numberOfEvents = 10
val processedEvents = ConcurrentHashMap<String, AtomicInteger>()
val latch = CountDownLatch(numberOfEvents)
@ -326,7 +326,7 @@ class RedisEventConsumerResilienceTest {
@Test
fun `should handle slow event handlers gracefully`() {
val aggregateId = UUID.randomUUID()
val aggregateId = Uuid.random()
val processedEvents = CopyOnWriteArrayList<String>()
val latch = CountDownLatch(3)
@ -373,7 +373,7 @@ class RedisEventConsumerResilienceTest {
@Test
fun `should handle consumer restart correctly`() {
val aggregateId = UUID.randomUUID()
val aggregateId = Uuid.random()
val firstPhaseEvents = mutableListOf<DomainEvent>()
val secondPhaseEvents = mutableListOf<DomainEvent>()
@ -434,7 +434,7 @@ class RedisEventConsumerResilienceTest {
// Ensure clean state for this test
cleanupRedis()
val aggregateId = UUID.randomUUID()
val aggregateId = Uuid.random()
val processedEvents = CopyOnWriteArrayList<String>()
val latch = CountDownLatch(3) // Expecting 3 events to be processed (2 success + 1 failure)
@ -486,14 +486,14 @@ class RedisEventConsumerResilienceTest {
// Test event classes
@Serializable
data class ResilienceTestEvent(
@Transient override val aggregateId: AggregateId = AggregateId(UUID.randomUUID()),
@Transient override val aggregateId: AggregateId = AggregateId(Uuid.random()),
@Transient override val version: EventVersion = EventVersion(0),
val data: String
) : BaseDomainEvent(aggregateId, EventType("ResilienceTestEvent"), version)
@Serializable
data class SlowTestEvent(
@Transient override val aggregateId: AggregateId = AggregateId(UUID.randomUUID()),
@Transient override val aggregateId: AggregateId = AggregateId(Uuid.random()),
@Transient override val version: EventVersion = EventVersion(0),
val data: String,
val processingTimeMs: Long
@ -501,7 +501,7 @@ class RedisEventConsumerResilienceTest {
@Serializable
data class FailingTestEvent(
@Transient override val aggregateId: AggregateId = AggregateId(UUID.randomUUID()),
@Transient override val aggregateId: AggregateId = AggregateId(Uuid.random()),
@Transient override val version: EventVersion = EventVersion(0),
val data: String,
val shouldFail: Boolean

View File

@ -20,8 +20,8 @@ import org.testcontainers.containers.GenericContainer
import org.testcontainers.junit.jupiter.Container
import org.testcontainers.junit.jupiter.Testcontainers
import org.testcontainers.utility.DockerImageName
import java.util.*
import kotlin.time.Clock
import kotlin.uuid.Uuid
/**
* Simplified error handling tests for RedisEventStore using Testcontainers.
@ -79,7 +79,7 @@ class RedisEventStoreErrorHandlingTest {
@Test
fun `should handle large event payloads correctly without memory issues`() {
val aggregateId = UUID.randomUUID()
val aggregateId = Uuid.random()
// Create an event with a very large payload (1MB)
val largeData = "X".repeat(1024 * 1024) // 1MB of data
@ -110,7 +110,7 @@ class RedisEventStoreErrorHandlingTest {
@Test
fun `should handle multiple large events in sequence`() {
val aggregateId = UUID.randomUUID()
val aggregateId = Uuid.random()
val numberOfLargeEvents = 10
val sizePerEvent = 100 * 1024 // 100KB per event
@ -144,7 +144,7 @@ class RedisEventStoreErrorHandlingTest {
@Test
fun `should handle corrupted data gracefully during deserialization by skipping bad events`() {
val aggregateId = UUID.randomUUID()
val aggregateId = Uuid.random()
val streamKey = "test-stream:$aggregateId"
// First, add a valid event
@ -161,7 +161,7 @@ class RedisEventStoreErrorHandlingTest {
"eventData" to "{\"corrupted\":\"json\",\"missing\":", // Invalid JSON - missing closing brace
"aggregateId" to aggregateId.toString(),
"version" to "2",
"eventId" to UUID.randomUUID().toString(),
"eventId" to Uuid.random().toString(),
"timestamp" to Clock.System.now().toString()
)
@ -193,7 +193,7 @@ class RedisEventStoreErrorHandlingTest {
@Test
fun `should handle unregistered event types gracefully during read operations`() {
val aggregateId = UUID.randomUUID()
val aggregateId = Uuid.random()
val streamKey = "test-stream:$aggregateId"
// Add a valid registered event first
@ -210,7 +210,7 @@ class RedisEventStoreErrorHandlingTest {
"eventData" to """{"someField": "someValue", "aggregateId": {"value": "$aggregateId"}, "version": {"value": 2}}""",
"aggregateId" to aggregateId.toString(),
"version" to "2",
"eventId" to UUID.randomUUID().toString(),
"eventId" to Uuid.random().toString(),
"timestamp" to Clock.System.now().toString()
)
@ -234,7 +234,7 @@ class RedisEventStoreErrorHandlingTest {
@Test
fun `should handle concurrent version conflicts properly with retry logic`() {
val aggregateId = UUID.randomUUID()
val aggregateId = Uuid.random()
// Create an initial event
val event1 = TestErrorEvent(
@ -279,7 +279,7 @@ class RedisEventStoreErrorHandlingTest {
@Test
fun `should handle complex nested object serialization correctly`() {
val aggregateId = UUID.randomUUID()
val aggregateId = Uuid.random()
val complexEvent = ComplexErrorEvent(
aggregateId = AggregateId(aggregateId),
@ -319,14 +319,14 @@ class RedisEventStoreErrorHandlingTest {
// Test event classes
@Serializable
data class TestErrorEvent(
@Transient override val aggregateId: AggregateId = AggregateId(UUID.randomUUID()),
@Transient override val aggregateId: AggregateId = AggregateId(Uuid.random()),
@Transient override val version: EventVersion = EventVersion(0),
val data: String
) : BaseDomainEvent(aggregateId, EventType("TestErrorEvent"), version)
@Serializable
data class LargePayloadEvent(
@Transient override val aggregateId: AggregateId = AggregateId(UUID.randomUUID()),
@Transient override val aggregateId: AggregateId = AggregateId(Uuid.random()),
@Transient override val version: EventVersion = EventVersion(0),
val largeData: String,
val metadata: Map<String, String>
@ -334,7 +334,7 @@ class RedisEventStoreErrorHandlingTest {
@Serializable
data class ComplexErrorEvent(
@Transient override val aggregateId: AggregateId = AggregateId(UUID.randomUUID()),
@Transient override val aggregateId: AggregateId = AggregateId(Uuid.random()),
@Transient override val version: EventVersion = EventVersion(0),
val nestedData: ComplexNestedData
) : BaseDomainEvent(aggregateId, EventType("ComplexErrorEvent"), version)

View File

@ -19,7 +19,7 @@ import org.testcontainers.containers.GenericContainer
import org.testcontainers.junit.jupiter.Container
import org.testcontainers.junit.jupiter.Testcontainers
import org.testcontainers.utility.DockerImageName
import java.util.*
import kotlin.uuid.Uuid
/**
* Stream-specific tests for RedisEventStore - Core functionality validation.
@ -75,7 +75,7 @@ class RedisEventStoreStreamTest {
@Test
fun `readFromStream should respect fromVersion and toVersion parameters`() {
val aggregateId = UUID.randomUUID()
val aggregateId = Uuid.random()
val events = (1..10).map { i ->
StreamTestEvent(
aggregateId = AggregateId(aggregateId),
@ -111,8 +111,8 @@ class RedisEventStoreStreamTest {
@Test
fun `readAllEvents should handle pagination correctly`() {
val aggregateId1 = UUID.randomUUID()
val aggregateId2 = UUID.randomUUID()
val aggregateId1 = Uuid.random()
val aggregateId2 = Uuid.random()
val events1 = (1..5).map { i ->
StreamTestEvent(
@ -157,14 +157,14 @@ class RedisEventStoreStreamTest {
@Test
fun `getStreamVersion should return -1 for non-existent streams`() {
val nonExistentStreamId = UUID.randomUUID()
val nonExistentStreamId = Uuid.random()
val version = eventStore.getStreamVersion(nonExistentStreamId)
assertEquals(0L, version) // Redis streams return 0 for non-existent streams, not -1
}
@Test
fun `should handle empty streams correctly`() {
val emptyStreamId = UUID.randomUUID()
val emptyStreamId = Uuid.random()
// Reading from an empty stream should return an empty list
val emptyEvents = eventStore.readFromStream(emptyStreamId)
@ -181,7 +181,7 @@ class RedisEventStoreStreamTest {
@Test
fun `should handle concurrent version conflicts properly using optimistic locking`() {
val aggregateId = UUID.randomUUID()
val aggregateId = Uuid.random()
// Add initial event
val initialEvent = OrderTestEvent(
@ -230,7 +230,7 @@ class RedisEventStoreStreamTest {
@Test
fun `should handle version gaps correctly in stream reading`() {
val aggregateId = UUID.randomUUID()
val aggregateId = Uuid.random()
// Create events with non-sequential versions (simulating gaps)
val event1 = StreamTestEvent(AggregateId(aggregateId), EventVersion(1L), "Event 1")
@ -254,7 +254,7 @@ class RedisEventStoreStreamTest {
@Test
fun `should handle large streams efficiently`() {
val aggregateId = UUID.randomUUID()
val aggregateId = Uuid.random()
val numberOfEvents = 1000
// Create and append a large number of events
@ -299,7 +299,7 @@ class RedisEventStoreStreamTest {
@Test
fun `subscribeToStream and subscribeToAll should return working subscriptions`() {
val aggregateId = UUID.randomUUID()
val aggregateId = Uuid.random()
var streamEventReceived = false
var allEventReceived = false
@ -329,14 +329,14 @@ class RedisEventStoreStreamTest {
// Test event classes
@Serializable
data class StreamTestEvent(
@Transient override val aggregateId: AggregateId = AggregateId(UUID.randomUUID()),
@Transient override val aggregateId: AggregateId = AggregateId(Uuid.random()),
@Transient override val version: EventVersion = EventVersion(0),
val data: String
) : BaseDomainEvent(aggregateId, EventType("StreamTestEvent"), version)
@Serializable
data class OrderTestEvent(
@Transient override val aggregateId: AggregateId = AggregateId(UUID.randomUUID()),
@Transient override val aggregateId: AggregateId = AggregateId(Uuid.random()),
@Transient override val version: EventVersion = EventVersion(0),
val threadId: Int,
val eventIndex: Int,

View File

@ -6,7 +6,6 @@ import at.mocode.core.domain.model.EventType
import at.mocode.core.domain.model.EventVersion
import at.mocode.infrastructure.eventstore.api.ConcurrencyException
import at.mocode.infrastructure.eventstore.api.EventSerializer
import java.util.UUID
import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient
import org.junit.jupiter.api.AfterEach
@ -21,6 +20,7 @@ import org.testcontainers.containers.GenericContainer
import org.testcontainers.junit.jupiter.Container
import org.testcontainers.junit.jupiter.Testcontainers
import org.testcontainers.utility.DockerImageName
import kotlin.uuid.Uuid
@Testcontainers
class RedisEventStoreTest {
@ -71,7 +71,7 @@ class RedisEventStoreTest {
@Test
fun `append and read events should work correctly for new stream`() {
val aggregateId = UUID.randomUUID()
val aggregateId = Uuid.random()
val event1 = TestCreatedEvent(AggregateId(aggregateId), EventVersion(1L), "Test Entity")
val event2 = TestUpdatedEvent(AggregateId(aggregateId), EventVersion(2L), "Updated Test Entity")
@ -91,7 +91,7 @@ class RedisEventStoreTest {
@Test
fun `appending with wrong expected version should throw ConcurrencyException`() {
val aggregateId = UUID.randomUUID()
val aggregateId = Uuid.random()
val event1 = TestCreatedEvent(AggregateId(aggregateId), EventVersion(1L), "Test Entity")
eventStore.appendToStream(listOf(event1), aggregateId, 0) // Stream is now at version 1
@ -103,14 +103,14 @@ class RedisEventStoreTest {
@Serializable
data class TestCreatedEvent(
@Transient override val aggregateId: AggregateId = AggregateId(UUID.randomUUID()),
@Transient override val aggregateId: AggregateId = AggregateId(Uuid.random()),
@Transient override val version: EventVersion = EventVersion(0),
val name: String
) : BaseDomainEvent(aggregateId, EventType("TestCreated"), version)
@Serializable
data class TestUpdatedEvent(
@Transient override val aggregateId: AggregateId = AggregateId(UUID.randomUUID()),
@Transient override val aggregateId: AggregateId = AggregateId(Uuid.random()),
@Transient override val version: EventVersion = EventVersion(0),
val name: String
) : BaseDomainEvent(aggregateId, EventType("TestUpdated"), version)

View File

@ -32,6 +32,8 @@ import org.springframework.web.bind.annotation.*
// Disable circuit breaker for JWT tests
"resilience4j.circuitbreaker.configs.default.registerHealthIndicator=false",
"management.health.circuitbreakers.enabled=false",
// Disable Redis health indicator for tests (no Redis in test environment)
"management.health.redis.enabled=false",
// Enable JWT authentication for testing
"gateway.security.jwt.enabled=true",
// Use reactive web application type
@ -260,23 +262,23 @@ class JwtAuthenticationTests {
return "Protected endpoint accessed - User ID: $userId, Role: $userRole"
}
@GetMapping("/health")
@GetMapping("/health", "/health/**")
fun healthEndpoint(): String = "Health OK"
@GetMapping("/ping")
@GetMapping("/ping", "/ping/**")
fun pingEndpoint(): String = "Ping OK"
@GetMapping("/auth")
@PostMapping("/auth")
@GetMapping("/auth", "/auth/**")
@PostMapping("/auth", "/auth/**")
fun authEndpoint(): String = "Auth endpoint"
@GetMapping("/fallback")
@GetMapping("/fallback", "/fallback/**")
fun fallbackEndpoint(): String = "Fallback OK"
@GetMapping("/docs")
@GetMapping("/docs", "/docs/**")
fun docsEndpoint(): String = "Documentation OK"
@GetMapping("/actuator")
@GetMapping("/actuator", "/actuator/**")
fun actuatorEndpoint(): String = "Actuator OK"
@GetMapping("/root")