From b25cdcf9d836dcd2a284269c856f72a763370ca6 Mon Sep 17 00:00:00 2001 From: beekeeper24 Date: Fri, 10 Oct 2025 17:44:03 +0900 Subject: [PATCH 1/2] fix(be):edit id type --- .../domain/userChat/chatmessage/entity/ChatMessage.kt | 2 +- .../domain/userChat/chatroom/entity/ChatRoom.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/back/koreaTravelGuide/domain/userChat/chatmessage/entity/ChatMessage.kt b/src/main/kotlin/com/back/koreaTravelGuide/domain/userChat/chatmessage/entity/ChatMessage.kt index cfad985..61dce64 100644 --- a/src/main/kotlin/com/back/koreaTravelGuide/domain/userChat/chatmessage/entity/ChatMessage.kt +++ b/src/main/kotlin/com/back/koreaTravelGuide/domain/userChat/chatmessage/entity/ChatMessage.kt @@ -17,7 +17,7 @@ import java.time.ZonedDateTime ) data class ChatMessage( @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - val id: Long? = null, + var id: Long? = null, @Column(name = "room_id", nullable = false) val roomId: Long, @Column(name = "sender_id", nullable = false) diff --git a/src/main/kotlin/com/back/koreaTravelGuide/domain/userChat/chatroom/entity/ChatRoom.kt b/src/main/kotlin/com/back/koreaTravelGuide/domain/userChat/chatroom/entity/ChatRoom.kt index 93e5009..b71f526 100644 --- a/src/main/kotlin/com/back/koreaTravelGuide/domain/userChat/chatroom/entity/ChatRoom.kt +++ b/src/main/kotlin/com/back/koreaTravelGuide/domain/userChat/chatroom/entity/ChatRoom.kt @@ -17,7 +17,7 @@ import java.time.ZonedDateTime ) data class ChatRoom( @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - val id: Long? = null, + var id: Long? = null, @Column(nullable = false) val title: String, @Column(name = "guide_id", nullable = false) From 8d804d032da1635143c189beaa789e01467bf3de Mon Sep 17 00:00:00 2001 From: beekeeper24 Date: Sat, 11 Oct 2025 11:43:53 +0900 Subject: [PATCH 2/2] fix(be): mock redis and object mapper for controller tests --- .../koreaTravelGuide/config/TestConfig.kt | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/test/kotlin/com/back/koreaTravelGuide/config/TestConfig.kt b/src/test/kotlin/com/back/koreaTravelGuide/config/TestConfig.kt index ac16daa..e34dd4d 100644 --- a/src/test/kotlin/com/back/koreaTravelGuide/config/TestConfig.kt +++ b/src/test/kotlin/com/back/koreaTravelGuide/config/TestConfig.kt @@ -1,14 +1,51 @@ package com.back.koreaTravelGuide.config +import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule +import com.fasterxml.jackson.module.kotlin.KotlinModule import org.mockito.Mockito +import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer import org.springframework.boot.test.context.TestConfiguration import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Primary import org.springframework.data.redis.connection.RedisConnectionFactory +import org.springframework.data.redis.core.RedisTemplate +import org.springframework.data.redis.core.ValueOperations @TestConfiguration class TestConfig { @Bean @Primary - fun redisConnectionFactory(): RedisConnectionFactory = Mockito.mock(RedisConnectionFactory::class.java) + fun testRedisConnectionFactory(): RedisConnectionFactory = Mockito.mock(RedisConnectionFactory::class.java) + + @Bean + @Primary + fun testRedisTemplate(): RedisTemplate { + @Suppress("UNCHECKED_CAST") + val template = Mockito.mock(RedisTemplate::class.java) as RedisTemplate + + @Suppress("UNCHECKED_CAST") + val valueOps = Mockito.mock(ValueOperations::class.java) as ValueOperations + + Mockito.`when`(template.opsForValue()).thenReturn(valueOps) + Mockito.`when`(valueOps.get(Mockito.anyString())).thenReturn(null) + + return template + } + + @Bean + fun javaTimeModuleCustomizer(): Jackson2ObjectMapperBuilderCustomizer { + return Jackson2ObjectMapperBuilderCustomizer { builder -> + builder.modulesToInstall(JavaTimeModule()) + } + } + + @Bean + @Primary + fun testObjectMapper(): ObjectMapper { + return ObjectMapper().apply { + registerModule(JavaTimeModule()) + registerModule(KotlinModule.Builder().build()) + } + } }