Renaming a use case
This commit is contained in:
parent
c12af5a800
commit
7b830d1c1a
@ -22,11 +22,11 @@ import org.matrix.android.sdk.api.session.Session
|
|||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class CanToggleNotificationsViaAccountDataUseCase @Inject constructor(
|
class CanToggleNotificationsViaAccountDataUseCase @Inject constructor(
|
||||||
private val getNotificationSettingsAccountDataAsFlowUseCase: GetNotificationSettingsAccountDataAsFlowUseCase,
|
private val getNotificationSettingsAccountDataUpdatesUseCase: GetNotificationSettingsAccountDataUpdatesUseCase,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
fun execute(session: Session, deviceId: String): Flow<Boolean> {
|
fun execute(session: Session, deviceId: String): Flow<Boolean> {
|
||||||
return getNotificationSettingsAccountDataAsFlowUseCase.execute(session, deviceId)
|
return getNotificationSettingsAccountDataUpdatesUseCase.execute(session, deviceId)
|
||||||
.map { it?.isSilenced != null }
|
.map { it?.isSilenced != null }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ import org.matrix.android.sdk.api.session.accountdata.UserAccountDataTypes
|
|||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class GetNotificationSettingsAccountDataAsFlowUseCase @Inject constructor() {
|
class GetNotificationSettingsAccountDataUpdatesUseCase @Inject constructor() {
|
||||||
|
|
||||||
fun execute(session: Session, deviceId: String): Flow<LocalNotificationSettingsContent?> {
|
fun execute(session: Session, deviceId: String): Flow<LocalNotificationSettingsContent?> {
|
||||||
return session
|
return session
|
@ -29,10 +29,10 @@ import org.matrix.android.sdk.api.account.LocalNotificationSettingsContent
|
|||||||
|
|
||||||
class CanToggleNotificationsViaAccountDataUseCaseTest {
|
class CanToggleNotificationsViaAccountDataUseCaseTest {
|
||||||
|
|
||||||
private val fakeGetNotificationSettingsAccountDataAsFlowUseCase = mockk<GetNotificationSettingsAccountDataAsFlowUseCase>()
|
private val fakeGetNotificationSettingsAccountDataUpdatesUseCase = mockk<GetNotificationSettingsAccountDataUpdatesUseCase>()
|
||||||
|
|
||||||
private val canToggleNotificationsViaAccountDataUseCase = CanToggleNotificationsViaAccountDataUseCase(
|
private val canToggleNotificationsViaAccountDataUseCase = CanToggleNotificationsViaAccountDataUseCase(
|
||||||
getNotificationSettingsAccountDataAsFlowUseCase = fakeGetNotificationSettingsAccountDataAsFlowUseCase,
|
getNotificationSettingsAccountDataUpdatesUseCase = fakeGetNotificationSettingsAccountDataUpdatesUseCase,
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -43,14 +43,14 @@ class CanToggleNotificationsViaAccountDataUseCaseTest {
|
|||||||
val localNotificationSettingsContent = LocalNotificationSettingsContent(
|
val localNotificationSettingsContent = LocalNotificationSettingsContent(
|
||||||
isSilenced = true,
|
isSilenced = true,
|
||||||
)
|
)
|
||||||
every { fakeGetNotificationSettingsAccountDataAsFlowUseCase.execute(any(), any()) } returns flowOf(localNotificationSettingsContent)
|
every { fakeGetNotificationSettingsAccountDataUpdatesUseCase.execute(any(), any()) } returns flowOf(localNotificationSettingsContent)
|
||||||
|
|
||||||
// When
|
// When
|
||||||
val result = canToggleNotificationsViaAccountDataUseCase.execute(aSession, aDeviceId).firstOrNull()
|
val result = canToggleNotificationsViaAccountDataUseCase.execute(aSession, aDeviceId).firstOrNull()
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
result shouldBe true
|
result shouldBe true
|
||||||
verify { fakeGetNotificationSettingsAccountDataAsFlowUseCase.execute(aSession, aDeviceId) }
|
verify { fakeGetNotificationSettingsAccountDataUpdatesUseCase.execute(aSession, aDeviceId) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -61,14 +61,14 @@ class CanToggleNotificationsViaAccountDataUseCaseTest {
|
|||||||
val localNotificationSettingsContent = LocalNotificationSettingsContent(
|
val localNotificationSettingsContent = LocalNotificationSettingsContent(
|
||||||
isSilenced = null,
|
isSilenced = null,
|
||||||
)
|
)
|
||||||
every { fakeGetNotificationSettingsAccountDataAsFlowUseCase.execute(any(), any()) } returns flowOf(localNotificationSettingsContent)
|
every { fakeGetNotificationSettingsAccountDataUpdatesUseCase.execute(any(), any()) } returns flowOf(localNotificationSettingsContent)
|
||||||
|
|
||||||
// When
|
// When
|
||||||
val result = canToggleNotificationsViaAccountDataUseCase.execute(aSession, aDeviceId).firstOrNull()
|
val result = canToggleNotificationsViaAccountDataUseCase.execute(aSession, aDeviceId).firstOrNull()
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
result shouldBe false
|
result shouldBe false
|
||||||
verify { fakeGetNotificationSettingsAccountDataAsFlowUseCase.execute(aSession, aDeviceId) }
|
verify { fakeGetNotificationSettingsAccountDataUpdatesUseCase.execute(aSession, aDeviceId) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -76,13 +76,13 @@ class CanToggleNotificationsViaAccountDataUseCaseTest {
|
|||||||
// Given
|
// Given
|
||||||
val aSession = FakeSession()
|
val aSession = FakeSession()
|
||||||
val aDeviceId = "aDeviceId"
|
val aDeviceId = "aDeviceId"
|
||||||
every { fakeGetNotificationSettingsAccountDataAsFlowUseCase.execute(any(), any()) } returns flowOf(null)
|
every { fakeGetNotificationSettingsAccountDataUpdatesUseCase.execute(any(), any()) } returns flowOf(null)
|
||||||
|
|
||||||
// When
|
// When
|
||||||
val result = canToggleNotificationsViaAccountDataUseCase.execute(aSession, aDeviceId).firstOrNull()
|
val result = canToggleNotificationsViaAccountDataUseCase.execute(aSession, aDeviceId).firstOrNull()
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
result shouldBe false
|
result shouldBe false
|
||||||
verify { fakeGetNotificationSettingsAccountDataAsFlowUseCase.execute(aSession, aDeviceId) }
|
verify { fakeGetNotificationSettingsAccountDataUpdatesUseCase.execute(aSession, aDeviceId) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,10 +30,10 @@ import org.matrix.android.sdk.api.account.LocalNotificationSettingsContent
|
|||||||
import org.matrix.android.sdk.api.session.accountdata.UserAccountDataTypes
|
import org.matrix.android.sdk.api.session.accountdata.UserAccountDataTypes
|
||||||
import org.matrix.android.sdk.api.session.events.model.toContent
|
import org.matrix.android.sdk.api.session.events.model.toContent
|
||||||
|
|
||||||
class GetNotificationSettingsAccountDataAsFlowUseCaseTest {
|
class GetNotificationSettingsAccountDataUpdatesUseCaseTest {
|
||||||
|
|
||||||
private val fakeFlowLiveDataConversions = FakeFlowLiveDataConversions()
|
private val fakeFlowLiveDataConversions = FakeFlowLiveDataConversions()
|
||||||
private val getNotificationSettingsAccountDataAsFlowUseCase = GetNotificationSettingsAccountDataAsFlowUseCase()
|
private val getNotificationSettingsAccountDataUpdatesUseCase = GetNotificationSettingsAccountDataUpdatesUseCase()
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
@ -60,7 +60,7 @@ class GetNotificationSettingsAccountDataAsFlowUseCaseTest {
|
|||||||
.givenAsFlow()
|
.givenAsFlow()
|
||||||
|
|
||||||
// When
|
// When
|
||||||
val result = getNotificationSettingsAccountDataAsFlowUseCase.execute(aSession, aDeviceId).firstOrNull()
|
val result = getNotificationSettingsAccountDataUpdatesUseCase.execute(aSession, aDeviceId).firstOrNull()
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
result shouldBeEqualTo expectedContent
|
result shouldBeEqualTo expectedContent
|
||||||
@ -80,7 +80,7 @@ class GetNotificationSettingsAccountDataAsFlowUseCaseTest {
|
|||||||
.givenAsFlow()
|
.givenAsFlow()
|
||||||
|
|
||||||
// When
|
// When
|
||||||
val result = getNotificationSettingsAccountDataAsFlowUseCase.execute(aSession, aDeviceId).firstOrNull()
|
val result = getNotificationSettingsAccountDataUpdatesUseCase.execute(aSession, aDeviceId).firstOrNull()
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
result shouldBeEqualTo null
|
result shouldBeEqualTo null
|
||||||
@ -101,7 +101,7 @@ class GetNotificationSettingsAccountDataAsFlowUseCaseTest {
|
|||||||
.givenAsFlow()
|
.givenAsFlow()
|
||||||
|
|
||||||
// When
|
// When
|
||||||
val result = getNotificationSettingsAccountDataAsFlowUseCase.execute(aSession, aDeviceId).firstOrNull()
|
val result = getNotificationSettingsAccountDataUpdatesUseCase.execute(aSession, aDeviceId).firstOrNull()
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
result shouldBeEqualTo expectedContent
|
result shouldBeEqualTo expectedContent
|
Loading…
Reference in New Issue
Block a user