Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1581a892 authored by Jonathan Klee's avatar Jonathan Klee
Browse files

refactor: remove useless UseCase classes invoke() calls

parent 28ec2197
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -173,7 +173,7 @@ class AppInstallProcessor @Inject constructor(
    }

    private suspend fun validateAgeLimit(appInstall: AppInstall): Boolean {
        val ageLimitValidationResult = validateAppAgeLimitUseCase.invoke(appInstall)
        val ageLimitValidationResult = validateAppAgeLimitUseCase(appInstall)
        if (ageLimitValidationResult.data?.isValid == true) {
            return true
        }
+2 −2
Original line number Diff line number Diff line
@@ -223,7 +223,7 @@ class AgeRatingProvider : ContentProvider() {
            packageName = packageName,
            source = Source.PLAY_STORE
        )
        val validateResult = validateAppAgeLimitUseCase.invoke(fakeAppInstall)
        val validateResult = validateAppAgeLimitUseCase(fakeAppInstall)
        saveContentRatingIfInvalid(validateResult, packageName)

        return validateResult.data?.isValid
@@ -249,7 +249,7 @@ class AgeRatingProvider : ContentProvider() {
            packageName = packageName,
            source = Source.OPEN_SOURCE,
        )
        val validateResult = validateAppAgeLimitUseCase.invoke(fakeAppInstall)
        val validateResult = validateAppAgeLimitUseCase(fakeAppInstall)
        return validateResult.data?.isValid ?: false
    }

+2 −2
Original line number Diff line number Diff line
@@ -190,7 +190,7 @@ class AppInstallProcessorTest {
    @Test
    fun `processInstallTest when age limit is satisfied`() = runTest {
        val fusedDownload = initTest()
        Mockito.`when`(validateAppAgeRatingUseCase.invoke(fusedDownload))
        Mockito.`when`(validateAppAgeRatingUseCase(fusedDownload))
            .thenReturn(ResultSupreme.create(ResultStatus.OK, ContentRatingValidity(true)))

        val finalFusedDownload = runProcessInstall(fusedDownload)
@@ -200,7 +200,7 @@ class AppInstallProcessorTest {
    @Test
    fun `processInstallTest when age limit is not satisfied`() = runTest {
        val fusedDownload = initTest()
        Mockito.`when`(validateAppAgeRatingUseCase.invoke(fusedDownload))
        Mockito.`when`(validateAppAgeRatingUseCase(fusedDownload))
            .thenReturn(ResultSupreme.create(ResultStatus.OK, ContentRatingValidity(false)))

        val finalFusedDownload = runProcessInstall(fusedDownload)
+7 −7
Original line number Diff line number Diff line
@@ -135,8 +135,8 @@ class LoginViewModelTest {
        val microgAccount = MicrogAccount(account, "token")
        val result = MicrogLoginManager.FetchResult.Success(microgAccount)

        whenever(fetchMicrogAccountUseCase.invoke("user@gmail.com")).thenReturn(result)
        whenever(initialMicrogLoginUseCase.invoke(microgAccount)).thenReturn(Unit)
        whenever(fetchMicrogAccountUseCase("user@gmail.com")).thenReturn(result)
        whenever(initialMicrogLoginUseCase(microgAccount)).thenReturn(Unit)
        whenever(authenticatorRepository.fetchAuthObjects(any())).thenReturn(emptyList())

        var onErrorCalls = 0
@@ -149,7 +149,7 @@ class LoginViewModelTest {
            onIntentRequired = { onIntentCalls += 1 }
        )

        verify(initialMicrogLoginUseCase).invoke(microgAccount)
        verify(initialMicrogLoginUseCase)(microgAccount)
        verify(authenticatorRepository).fetchAuthObjects(any())
        assert(onErrorCalls == 0)
        assert(onIntentCalls == 0)
@@ -160,7 +160,7 @@ class LoginViewModelTest {
        val intent = Intent("test.action")
        val result = MicrogLoginManager.FetchResult.RequiresUserAction(intent)

        whenever(fetchMicrogAccountUseCase.invoke("")).thenReturn(result)
        whenever(fetchMicrogAccountUseCase("")).thenReturn(result)

        var onIntentCalls = 0
        var receivedIntent: Intent? = null
@@ -177,13 +177,13 @@ class LoginViewModelTest {

        assert(onIntentCalls == 1)
        assert(receivedIntent === intent)
        verify(initialMicrogLoginUseCase, never()).invoke(any())
        verify(initialMicrogLoginUseCase, never())(any())
    }

    @Test
    fun `initialMicrogLogin reports error when fetch fails`() = runTest {
        val failure = IllegalStateException("boom")
        whenever(fetchMicrogAccountUseCase.invoke("")).thenThrow(failure)
        whenever(fetchMicrogAccountUseCase("")).thenThrow(failure)

        var errorMessage: String? = null

@@ -195,6 +195,6 @@ class LoginViewModelTest {
        )

        assert(errorMessage == "boom")
        verify(initialMicrogLoginUseCase, never()).invoke(any())
        verify(initialMicrogLoginUseCase, never())(any())
    }
}