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
|
||||
|
||||
class CanToggleNotificationsViaAccountDataUseCase @Inject constructor(
|
||||
private val getNotificationSettingsAccountDataAsFlowUseCase: GetNotificationSettingsAccountDataAsFlowUseCase,
|
||||
private val getNotificationSettingsAccountDataUpdatesUseCase: GetNotificationSettingsAccountDataUpdatesUseCase,
|
||||
) {
|
||||
|
||||
fun execute(session: Session, deviceId: String): Flow<Boolean> {
|
||||
return getNotificationSettingsAccountDataAsFlowUseCase.execute(session, deviceId)
|
||||
return getNotificationSettingsAccountDataUpdatesUseCase.execute(session, deviceId)
|
||||
.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 javax.inject.Inject
|
||||
|
||||
class GetNotificationSettingsAccountDataAsFlowUseCase @Inject constructor() {
|
||||
class GetNotificationSettingsAccountDataUpdatesUseCase @Inject constructor() {
|
||||
|
||||
fun execute(session: Session, deviceId: String): Flow<LocalNotificationSettingsContent?> {
|
||||
return session
|
|
@ -29,10 +29,10 @@ import org.matrix.android.sdk.api.account.LocalNotificationSettingsContent
|
|||
|
||||
class CanToggleNotificationsViaAccountDataUseCaseTest {
|
||||
|
||||
private val fakeGetNotificationSettingsAccountDataAsFlowUseCase = mockk<GetNotificationSettingsAccountDataAsFlowUseCase>()
|
||||
private val fakeGetNotificationSettingsAccountDataUpdatesUseCase = mockk<GetNotificationSettingsAccountDataUpdatesUseCase>()
|
||||
|
||||
private val canToggleNotificationsViaAccountDataUseCase = CanToggleNotificationsViaAccountDataUseCase(
|
||||
getNotificationSettingsAccountDataAsFlowUseCase = fakeGetNotificationSettingsAccountDataAsFlowUseCase,
|
||||
getNotificationSettingsAccountDataUpdatesUseCase = fakeGetNotificationSettingsAccountDataUpdatesUseCase,
|
||||
)
|
||||
|
||||
@Test
|
||||
|
@ -43,14 +43,14 @@ class CanToggleNotificationsViaAccountDataUseCaseTest {
|
|||
val localNotificationSettingsContent = LocalNotificationSettingsContent(
|
||||
isSilenced = true,
|
||||
)
|
||||
every { fakeGetNotificationSettingsAccountDataAsFlowUseCase.execute(any(), any()) } returns flowOf(localNotificationSettingsContent)
|
||||
every { fakeGetNotificationSettingsAccountDataUpdatesUseCase.execute(any(), any()) } returns flowOf(localNotificationSettingsContent)
|
||||
|
||||
// When
|
||||
val result = canToggleNotificationsViaAccountDataUseCase.execute(aSession, aDeviceId).firstOrNull()
|
||||
|
||||
// Then
|
||||
result shouldBe true
|
||||
verify { fakeGetNotificationSettingsAccountDataAsFlowUseCase.execute(aSession, aDeviceId) }
|
||||
verify { fakeGetNotificationSettingsAccountDataUpdatesUseCase.execute(aSession, aDeviceId) }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -61,14 +61,14 @@ class CanToggleNotificationsViaAccountDataUseCaseTest {
|
|||
val localNotificationSettingsContent = LocalNotificationSettingsContent(
|
||||
isSilenced = null,
|
||||
)
|
||||
every { fakeGetNotificationSettingsAccountDataAsFlowUseCase.execute(any(), any()) } returns flowOf(localNotificationSettingsContent)
|
||||
every { fakeGetNotificationSettingsAccountDataUpdatesUseCase.execute(any(), any()) } returns flowOf(localNotificationSettingsContent)
|
||||
|
||||
// When
|
||||
val result = canToggleNotificationsViaAccountDataUseCase.execute(aSession, aDeviceId).firstOrNull()
|
||||
|
||||
// Then
|
||||
result shouldBe false
|
||||
verify { fakeGetNotificationSettingsAccountDataAsFlowUseCase.execute(aSession, aDeviceId) }
|
||||
verify { fakeGetNotificationSettingsAccountDataUpdatesUseCase.execute(aSession, aDeviceId) }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -76,13 +76,13 @@ class CanToggleNotificationsViaAccountDataUseCaseTest {
|
|||
// Given
|
||||
val aSession = FakeSession()
|
||||
val aDeviceId = "aDeviceId"
|
||||
every { fakeGetNotificationSettingsAccountDataAsFlowUseCase.execute(any(), any()) } returns flowOf(null)
|
||||
every { fakeGetNotificationSettingsAccountDataUpdatesUseCase.execute(any(), any()) } returns flowOf(null)
|
||||
|
||||
// When
|
||||
val result = canToggleNotificationsViaAccountDataUseCase.execute(aSession, aDeviceId).firstOrNull()
|
||||
|
||||
// Then
|
||||
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.events.model.toContent
|
||||
|
||||
class GetNotificationSettingsAccountDataAsFlowUseCaseTest {
|
||||
class GetNotificationSettingsAccountDataUpdatesUseCaseTest {
|
||||
|
||||
private val fakeFlowLiveDataConversions = FakeFlowLiveDataConversions()
|
||||
private val getNotificationSettingsAccountDataAsFlowUseCase = GetNotificationSettingsAccountDataAsFlowUseCase()
|
||||
private val getNotificationSettingsAccountDataUpdatesUseCase = GetNotificationSettingsAccountDataUpdatesUseCase()
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
|
@ -60,7 +60,7 @@ class GetNotificationSettingsAccountDataAsFlowUseCaseTest {
|
|||
.givenAsFlow()
|
||||
|
||||
// When
|
||||
val result = getNotificationSettingsAccountDataAsFlowUseCase.execute(aSession, aDeviceId).firstOrNull()
|
||||
val result = getNotificationSettingsAccountDataUpdatesUseCase.execute(aSession, aDeviceId).firstOrNull()
|
||||
|
||||
// Then
|
||||
result shouldBeEqualTo expectedContent
|
||||
|
@ -80,7 +80,7 @@ class GetNotificationSettingsAccountDataAsFlowUseCaseTest {
|
|||
.givenAsFlow()
|
||||
|
||||
// When
|
||||
val result = getNotificationSettingsAccountDataAsFlowUseCase.execute(aSession, aDeviceId).firstOrNull()
|
||||
val result = getNotificationSettingsAccountDataUpdatesUseCase.execute(aSession, aDeviceId).firstOrNull()
|
||||
|
||||
// Then
|
||||
result shouldBeEqualTo null
|
||||
|
@ -101,7 +101,7 @@ class GetNotificationSettingsAccountDataAsFlowUseCaseTest {
|
|||
.givenAsFlow()
|
||||
|
||||
// When
|
||||
val result = getNotificationSettingsAccountDataAsFlowUseCase.execute(aSession, aDeviceId).firstOrNull()
|
||||
val result = getNotificationSettingsAccountDataUpdatesUseCase.execute(aSession, aDeviceId).firstOrNull()
|
||||
|
||||
// Then
|
||||
result shouldBeEqualTo expectedContent
|
Loading…
Reference in New Issue