diff --git a/src/test/kotlin/dev/usbharu/hideout/EqualsAndToStringTest.kt b/src/test/kotlin/dev/usbharu/hideout/EqualsAndToStringTest.kt index 7d2454c1..1a339cc3 100644 --- a/src/test/kotlin/dev/usbharu/hideout/EqualsAndToStringTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/EqualsAndToStringTest.kt @@ -96,6 +96,9 @@ class EqualsAndToStringTest { .filter { it.superclass == Any::class.java || it.superclass?.packageName?.startsWith("dev.usbharu") ?: true } + .filterNot { + it.superclass.isSealed + } .filterNot { it == UnicodeEmoji::class.java } .map { diff --git a/src/test/kotlin/dev/usbharu/hideout/core/service/reaction/ReactionServiceImplTest.kt b/src/test/kotlin/dev/usbharu/hideout/core/service/reaction/ReactionServiceImplTest.kt index f3863d64..98558744 100644 --- a/src/test/kotlin/dev/usbharu/hideout/core/service/reaction/ReactionServiceImplTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/core/service/reaction/ReactionServiceImplTest.kt @@ -4,8 +4,10 @@ package dev.usbharu.hideout.core.service.reaction import dev.usbharu.hideout.activitypub.service.activity.like.APReactionService import dev.usbharu.hideout.application.service.id.TwitterSnowflakeIdGenerateService 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.ReactionRepository +import dev.usbharu.hideout.core.service.notification.NotificationService import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -18,6 +20,12 @@ import utils.PostBuilder @ExtendWith(MockitoExtension::class) class ReactionServiceImplTest { + @Mock + private lateinit var notificationService: NotificationService + + @Mock + private lateinit var postRepository: PostRepository + @Mock private lateinit var reactionRepository: ReactionRepository @@ -35,6 +43,9 @@ class ReactionServiceImplTest { whenever(reactionRepository.existByPostIdAndActor(eq(post.id), eq(post.actorId))).doReturn( false ) + whenever(postRepository.findById(eq(post.id))).doReturn(post) + whenever(reactionRepository.save(any())).doAnswer { it.arguments[0] as Reaction } + val generateId = TwitterSnowflakeIdGenerateService.generateId() whenever(reactionRepository.generateId()).doReturn(generateId) @@ -50,7 +61,8 @@ class ReactionServiceImplTest { whenever(reactionRepository.existByPostIdAndActor(eq(post.id), eq(post.actorId))).doReturn( true ) - + whenever(postRepository.findById(eq(post.id))).doReturn(post) + whenever(reactionRepository.save(any())).doAnswer { it.arguments[0] as Reaction } val generateId = TwitterSnowflakeIdGenerateService.generateId() whenever(reactionRepository.generateId()).doReturn(generateId) @@ -67,6 +79,8 @@ class ReactionServiceImplTest { whenever(reactionRepository.findByPostIdAndActorIdAndEmojiId(eq(post.id), eq(post.actorId), eq(0))).doReturn( null ) + whenever(postRepository.findById(eq(post.id))).doReturn(post) + whenever(reactionRepository.save(any())).doAnswer { it.arguments[0] as Reaction } val generateId = TwitterSnowflakeIdGenerateService.generateId() whenever(reactionRepository.generateId()).doReturn(generateId) @@ -83,6 +97,8 @@ class ReactionServiceImplTest { whenever(reactionRepository.findByPostIdAndActorIdAndEmojiId(eq(post.id), eq(post.actorId), eq(0))).doReturn( 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() whenever(reactionRepository.generateId()).doReturn(generateId) diff --git a/src/test/kotlin/dev/usbharu/hideout/core/service/relationship/RelationshipServiceImplTest.kt b/src/test/kotlin/dev/usbharu/hideout/core/service/relationship/RelationshipServiceImplTest.kt index 44e43a17..cd338e15 100644 --- a/src/test/kotlin/dev/usbharu/hideout/core/service/relationship/RelationshipServiceImplTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/core/service/relationship/RelationshipServiceImplTest.kt @@ -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.RelationshipRepository import dev.usbharu.hideout.core.service.follow.SendFollowDto +import dev.usbharu.hideout.core.service.notification.NotificationService import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows @@ -25,6 +26,10 @@ import java.net.URL @ExtendWith(MockitoExtension::class) class RelationshipServiceImplTest { + + @Mock + private lateinit var notificationService: NotificationService + @Spy private val applicationConfig = ApplicationConfig(URL("https://example.com"))