refactoring infrastructure

This commit is contained in:
2025-10-14 12:47:16 +02:00
parent 689458e9b1
commit e8f33e465c
2 changed files with 8 additions and 5 deletions
@@ -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<String, ByteArray> {
fun redisTemplate(
@Qualifier("redisConnectionFactory") connectionFactory: RedisConnectionFactory
): RedisTemplate<String, ByteArray> {
return RedisTemplate<String, ByteArray>().apply {
setConnectionFactory(connectionFactory)
keySerializer = StringRedisSerializer()
@@ -96,7 +96,7 @@ class RedisCacheAndEventStoreIntegrationTest {
class TestConfig {
@Bean
fun distributedCache(
redisTemplate: RedisTemplate<String, ByteArray>,
@Qualifier("redisTemplate") redisTemplate: RedisTemplate<String, ByteArray>,
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<String, String>,
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