mirror of https://github.com/usbharu/Hideout.git
test: テストを修正
This commit is contained in:
parent
09442d2bdf
commit
778d8a4968
|
@ -36,7 +36,7 @@ interface APNoteService {
|
|||
}
|
||||
|
||||
@Service
|
||||
class APNoteServiceImpl private constructor(
|
||||
class APNoteServiceImpl(
|
||||
private val httpClient: HttpClient,
|
||||
private val jobQueueParentService: JobQueueParentService,
|
||||
private val postRepository: PostRepository,
|
||||
|
|
|
@ -12,6 +12,8 @@ import org.junit.jupiter.api.Test
|
|||
import org.mockito.kotlin.any
|
||||
import org.mockito.kotlin.doAnswer
|
||||
import org.mockito.kotlin.mock
|
||||
import utils.JsonObjectMapper.objectMapper
|
||||
import utils.TestApplicationConfig.testApplicationConfig
|
||||
import utils.TestTransaction
|
||||
import java.security.KeyPairGenerator
|
||||
import java.time.Instant
|
||||
|
@ -41,7 +43,7 @@ class ActivityPubKtTest {
|
|||
}
|
||||
}
|
||||
runBlocking {
|
||||
val ktorKeyMap = KtorKeyMap(userQueryService, TestTransaction)
|
||||
val ktorKeyMap = KtorKeyMap(userQueryService, TestTransaction, testApplicationConfig)
|
||||
|
||||
val httpClient = HttpClient(
|
||||
MockEngine { httpRequestData ->
|
||||
|
@ -57,7 +59,7 @@ class ActivityPubKtTest {
|
|||
}
|
||||
}
|
||||
|
||||
httpClient.postAp("https://localhost", "test", JsonLd(emptyList()))
|
||||
httpClient.postAp("https://localhost", "test", JsonLd(emptyList()), objectMapper)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test
|
|||
import org.mockito.kotlin.any
|
||||
import org.mockito.kotlin.doAnswer
|
||||
import org.mockito.kotlin.mock
|
||||
import utils.TestApplicationConfig.testApplicationConfig
|
||||
import utils.TestTransaction
|
||||
import java.security.KeyPairGenerator
|
||||
import java.time.Instant
|
||||
|
@ -36,7 +37,7 @@ class KtorKeyMapTest {
|
|||
)
|
||||
}
|
||||
}
|
||||
val ktorKeyMap = KtorKeyMap(userQueryService, TestTransaction)
|
||||
val ktorKeyMap = KtorKeyMap(userQueryService, TestTransaction, testApplicationConfig)
|
||||
|
||||
ktorKeyMap.getPrivateKey("test")
|
||||
}
|
||||
|
|
|
@ -22,13 +22,15 @@ import org.junit.jupiter.api.Test
|
|||
import org.mockito.Mockito.eq
|
||||
import org.mockito.kotlin.*
|
||||
import utils.JsonObjectMapper
|
||||
import utils.JsonObjectMapper.objectMapper
|
||||
import utils.TestApplicationConfig.testApplicationConfig
|
||||
import java.time.Instant
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class APNoteServiceImplTest {
|
||||
@Test
|
||||
fun `createPost 新しい投稿`() = runTest {
|
||||
val followers = listOf<User>(
|
||||
val followers = listOf(
|
||||
User.of(
|
||||
2L,
|
||||
"follower",
|
||||
|
@ -84,7 +86,9 @@ class APNoteServiceImplTest {
|
|||
mock(),
|
||||
userQueryService,
|
||||
followerQueryService,
|
||||
mock()
|
||||
mock(),
|
||||
objectMapper = objectMapper,
|
||||
applicationConfig = testApplicationConfig
|
||||
)
|
||||
val postEntity = Post.of(
|
||||
1L,
|
||||
|
@ -109,13 +113,15 @@ class APNoteServiceImplTest {
|
|||
}
|
||||
)
|
||||
val activityPubNoteService = APNoteServiceImpl(
|
||||
httpClient,
|
||||
mock(),
|
||||
mock(),
|
||||
mock(),
|
||||
mock(),
|
||||
mock(),
|
||||
mock()
|
||||
httpClient = httpClient,
|
||||
jobQueueParentService = mock(),
|
||||
postRepository = mock(),
|
||||
apUserService = mock(),
|
||||
userQueryService = mock(),
|
||||
followerQueryService = mock(),
|
||||
postQueryService = mock(),
|
||||
objectMapper = objectMapper,
|
||||
applicationConfig = testApplicationConfig
|
||||
)
|
||||
activityPubNoteService.createNoteJob(
|
||||
JobProps(
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.junit.jupiter.api.Test
|
|||
import org.mockito.ArgumentMatchers.anyString
|
||||
import org.mockito.kotlin.*
|
||||
import utils.JsonObjectMapper
|
||||
import utils.JsonObjectMapper.objectMapper
|
||||
import utils.TestTransaction
|
||||
import java.time.Instant
|
||||
|
||||
|
@ -34,7 +35,10 @@ class APReceiveFollowServiceImplTest {
|
|||
onBlocking { schedule(eq(ReceiveFollowJob), any()) } doReturn Unit
|
||||
}
|
||||
val activityPubFollowService =
|
||||
APReceiveFollowServiceImpl(jobQueueParentService, mock(), mock(), mock(), mock(), TestTransaction)
|
||||
APReceiveFollowServiceImpl(
|
||||
jobQueueParentService, mock(), mock(), mock(), mock(), TestTransaction,
|
||||
objectMapper
|
||||
)
|
||||
activityPubFollowService.receiveFollow(
|
||||
Follow(
|
||||
emptyList(),
|
||||
|
@ -163,7 +167,8 @@ class APReceiveFollowServiceImplTest {
|
|||
}
|
||||
),
|
||||
userQueryService,
|
||||
TestTransaction
|
||||
TestTransaction,
|
||||
objectMapper
|
||||
)
|
||||
activityPubFollowService.receiveFollowJob(
|
||||
JobProps(
|
||||
|
|
|
@ -12,6 +12,7 @@ import kotlinx.coroutines.test.runTest
|
|||
import org.junit.jupiter.api.Test
|
||||
import org.mockito.ArgumentMatchers.anyString
|
||||
import org.mockito.kotlin.*
|
||||
import utils.TestApplicationConfig.testApplicationConfig
|
||||
import java.security.KeyPairGenerator
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNull
|
||||
|
@ -28,7 +29,8 @@ class UserServiceTest {
|
|||
onBlocking { hash(anyString()) } doReturn "hashedPassword"
|
||||
onBlocking { generateKeyPair() } doReturn generateKeyPair
|
||||
}
|
||||
val userService = UserServiceImpl(userRepository, userAuthService, mock(), mock(), mock())
|
||||
val userService =
|
||||
UserServiceImpl(userRepository, userAuthService, mock(), mock(), mock(), testApplicationConfig)
|
||||
userService.createLocalUser(UserCreateDto("test", "testUser", "XXXXXXXXXXXXX", "test"))
|
||||
verify(userRepository, times(1)).save(any())
|
||||
argumentCaptor<dev.usbharu.hideout.domain.model.hideout.entity.User> {
|
||||
|
@ -54,7 +56,7 @@ class UserServiceTest {
|
|||
val userRepository = mock<UserRepository> {
|
||||
onBlocking { nextId() } doReturn 113345L
|
||||
}
|
||||
val userService = UserServiceImpl(userRepository, mock(), mock(), mock(), mock())
|
||||
val userService = UserServiceImpl(userRepository, mock(), mock(), mock(), mock(), testApplicationConfig)
|
||||
val user = RemoteUserCreateDto(
|
||||
"test",
|
||||
"example.com",
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package utils
|
||||
|
||||
import dev.usbharu.hideout.config.ApplicationConfig
|
||||
import java.net.URL
|
||||
|
||||
object TestApplicationConfig {
|
||||
val testApplicationConfig = ApplicationConfig(URL("https://example.com"))
|
||||
}
|
Loading…
Reference in New Issue