Rename CertificateErrorNotifications to CertificateErrorNotificationController

This commit is contained in:
cketti 2021-10-14 17:20:30 +02:00
parent 50187f8b53
commit 05a75b898e
4 changed files with 12 additions and 12 deletions

View file

@ -5,7 +5,7 @@ import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import com.fsck.k9.Account
internal open class CertificateErrorNotifications(
internal open class CertificateErrorNotificationController(
private val notificationHelper: NotificationHelper,
private val actionCreator: NotificationActionCreator,
private val resourceProvider: NotificationResourceProvider

View file

@ -26,7 +26,7 @@ val coreNotificationModule = module {
serverSettingsSerializer = get()
)
}
single { CertificateErrorNotifications(get(), get(), get()) }
single { CertificateErrorNotificationController(get(), get(), get()) }
single { AuthenticationErrorNotificationController(get(), get(), get()) }
single { SyncNotifications(get(), get(), get()) }
single { SendFailedNotifications(get(), get(), get()) }

View file

@ -6,18 +6,18 @@ import com.fsck.k9.mailstore.LocalFolder
import com.fsck.k9.mailstore.LocalMessage
class NotificationController internal constructor(
private val certificateErrorNotifications: CertificateErrorNotifications,
private val certificateErrorNotificationController: CertificateErrorNotificationController,
private val authenticationErrorNotificationController: AuthenticationErrorNotificationController,
private val syncNotifications: SyncNotifications,
private val sendFailedNotifications: SendFailedNotifications,
private val newMailNotifications: NewMailNotifications
) {
fun showCertificateErrorNotification(account: Account, incoming: Boolean) {
certificateErrorNotifications.showCertificateErrorNotification(account, incoming)
certificateErrorNotificationController.showCertificateErrorNotification(account, incoming)
}
fun clearCertificateErrorNotifications(account: Account, incoming: Boolean) {
certificateErrorNotifications.clearCertificateErrorNotifications(account, incoming)
certificateErrorNotificationController.clearCertificateErrorNotifications(account, incoming)
}
fun showAuthenticationErrorNotification(account: Account, incoming: Boolean) {

View file

@ -19,21 +19,21 @@ private const val OUTGOING = false
private const val ACCOUNT_NUMBER = 1
private const val ACCOUNT_NAME = "TestAccount"
class CertificateErrorNotificationsTest : RobolectricTest() {
class CertificateErrorNotificationControllerTest : RobolectricTest() {
private val resourceProvider: NotificationResourceProvider = TestNotificationResourceProvider()
private val notification = mock<Notification>()
private val notificationManager = mock<NotificationManagerCompat>()
private val builder = createFakeNotificationBuilder(notification)
private val notificationHelper = createFakeNotificationHelper(notificationManager, builder)
private val account = createFakeAccount()
private val certificateErrorNotifications = TestCertificateErrorNotifications()
private val controller = TestCertificateErrorNotificationController()
private val contentIntent = mock<PendingIntent>()
@Test
fun testShowCertificateErrorNotificationForIncomingServer() {
val notificationId = NotificationIds.getCertificateErrorNotificationId(account, INCOMING)
certificateErrorNotifications.showCertificateErrorNotification(account, INCOMING)
controller.showCertificateErrorNotification(account, INCOMING)
verify(notificationManager).notify(notificationId, notification)
assertCertificateErrorNotificationContents()
@ -43,7 +43,7 @@ class CertificateErrorNotificationsTest : RobolectricTest() {
fun testClearCertificateErrorNotificationsForIncomingServer() {
val notificationId = NotificationIds.getCertificateErrorNotificationId(account, INCOMING)
certificateErrorNotifications.clearCertificateErrorNotifications(account, INCOMING)
controller.clearCertificateErrorNotifications(account, INCOMING)
verify(notificationManager).cancel(notificationId)
}
@ -52,7 +52,7 @@ class CertificateErrorNotificationsTest : RobolectricTest() {
fun testShowCertificateErrorNotificationForOutgoingServer() {
val notificationId = NotificationIds.getCertificateErrorNotificationId(account, OUTGOING)
certificateErrorNotifications.showCertificateErrorNotification(account, OUTGOING)
controller.showCertificateErrorNotification(account, OUTGOING)
verify(notificationManager).notify(notificationId, notification)
assertCertificateErrorNotificationContents()
@ -62,7 +62,7 @@ class CertificateErrorNotificationsTest : RobolectricTest() {
fun testClearCertificateErrorNotificationsForOutgoingServer() {
val notificationId = NotificationIds.getCertificateErrorNotificationId(account, OUTGOING)
certificateErrorNotifications.clearCertificateErrorNotifications(account, OUTGOING)
controller.clearCertificateErrorNotifications(account, OUTGOING)
verify(notificationManager).cancel(notificationId)
}
@ -101,7 +101,7 @@ class CertificateErrorNotificationsTest : RobolectricTest() {
}
}
internal inner class TestCertificateErrorNotifications : CertificateErrorNotifications(
internal inner class TestCertificateErrorNotificationController : CertificateErrorNotificationController(
notificationHelper, mock(), resourceProvider
) {
override fun createContentIntent(account: Account, incoming: Boolean): PendingIntent {