Unit test rest controller in kotlin + Spring boot
I'm testing post API and mocking a method like below:
@Test
fun testMaintenanceMode() {
val mockController = Mockito.mock(Controller::class.java)
Mockito.`when`(mockController.isMaintenanceFileExist("maintenanceFilePath"))
.thenReturn(true)
// Request body
val body = "authId=123&email=a@mail.com&confirmationKey=86b498cb7a94a3555bc6ee1041a1c90a"
// When maintenance mode is on
mvc.perform(
MockMvcRequestBuilders.post("/post")...