mirror of https://github.com/usbharu/Hideout.git
style: fix lint
This commit is contained in:
parent
a389036827
commit
4b59802c8d
|
@ -112,18 +112,17 @@ class InboxCommonTest {
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun beforeAll(@Autowired flyway: Flyway) {
|
fun beforeAll() {
|
||||||
server = MockServer.feature("classpath:federation/InboxxCommonMockServerTest.feature").http(0).build()
|
server = MockServer.feature("classpath:federation/InboxxCommonMockServerTest.feature").http(0).build()
|
||||||
_remotePort = server.port.toString()
|
_remotePort = server.port.toString()
|
||||||
|
|
||||||
flyway.clean()
|
|
||||||
flyway.migrate()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterAll
|
@AfterAll
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun afterAll() {
|
fun afterAll(@Autowired flyway: Flyway) {
|
||||||
server.stop()
|
server.stop()
|
||||||
|
flyway.clean()
|
||||||
|
flyway.migrate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,7 +210,6 @@ data class Actor private constructor(
|
||||||
fun decrementPostsCount(): Actor = this.copy(postsCount = this.postsCount - 1)
|
fun decrementPostsCount(): Actor = this.copy(postsCount = this.postsCount - 1)
|
||||||
|
|
||||||
fun withLastPostAt(lastPostDate: Instant): Actor = this.copy(lastPostDate = lastPostDate)
|
fun withLastPostAt(lastPostDate: Instant): Actor = this.copy(lastPostDate = lastPostDate)
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return "Actor(" +
|
return "Actor(" +
|
||||||
"id=$id, " +
|
"id=$id, " +
|
||||||
|
@ -232,7 +231,8 @@ data class Actor private constructor(
|
||||||
"followersCount=$followersCount, " +
|
"followersCount=$followersCount, " +
|
||||||
"followingCount=$followingCount, " +
|
"followingCount=$followingCount, " +
|
||||||
"postsCount=$postsCount, " +
|
"postsCount=$postsCount, " +
|
||||||
"lastPostDate=$lastPostDate" +
|
"lastPostDate=$lastPostDate, " +
|
||||||
|
"emojis=$emojis" +
|
||||||
")"
|
")"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,12 @@ sealed class Emoji {
|
||||||
abstract val domain: String
|
abstract val domain: String
|
||||||
abstract val name: String
|
abstract val name: String
|
||||||
abstract fun id(): String
|
abstract fun id(): String
|
||||||
|
override fun toString(): String {
|
||||||
|
return "Emoji(" +
|
||||||
|
"domain='$domain', " +
|
||||||
|
"name='$name'" +
|
||||||
|
")"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class CustomEmoji(
|
data class CustomEmoji(
|
||||||
|
|
|
@ -18,7 +18,8 @@ class PostQueryMapper(private val postResultRowMapper: ResultRowMapper<Post>) :
|
||||||
it.first().let(postResultRowMapper::map)
|
it.first().let(postResultRowMapper::map)
|
||||||
.copy(
|
.copy(
|
||||||
mediaIds = it.mapNotNull { resultRow -> resultRow.getOrNull(PostsMedia.mediaId) },
|
mediaIds = it.mapNotNull { resultRow -> resultRow.getOrNull(PostsMedia.mediaId) },
|
||||||
emojiIds = it.mapNotNull { resultRow -> resultRow.getOrNull(PostsEmojis.emojiId) })
|
emojiIds = it.mapNotNull { resultRow -> resultRow.getOrNull(PostsEmojis.emojiId) }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package dev.usbharu.hideout
|
||||||
import com.fasterxml.jackson.module.kotlin.isKotlinClass
|
import com.fasterxml.jackson.module.kotlin.isKotlinClass
|
||||||
import com.jparams.verifier.tostring.ToStringVerifier
|
import com.jparams.verifier.tostring.ToStringVerifier
|
||||||
import com.jparams.verifier.tostring.preset.Presets
|
import com.jparams.verifier.tostring.preset.Presets
|
||||||
|
import dev.usbharu.hideout.core.domain.model.emoji.UnicodeEmoji
|
||||||
import nl.jqno.equalsverifier.EqualsVerifier
|
import nl.jqno.equalsverifier.EqualsVerifier
|
||||||
import nl.jqno.equalsverifier.Warning
|
import nl.jqno.equalsverifier.Warning
|
||||||
import nl.jqno.equalsverifier.internal.reflection.PackageScanner
|
import nl.jqno.equalsverifier.internal.reflection.PackageScanner
|
||||||
|
@ -95,6 +96,7 @@ 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 == UnicodeEmoji::class.java }
|
||||||
.map {
|
.map {
|
||||||
|
|
||||||
dynamicTest(it.name) {
|
dynamicTest(it.name) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package dev.usbharu.hideout.activitypub.service.activity.like
|
||||||
|
|
||||||
import dev.usbharu.hideout.application.service.id.TwitterSnowflakeIdGenerateService
|
import dev.usbharu.hideout.application.service.id.TwitterSnowflakeIdGenerateService
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
|
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.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.external.job.DeliverReactionJob
|
import dev.usbharu.hideout.core.external.job.DeliverReactionJob
|
||||||
|
@ -48,7 +49,7 @@ class APReactionServiceImplTest {
|
||||||
apReactionServiceImpl.reaction(
|
apReactionServiceImpl.reaction(
|
||||||
Reaction(
|
Reaction(
|
||||||
id = TwitterSnowflakeIdGenerateService.generateId(),
|
id = TwitterSnowflakeIdGenerateService.generateId(),
|
||||||
emojiId = 0,
|
emoji = UnicodeEmoji("❤"),
|
||||||
postId = post.id,
|
postId = post.id,
|
||||||
actorId = user.id
|
actorId = user.id
|
||||||
)
|
)
|
||||||
|
@ -88,7 +89,7 @@ class APReactionServiceImplTest {
|
||||||
apReactionServiceImpl.removeReaction(
|
apReactionServiceImpl.removeReaction(
|
||||||
Reaction(
|
Reaction(
|
||||||
id = TwitterSnowflakeIdGenerateService.generateId(),
|
id = TwitterSnowflakeIdGenerateService.generateId(),
|
||||||
emojiId = 0,
|
emoji = UnicodeEmoji("❤"),
|
||||||
postId = post.id,
|
postId = post.id,
|
||||||
actorId = user.id
|
actorId = user.id
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,6 +3,7 @@ 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.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 kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
|
@ -40,7 +41,7 @@ class ReactionServiceImplTest {
|
||||||
|
|
||||||
reactionServiceImpl.receiveReaction("❤", "example.com", post.actorId, post.id)
|
reactionServiceImpl.receiveReaction("❤", "example.com", post.actorId, post.id)
|
||||||
|
|
||||||
verify(reactionRepository, times(1)).save(eq(Reaction(generateId, 0, post.id, post.actorId)))
|
verify(reactionRepository, times(1)).save(eq(Reaction(generateId, UnicodeEmoji("❤"), post.id, post.actorId)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -56,7 +57,7 @@ class ReactionServiceImplTest {
|
||||||
eq(
|
eq(
|
||||||
Reaction(
|
Reaction(
|
||||||
id = generateId,
|
id = generateId,
|
||||||
emojiId = 0,
|
emoji = UnicodeEmoji("❤"),
|
||||||
postId = post.id,
|
postId = post.id,
|
||||||
actorId = post.actorId
|
actorId = post.actorId
|
||||||
)
|
)
|
||||||
|
@ -72,7 +73,7 @@ class ReactionServiceImplTest {
|
||||||
|
|
||||||
reactionServiceImpl.receiveReaction("❤", "example.com", post.actorId, post.id)
|
reactionServiceImpl.receiveReaction("❤", "example.com", post.actorId, post.id)
|
||||||
|
|
||||||
verify(reactionRepository, times(1)).save(eq(Reaction(generateId, 0, post.id, post.actorId)))
|
verify(reactionRepository, times(1)).save(eq(Reaction(generateId, UnicodeEmoji("❤"), post.id, post.actorId)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -98,8 +99,8 @@ class ReactionServiceImplTest {
|
||||||
|
|
||||||
reactionServiceImpl.sendReaction("❤", post.actorId, post.id)
|
reactionServiceImpl.sendReaction("❤", post.actorId, post.id)
|
||||||
|
|
||||||
verify(reactionRepository, times(1)).save(eq(Reaction(generateId, 0, post.id, post.actorId)))
|
verify(reactionRepository, times(1)).save(eq(Reaction(generateId, UnicodeEmoji("❤"), post.id, post.actorId)))
|
||||||
verify(apReactionService, times(1)).reaction(eq(Reaction(generateId, 0, post.id, post.actorId)))
|
verify(apReactionService, times(1)).reaction(eq(Reaction(generateId, UnicodeEmoji("❤"), post.id, post.actorId)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -107,7 +108,7 @@ class ReactionServiceImplTest {
|
||||||
val post = PostBuilder.of()
|
val post = PostBuilder.of()
|
||||||
val id = TwitterSnowflakeIdGenerateService.generateId()
|
val id = TwitterSnowflakeIdGenerateService.generateId()
|
||||||
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, 0, post.id, post.actorId)
|
Reaction(id, UnicodeEmoji("❤"), post.id, post.actorId)
|
||||||
)
|
)
|
||||||
val generateId = TwitterSnowflakeIdGenerateService.generateId()
|
val generateId = TwitterSnowflakeIdGenerateService.generateId()
|
||||||
whenever(reactionRepository.generateId()).doReturn(generateId)
|
whenever(reactionRepository.generateId()).doReturn(generateId)
|
||||||
|
@ -115,22 +116,22 @@ class ReactionServiceImplTest {
|
||||||
reactionServiceImpl.sendReaction("❤", post.actorId, post.id)
|
reactionServiceImpl.sendReaction("❤", post.actorId, post.id)
|
||||||
|
|
||||||
|
|
||||||
verify(reactionRepository, times(1)).delete(eq(Reaction(id, 0, post.id, post.actorId)))
|
verify(reactionRepository, times(1)).delete(eq(Reaction(id, UnicodeEmoji("❤"), post.id, post.actorId)))
|
||||||
verify(reactionRepository, times(1)).save(eq(Reaction(generateId, 0, post.id, post.actorId)))
|
verify(reactionRepository, times(1)).save(eq(Reaction(generateId, UnicodeEmoji("❤"), post.id, post.actorId)))
|
||||||
verify(apReactionService, times(1)).removeReaction(eq(Reaction(id, 0, post.id, post.actorId)))
|
verify(apReactionService, times(1)).removeReaction(eq(Reaction(id, UnicodeEmoji("❤"), post.id, post.actorId)))
|
||||||
verify(apReactionService, times(1)).reaction(eq(Reaction(generateId, 0, post.id, post.actorId)))
|
verify(apReactionService, times(1)).reaction(eq(Reaction(generateId, UnicodeEmoji("❤"), post.id, post.actorId)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `removeReaction リアクションが存在する場合削除して配送`() = runTest {
|
fun `removeReaction リアクションが存在する場合削除して配送`() = runTest {
|
||||||
val post = PostBuilder.of()
|
val post = PostBuilder.of()
|
||||||
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(0, 0, post.id, post.actorId)
|
Reaction(0, UnicodeEmoji("❤"), post.id, post.actorId)
|
||||||
)
|
)
|
||||||
|
|
||||||
reactionServiceImpl.removeReaction(post.actorId, post.id)
|
reactionServiceImpl.removeReaction(post.actorId, post.id)
|
||||||
|
|
||||||
verify(reactionRepository, times(1)).delete(eq(Reaction(0, 0, post.id, post.actorId)))
|
verify(reactionRepository, times(1)).delete(eq(Reaction(0, UnicodeEmoji("❤"), post.id, post.actorId)))
|
||||||
verify(apReactionService, times(1)).removeReaction(eq(Reaction(0, 0, post.id, post.actorId)))
|
verify(apReactionService, times(1)).removeReaction(eq(Reaction(0, UnicodeEmoji("❤"), post.id, post.actorId)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue