mirror of https://github.com/usbharu/Hideout.git
wip
This commit is contained in:
parent
d8d903437e
commit
6d233a1d39
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2024 usbharu
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package dev.usbharu.hideout.core.domain.model.followtimeline
|
||||
|
||||
import dev.usbharu.hideout.core.domain.model.timeline.TimelineId
|
||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
|
||||
|
||||
class FollowTimeline(val userDetailId: UserDetailId, val timelineId: TimelineId)
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2024 usbharu
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package dev.usbharu.hideout.core.domain.model.followtimeline
|
||||
|
||||
interface FollowTimelineRepository {
|
||||
suspend fun save(followTimeline: FollowTimeline): FollowTimeline
|
||||
suspend fun delete(followTimeline: FollowTimeline)
|
||||
}
|
|
@ -53,7 +53,7 @@ class Relationship(
|
|||
}
|
||||
|
||||
fun block() {
|
||||
require(following.not())
|
||||
unfollow()
|
||||
blocking = true
|
||||
addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.BLOCK))
|
||||
}
|
||||
|
|
|
@ -0,0 +1,140 @@
|
|||
package dev.usbharu.hideout.core.domain.model.relationship
|
||||
|
||||
import dev.usbharu.hideout.core.domain.event.relationship.RelationshipEvent
|
||||
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||
import org.junit.jupiter.api.Test
|
||||
import utils.AssertDomainEvent.assertContainsEvent
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class RelationshipTest {
|
||||
@Test
|
||||
fun unfollow_フォローとフォローリクエストが取り消されUNFOLLOWとUNFOLLOW_REQUESTが発生する() {
|
||||
val relationship = Relationship(
|
||||
actorId = ActorId(1),
|
||||
targetActorId = ActorId(2),
|
||||
following = true,
|
||||
blocking = false,
|
||||
muting = false,
|
||||
followRequesting = false,
|
||||
mutingFollowRequest = false
|
||||
)
|
||||
|
||||
relationship.unfollow()
|
||||
|
||||
assertFalse(relationship.following)
|
||||
assertFalse(relationship.followRequesting)
|
||||
assertContainsEvent(relationship, RelationshipEvent.UNFOLLOW.eventName)
|
||||
assertContainsEvent(relationship, RelationshipEvent.UNFOLLOW_REQUEST.eventName)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun block_unfollowされblockが発生する() {
|
||||
val relationship = Relationship(
|
||||
actorId = ActorId(1),
|
||||
targetActorId = ActorId(2),
|
||||
following = true,
|
||||
blocking = false,
|
||||
muting = false,
|
||||
followRequesting = false,
|
||||
mutingFollowRequest = false
|
||||
)
|
||||
|
||||
relationship.block()
|
||||
|
||||
assertTrue(relationship.blocking)
|
||||
assertContainsEvent(relationship, RelationshipEvent.BLOCK.eventName)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun mute_MUTEが発生する() {
|
||||
val relationship = Relationship(
|
||||
actorId = ActorId(1),
|
||||
targetActorId = ActorId(2),
|
||||
following = true,
|
||||
blocking = false,
|
||||
muting = false,
|
||||
followRequesting = false,
|
||||
mutingFollowRequest = false
|
||||
)
|
||||
|
||||
relationship.mute()
|
||||
|
||||
assertTrue(relationship.muting)
|
||||
assertContainsEvent(relationship, RelationshipEvent.MUTE.eventName)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun unmute_UNMUTEが発生する() {
|
||||
val relationship = Relationship(
|
||||
actorId = ActorId(1),
|
||||
targetActorId = ActorId(2),
|
||||
following = true,
|
||||
blocking = false,
|
||||
muting = true,
|
||||
followRequesting = false,
|
||||
mutingFollowRequest = true
|
||||
)
|
||||
|
||||
relationship.unmute()
|
||||
|
||||
assertFalse(relationship.muting)
|
||||
assertContainsEvent(relationship, RelationshipEvent.UNMUTE.eventName)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun muteFollowRequest_muteFollowiRequestがtrueになる() {
|
||||
val relationship = Relationship(
|
||||
actorId = ActorId(1),
|
||||
targetActorId = ActorId(2),
|
||||
following = true,
|
||||
blocking = false,
|
||||
muting = false,
|
||||
followRequesting = true,
|
||||
mutingFollowRequest = false
|
||||
)
|
||||
|
||||
relationship.muteFollowRequest()
|
||||
|
||||
assertTrue(relationship.mutingFollowRequest)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun unmuteFollowRequest_muteFollowiRequestがfalseになる() {
|
||||
val relationship = Relationship(
|
||||
actorId = ActorId(1),
|
||||
targetActorId = ActorId(2),
|
||||
following = true,
|
||||
blocking = false,
|
||||
muting = false,
|
||||
followRequesting = true,
|
||||
mutingFollowRequest = true
|
||||
)
|
||||
|
||||
relationship.unmuteFollowRequest()
|
||||
|
||||
assertFalse(relationship.mutingFollowRequest)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun followRequest_followRequestingがtrueになりFOLLOW_REQUESTが発生する() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
fun followRequest_ブロックしている場合はフォローリクエストを送れない() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
fun unfollowRequest_followRequestingがfalseになりUNFOLLOW_REQUESTが発生する() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
fun acceptFollowRequest_followingがtrueにfollowRequestingがfalseになりaccept_followが発生する() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue