Skip to content
Merged
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 @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
39 changes: 38 additions & 1 deletion src/test/kotlin/com/back/koreaTravelGuide/config/TestConfig.kt
Original file line number Diff line number Diff line change
@@ -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<String, String> {
@Suppress("UNCHECKED_CAST")
val template = Mockito.mock(RedisTemplate::class.java) as RedisTemplate<String, String>

@Suppress("UNCHECKED_CAST")
val valueOps = Mockito.mock(ValueOperations::class.java) as ValueOperations<String, String>

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())
}
}
}