diff --git a/app/src/androidTest/kotlin/at/bitfire/davdroid/resource/LocalAddressBookStoreTest.kt b/app/src/androidTest/kotlin/at/bitfire/davdroid/resource/LocalAddressBookStoreTest.kt index 90773fa33..408f98bb2 100644 --- a/app/src/androidTest/kotlin/at/bitfire/davdroid/resource/LocalAddressBookStoreTest.kt +++ b/app/src/androidTest/kotlin/at/bitfire/davdroid/resource/LocalAddressBookStoreTest.kt @@ -17,7 +17,6 @@ import dagger.hilt.android.testing.HiltAndroidTest import io.mockk.MockKAnnotations import io.mockk.every import io.mockk.impl.annotations.InjectMockKs -import io.mockk.impl.annotations.MockK import io.mockk.impl.annotations.RelaxedMockK import io.mockk.impl.annotations.SpyK import io.mockk.just @@ -48,7 +47,7 @@ class LocalAddressBookStoreTest { @SpyK lateinit var context: Context - val account: Account = mockk(relaxed = true) + val account: Account = Account("MrRobert@example.com", "Mock Account Type") val provider = mockk(relaxed = true) val addressBook: LocalAddressBook = mockk(relaxed = true) { every { updateSyncFrameworkSettings() } just runs @@ -56,20 +55,26 @@ class LocalAddressBookStoreTest { every { settings } returns LocalAddressBookStore.contactsProviderSettings } - @MockK + @RelaxedMockK lateinit var collectionRepository: DavCollectionRepository - @MockK - lateinit var localAddressBookFactory: LocalAddressBook.Factory + val localAddressBookFactory = mockk { + every { create(account, provider) } returns addressBook + } - @RelaxedMockK + @Inject + @SpyK lateinit var logger: Logger @RelaxedMockK lateinit var settingsManager: SettingsManager - @MockK - lateinit var serviceRepository: DavServiceRepository + val serviceRepository = mockk(relaxed = true) { + every { get(any()) } returns null + every { get(200) } returns mockk { + every { accountName } returns "MrRobert@example.com" + } + } @InjectMockKs @SpyK @@ -82,12 +87,6 @@ class LocalAddressBookStoreTest { // initialize global mocks MockKAnnotations.init(this) - every { localAddressBookFactory.create(account, provider) } returns addressBook - - every { serviceRepository.get(any()) } returns null - every { serviceRepository.get(200) } returns mockk { - every { accountName } returns "MrRobert@example.com" - } } @After