test: テストコードをログインユーザー取得に対応

This commit is contained in:
usbharu 2024-01-26 12:17:09 +09:00
parent 54b89c290a
commit 63632f7676
3 changed files with 14 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package dev.usbharu.hideout.mastodon.interfaces.api.account
import dev.usbharu.hideout.application.config.ActivityPubConfig
import dev.usbharu.hideout.core.infrastructure.springframework.security.OAuth2JwtLoginUserContextHolder
import dev.usbharu.hideout.domain.mastodon.model.generated.AccountSource
import dev.usbharu.hideout.domain.mastodon.model.generated.CredentialAccount
import dev.usbharu.hideout.domain.mastodon.model.generated.Role
@ -31,6 +32,9 @@ class MastodonAccountApiControllerTest {
private lateinit var mockMvc: MockMvc
@Spy
private val loginUserContextHolder = OAuth2JwtLoginUserContextHolder()
@Spy
private lateinit var testTransaction: TestTransaction

View File

@ -1,6 +1,7 @@
package dev.usbharu.hideout.mastodon.interfaces.api.status
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import dev.usbharu.hideout.core.infrastructure.springframework.security.OAuth2JwtLoginUserContextHolder
import dev.usbharu.hideout.domain.mastodon.model.generated.Account
import dev.usbharu.hideout.domain.mastodon.model.generated.Status
import dev.usbharu.hideout.generate.JsonOrFormModelMethodProcessor
@ -11,6 +12,7 @@ import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import org.mockito.InjectMocks
import org.mockito.Mock
import org.mockito.Spy
import org.mockito.junit.jupiter.MockitoExtension
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.eq
@ -30,6 +32,9 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestResponseBody
@ExtendWith(MockitoExtension::class)
class MastodonStatusesApiControllerTest {
@Spy
private val loginUserContextHolder = OAuth2JwtLoginUserContextHolder()
@Mock
private lateinit var statusesApiService: StatusesApiService

View File

@ -1,6 +1,7 @@
package dev.usbharu.hideout.mastodon.interfaces.api.timeline
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import dev.usbharu.hideout.core.infrastructure.springframework.security.OAuth2JwtLoginUserContextHolder
import dev.usbharu.hideout.domain.mastodon.model.generated.Account
import dev.usbharu.hideout.domain.mastodon.model.generated.Status
import dev.usbharu.hideout.mastodon.service.timeline.TimelineApiService
@ -10,6 +11,7 @@ import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import org.mockito.InjectMocks
import org.mockito.Mock
import org.mockito.Spy
import org.mockito.junit.jupiter.MockitoExtension
import org.mockito.kotlin.*
import org.springframework.security.core.context.SecurityContextHolder
@ -23,6 +25,9 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders
@ExtendWith(MockitoExtension::class)
class MastodonTimelineApiControllerTest {
@Spy
private val loginUserContextHolder = OAuth2JwtLoginUserContextHolder()
@Mock
private lateinit var timelineApiService: TimelineApiService