mirror of https://github.com/usbharu/Hideout.git
test: テストを修正
This commit is contained in:
parent
31240b8797
commit
72d937a104
|
@ -96,6 +96,9 @@ class EqualsAndToStringTest {
|
||||||
.filter {
|
.filter {
|
||||||
it.superclass == Any::class.java || it.superclass?.packageName?.startsWith("dev.usbharu") ?: true
|
it.superclass == Any::class.java || it.superclass?.packageName?.startsWith("dev.usbharu") ?: true
|
||||||
}
|
}
|
||||||
|
.filterNot {
|
||||||
|
it.superclass.isSealed
|
||||||
|
}
|
||||||
.filterNot { it == UnicodeEmoji::class.java }
|
.filterNot { it == UnicodeEmoji::class.java }
|
||||||
.map {
|
.map {
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,10 @@ package dev.usbharu.hideout.core.service.reaction
|
||||||
import dev.usbharu.hideout.activitypub.service.activity.like.APReactionService
|
import dev.usbharu.hideout.activitypub.service.activity.like.APReactionService
|
||||||
import dev.usbharu.hideout.application.service.id.TwitterSnowflakeIdGenerateService
|
import dev.usbharu.hideout.application.service.id.TwitterSnowflakeIdGenerateService
|
||||||
import dev.usbharu.hideout.core.domain.model.emoji.UnicodeEmoji
|
import dev.usbharu.hideout.core.domain.model.emoji.UnicodeEmoji
|
||||||
|
import dev.usbharu.hideout.core.domain.model.post.PostRepository
|
||||||
import dev.usbharu.hideout.core.domain.model.reaction.Reaction
|
import dev.usbharu.hideout.core.domain.model.reaction.Reaction
|
||||||
import dev.usbharu.hideout.core.domain.model.reaction.ReactionRepository
|
import dev.usbharu.hideout.core.domain.model.reaction.ReactionRepository
|
||||||
|
import dev.usbharu.hideout.core.service.notification.NotificationService
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.junit.jupiter.api.extension.ExtendWith
|
import org.junit.jupiter.api.extension.ExtendWith
|
||||||
|
@ -18,6 +20,12 @@ import utils.PostBuilder
|
||||||
@ExtendWith(MockitoExtension::class)
|
@ExtendWith(MockitoExtension::class)
|
||||||
class ReactionServiceImplTest {
|
class ReactionServiceImplTest {
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private lateinit var notificationService: NotificationService
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private lateinit var postRepository: PostRepository
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var reactionRepository: ReactionRepository
|
private lateinit var reactionRepository: ReactionRepository
|
||||||
|
|
||||||
|
@ -35,6 +43,9 @@ class ReactionServiceImplTest {
|
||||||
whenever(reactionRepository.existByPostIdAndActor(eq(post.id), eq(post.actorId))).doReturn(
|
whenever(reactionRepository.existByPostIdAndActor(eq(post.id), eq(post.actorId))).doReturn(
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
whenever(postRepository.findById(eq(post.id))).doReturn(post)
|
||||||
|
whenever(reactionRepository.save(any())).doAnswer { it.arguments[0] as Reaction }
|
||||||
|
|
||||||
val generateId = TwitterSnowflakeIdGenerateService.generateId()
|
val generateId = TwitterSnowflakeIdGenerateService.generateId()
|
||||||
whenever(reactionRepository.generateId()).doReturn(generateId)
|
whenever(reactionRepository.generateId()).doReturn(generateId)
|
||||||
|
|
||||||
|
@ -50,7 +61,8 @@ class ReactionServiceImplTest {
|
||||||
whenever(reactionRepository.existByPostIdAndActor(eq(post.id), eq(post.actorId))).doReturn(
|
whenever(reactionRepository.existByPostIdAndActor(eq(post.id), eq(post.actorId))).doReturn(
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
whenever(postRepository.findById(eq(post.id))).doReturn(post)
|
||||||
|
whenever(reactionRepository.save(any())).doAnswer { it.arguments[0] as Reaction }
|
||||||
val generateId = TwitterSnowflakeIdGenerateService.generateId()
|
val generateId = TwitterSnowflakeIdGenerateService.generateId()
|
||||||
|
|
||||||
whenever(reactionRepository.generateId()).doReturn(generateId)
|
whenever(reactionRepository.generateId()).doReturn(generateId)
|
||||||
|
@ -67,6 +79,8 @@ class ReactionServiceImplTest {
|
||||||
whenever(reactionRepository.findByPostIdAndActorIdAndEmojiId(eq(post.id), eq(post.actorId), eq(0))).doReturn(
|
whenever(reactionRepository.findByPostIdAndActorIdAndEmojiId(eq(post.id), eq(post.actorId), eq(0))).doReturn(
|
||||||
null
|
null
|
||||||
)
|
)
|
||||||
|
whenever(postRepository.findById(eq(post.id))).doReturn(post)
|
||||||
|
whenever(reactionRepository.save(any())).doAnswer { it.arguments[0] as Reaction }
|
||||||
val generateId = TwitterSnowflakeIdGenerateService.generateId()
|
val generateId = TwitterSnowflakeIdGenerateService.generateId()
|
||||||
whenever(reactionRepository.generateId()).doReturn(generateId)
|
whenever(reactionRepository.generateId()).doReturn(generateId)
|
||||||
|
|
||||||
|
@ -83,6 +97,8 @@ class ReactionServiceImplTest {
|
||||||
whenever(reactionRepository.findByPostIdAndActorIdAndEmojiId(eq(post.id), eq(post.actorId), eq(0))).doReturn(
|
whenever(reactionRepository.findByPostIdAndActorIdAndEmojiId(eq(post.id), eq(post.actorId), eq(0))).doReturn(
|
||||||
Reaction(id, UnicodeEmoji("❤"), post.id, post.actorId)
|
Reaction(id, UnicodeEmoji("❤"), post.id, post.actorId)
|
||||||
)
|
)
|
||||||
|
whenever(postRepository.findById(eq(post.id))).doReturn(post)
|
||||||
|
whenever(reactionRepository.save(any())).doAnswer { it.arguments[0] as Reaction }
|
||||||
val generateId = TwitterSnowflakeIdGenerateService.generateId()
|
val generateId = TwitterSnowflakeIdGenerateService.generateId()
|
||||||
whenever(reactionRepository.generateId()).doReturn(generateId)
|
whenever(reactionRepository.generateId()).doReturn(generateId)
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.domain.model.relationship.Relationship
|
import dev.usbharu.hideout.core.domain.model.relationship.Relationship
|
||||||
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
|
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
|
||||||
import dev.usbharu.hideout.core.service.follow.SendFollowDto
|
import dev.usbharu.hideout.core.service.follow.SendFollowDto
|
||||||
|
import dev.usbharu.hideout.core.service.notification.NotificationService
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.junit.jupiter.api.assertThrows
|
import org.junit.jupiter.api.assertThrows
|
||||||
|
@ -25,6 +26,10 @@ import java.net.URL
|
||||||
@ExtendWith(MockitoExtension::class)
|
@ExtendWith(MockitoExtension::class)
|
||||||
class RelationshipServiceImplTest {
|
class RelationshipServiceImplTest {
|
||||||
|
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private lateinit var notificationService: NotificationService
|
||||||
|
|
||||||
@Spy
|
@Spy
|
||||||
private val applicationConfig = ApplicationConfig(URL("https://example.com"))
|
private val applicationConfig = ApplicationConfig(URL("https://example.com"))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue