From e8f33e465cd190512393f829e8c08ec2453f0abd Mon Sep 17 00:00:00 2001 From: MoCoAt Date: Tue, 14 Oct 2025 12:47:16 +0200 Subject: [PATCH] refactoring infrastructure --- .../infrastructure/cache/redis/RedisConfiguration.kt | 5 ++++- .../redis/RedisCacheAndEventStoreIntegrationTest.kt | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/infrastructure/cache/redis-cache/src/main/kotlin/at/mocode/infrastructure/cache/redis/RedisConfiguration.kt b/infrastructure/cache/redis-cache/src/main/kotlin/at/mocode/infrastructure/cache/redis/RedisConfiguration.kt index 72eaec91..1aea196f 100644 --- a/infrastructure/cache/redis-cache/src/main/kotlin/at/mocode/infrastructure/cache/redis/RedisConfiguration.kt +++ b/infrastructure/cache/redis-cache/src/main/kotlin/at/mocode/infrastructure/cache/redis/RedisConfiguration.kt @@ -3,6 +3,7 @@ package at.mocode.infrastructure.cache.redis import at.mocode.infrastructure.cache.api.CacheConfiguration import at.mocode.infrastructure.cache.api.CacheSerializer import at.mocode.infrastructure.cache.api.DefaultCacheConfiguration +import org.springframework.beans.factory.annotation.Qualifier import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean import org.springframework.boot.context.properties.ConfigurationProperties import org.springframework.boot.context.properties.EnableConfigurationProperties @@ -66,7 +67,9 @@ class RedisConfiguration { * @return Redis template */ @Bean - fun redisTemplate(connectionFactory: RedisConnectionFactory): RedisTemplate { + fun redisTemplate( + @Qualifier("redisConnectionFactory") connectionFactory: RedisConnectionFactory + ): RedisTemplate { return RedisTemplate().apply { setConnectionFactory(connectionFactory) keySerializer = StringRedisSerializer() diff --git a/infrastructure/event-store/redis-event-store/src/test/kotlin/at/mocode/infrastructure/eventstore/redis/RedisCacheAndEventStoreIntegrationTest.kt b/infrastructure/event-store/redis-event-store/src/test/kotlin/at/mocode/infrastructure/eventstore/redis/RedisCacheAndEventStoreIntegrationTest.kt index 6c89fbf8..39049f15 100644 --- a/infrastructure/event-store/redis-event-store/src/test/kotlin/at/mocode/infrastructure/eventstore/redis/RedisCacheAndEventStoreIntegrationTest.kt +++ b/infrastructure/event-store/redis-event-store/src/test/kotlin/at/mocode/infrastructure/eventstore/redis/RedisCacheAndEventStoreIntegrationTest.kt @@ -96,7 +96,7 @@ class RedisCacheAndEventStoreIntegrationTest { class TestConfig { @Bean fun distributedCache( - redisTemplate: RedisTemplate, + @Qualifier("redisTemplate") redisTemplate: RedisTemplate, cacheConfiguration: CacheConfiguration ): DistributedCache { return RedisDistributedCache( @@ -148,7 +148,7 @@ class RedisCacheAndEventStoreIntegrationTest { ) println("[DEBUG_LOG] EventStore: Appending event for aggregateId=$aggregateId") - eventStore.appendToStream(event, aggregateId, -1L) + eventStore.appendToStream(event, aggregateId, 0L) val loadedEvents = eventStore.readFromStream(aggregateId) println("[DEBUG_LOG] EventStore: Loaded ${loadedEvents.size} events") @@ -216,7 +216,7 @@ class RedisCacheAndEventStoreIntegrationTest { eventType = EventType("TestEvent"), data = mapOf("key" to sharedKey) ) - eventStore.appendToStream(event, aggregateId, -1L) + eventStore.appendToStream(event, aggregateId, 0L) println("[DEBUG_LOG] Stored event in event store with aggregateId=$aggregateId") // Both should be retrievable independently @@ -244,7 +244,7 @@ class RedisCacheAndEventStoreIntegrationTest { val data: Map, override val eventId: EventId = EventId(Uuid.random()), override val timestamp: kotlin.time.Instant = kotlin.time.Clock.System.now(), - override val version: EventVersion = EventVersion(0), + override val version: EventVersion = EventVersion(1), override val correlationId: CorrelationId? = null, override val causationId: CausationId? = null ) : DomainEvent