-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathBaseIntegrationController.kt
More file actions
57 lines (47 loc) · 1.83 KB
/
BaseIntegrationController.kt
File metadata and controls
57 lines (47 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.example.demo.kotest.common
import com.example.demo.common.aop.SendWebHookSignalRequestBodyAdvice
import com.example.demo.infrastructure.webhook.WebHookProvider
import com.example.demo.kotest.common.security.SecurityListenerFactory
import com.fasterxml.jackson.databind.ObjectMapper
import com.ninjasquad.springmockk.MockkBean
import io.kotest.core.spec.style.BehaviorSpec
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.HttpStatus
import org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers
import org.springframework.test.web.servlet.MockMvc
import org.springframework.test.web.servlet.result.MockMvcResultHandlers
import org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder
import org.springframework.test.web.servlet.setup.MockMvcBuilders
import org.springframework.web.context.WebApplicationContext
abstract class BaseIntegrationController : BehaviorSpec() {
@Autowired
protected lateinit var webApplicationContext: WebApplicationContext
@Autowired
protected lateinit var mockMvc: MockMvc
@Autowired
protected lateinit var objectMapper: ObjectMapper
@Suppress("unused")
@Autowired
protected lateinit var sendWebHookSignalRequestBodyAdvice: SendWebHookSignalRequestBodyAdvice
@MockkBean
protected lateinit var webHookProvider: WebHookProvider
/**
* ResponseAdvice Status
*/
protected val commonStatus: Int = HttpStatus.OK.value()
/**
* ResponseAdvice Message
*/
protected val commonMessage: String = HttpStatus.OK.name
fun initialize() {
listeners(SecurityListenerFactory())
beforeSpec {
mockMvc =
MockMvcBuilders
.webAppContextSetup(webApplicationContext)
.apply<DefaultMockMvcBuilder>(SecurityMockMvcConfigurers.springSecurity())
.alwaysDo<DefaultMockMvcBuilder>(MockMvcResultHandlers.print())
.build()
}
}
}