diff --git a/app/build.gradle b/app/build.gradle index 5b84004a7..04b7bf066 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -172,7 +172,7 @@ dependencies { androidTestImplementation "junit:junit:$rootProject.jUnitVersion" androidTestImplementation "org.mockito:mockito-core:$rootProject.mockitoVersion" androidTestImplementation "org.mockito:mockito-android:$rootProject.mockitoVersion" - androidTestImplementation "androidx.annotation:annotation:1.0.0" + androidTestImplementation "androidx.annotation:annotation:1.7.0" implementation "androidx.arch.core:core-testing:$rootProject.archCoreVersion" androidTestImplementation("androidx.test.espresso:espresso-contrib:$rootProject.espressoVersion") { exclude group: 'com.android.support', module: 'appcompat' diff --git a/app/src/commonTest/java/org/mifos/mobile/RetrofitUtils.kt b/app/src/commonTest/java/org/mifos/mobile/RetrofitUtils.kt index 9e8ed89e3..d34cf5f33 100644 --- a/app/src/commonTest/java/org/mifos/mobile/RetrofitUtils.kt +++ b/app/src/commonTest/java/org/mifos/mobile/RetrofitUtils.kt @@ -1,8 +1,10 @@ package org.mifos.mobile import okhttp3.MediaType +import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.Protocol import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import retrofit2.HttpException import retrofit2.Response @@ -13,7 +15,7 @@ object RetrofitUtils { fun getResponseForError(errorCode: Int): Exception { val message = if (errorCode == 401) "UnAuthorized" else "Not Found" val responseBody = - ResponseBody.create(MediaType.parse("application/json"), "{\"message\":\"$message\"}") + "{\"message\":\"$message\"}".toResponseBody("application/json".toMediaTypeOrNull()) val response = okhttp3.Response.Builder().code(errorCode) .message(message) .protocol(Protocol.HTTP_1_1) diff --git a/app/src/debug/java/org/mifos/mobile/api/SelfServiceInterceptor.kt b/app/src/debug/java/org/mifos/mobile/api/SelfServiceInterceptor.kt index 1164e0d18..cee5605c0 100644 --- a/app/src/debug/java/org/mifos/mobile/api/SelfServiceInterceptor.kt +++ b/app/src/debug/java/org/mifos/mobile/api/SelfServiceInterceptor.kt @@ -18,14 +18,18 @@ class SelfServiceInterceptor(private val tenant: String?, private val authToken: @Throws(IOException::class) override fun intercept(chain: Interceptor.Chain): Response { val chainRequest = chain.request() - val builder = chainRequest.newBuilder() - .header(HEADER_TENANT, tenant) - .header(CONTENT_TYPE, "application/json") + val builder = tenant?.let { + chainRequest.newBuilder() + .header(HEADER_TENANT, it) + .header(CONTENT_TYPE, "application/json") + } if (!TextUtils.isEmpty(authToken)) { - builder.header(HEADER_AUTH, authToken) + if (authToken != null) { + builder?.header(HEADER_AUTH, authToken) + } } - val request = builder.build() - return chain.proceed(request) + val request = builder?.build() + return chain.proceed(request!!) } companion object { diff --git a/app/src/main/java/org/mifos/mobile/repositories/GuarantorRepositoryImp.kt b/app/src/main/java/org/mifos/mobile/repositories/GuarantorRepositoryImp.kt index c4da39177..0e7194f6d 100644 --- a/app/src/main/java/org/mifos/mobile/repositories/GuarantorRepositoryImp.kt +++ b/app/src/main/java/org/mifos/mobile/repositories/GuarantorRepositoryImp.kt @@ -4,7 +4,9 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.flow import okhttp3.MediaType +import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.mifos.mobile.FakeRemoteDataSource import org.mifos.mobile.api.DataManager import org.mifos.mobile.models.guarantor.GuarantorApplicationPayload @@ -30,10 +32,8 @@ class GuarantorRepositoryImp @Inject constructor(private val dataManager: DataMa return flow { emit(dataManager.createGuarantor(loanId, payload)) }.catch { - val responseBody = ResponseBody.create( - MediaType.parse("text/plain"), - "Guarantor Added Successfully" - ) + val responseBody = "Guarantor Added Successfully" + .toResponseBody("text/plain".toMediaTypeOrNull()) emit(responseBody) } } @@ -46,10 +46,8 @@ class GuarantorRepositoryImp @Inject constructor(private val dataManager: DataMa return flow { emit(dataManager.updateGuarantor(payload, loanId, guarantorId)) }.catch { - val response = ResponseBody.create( - MediaType - .parse("plain/text"), - "Guarantor Updated Successfully", + val response = "Guarantor Updated Successfully".toResponseBody( + "plain/text".toMediaTypeOrNull() ) emit(response) } @@ -59,10 +57,8 @@ class GuarantorRepositoryImp @Inject constructor(private val dataManager: DataMa return flow { emit(dataManager.deleteGuarantor(loanId, guarantorId)) }.catch { - val response = ResponseBody.create( - MediaType - .parse("plain/text"), - "Guarantor Deleted Successfully", + val response = "Guarantor Deleted Successfully".toResponseBody( + "plain/text".toMediaTypeOrNull() ) emit(response) } diff --git a/app/src/main/java/org/mifos/mobile/ui/activities/HomeActivity.kt b/app/src/main/java/org/mifos/mobile/ui/activities/HomeActivity.kt index cd74b71bd..9c5577afa 100644 --- a/app/src/main/java/org/mifos/mobile/ui/activities/HomeActivity.kt +++ b/app/src/main/java/org/mifos/mobile/ui/activities/HomeActivity.kt @@ -435,7 +435,7 @@ class HomeActivity : if (resultCode != ConnectionResult.SUCCESS) { if (apiAvailability.isUserResolvableError(resultCode)) { apiAvailability.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST) - .show() + ?.show() } else { Log.i(HomeActivity::class.java.name, "This device is not supported.") finish() diff --git a/app/src/main/java/org/mifos/mobile/ui/fragments/LocationsFragment.kt b/app/src/main/java/org/mifos/mobile/ui/fragments/LocationsFragment.kt index 143dd081b..4a8eef2ed 100644 --- a/app/src/main/java/org/mifos/mobile/ui/fragments/LocationsFragment.kt +++ b/app/src/main/java/org/mifos/mobile/ui/fragments/LocationsFragment.kt @@ -37,7 +37,7 @@ class LocationsFragment : BaseFragment(), OnMapReadyCallback { binding.map.onCreate(savedInstanceState) binding.map.onResume() try { - MapsInitializer.initialize(activity?.applicationContext) + activity?.applicationContext?.let { MapsInitializer.initialize(it) } } catch (e: Exception) { Log.d(LocationsFragment::class.java.simpleName, e.toString()) } diff --git a/app/src/test/java/org/mifos/mobile/repositories/BeneficiaryRepositoryImpTest.kt b/app/src/test/java/org/mifos/mobile/repositories/BeneficiaryRepositoryImpTest.kt index 1c8b2f00c..7af89e11c 100644 --- a/app/src/test/java/org/mifos/mobile/repositories/BeneficiaryRepositoryImpTest.kt +++ b/app/src/test/java/org/mifos/mobile/repositories/BeneficiaryRepositoryImpTest.kt @@ -5,6 +5,7 @@ import junit.framework.Assert.assertEquals import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.Before import org.junit.Rule import org.junit.Test @@ -54,7 +55,7 @@ class BeneficiaryRepositoryImpTest { @Test fun testBeneficiaryTemplate_Unsuccessful() = runBlocking { val error: Response = - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) `when`(dataManager.beneficiaryTemplate()).thenReturn(error) val result = beneficiaryRepositoryImp.beneficiaryTemplate() @@ -81,7 +82,7 @@ class BeneficiaryRepositoryImpTest { @Test fun testCreateBeneficiary_Unsuccessful() = runBlocking { val error: Response = - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) val beneficiaryPayload = mock(BeneficiaryPayload::class.java) `when`(dataManager.createBeneficiary(beneficiaryPayload)).thenReturn(error) @@ -108,7 +109,7 @@ class BeneficiaryRepositoryImpTest { @Test fun testUpdateBeneficiary_Unsuccessful() = runBlocking { val error: Response = - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) val beneficiaryUpdatePayload = mock(BeneficiaryUpdatePayload::class.java) @@ -133,7 +134,7 @@ class BeneficiaryRepositoryImpTest { @Test fun testDeleteBeneficiary_Unsuccessful() = runBlocking { val error: Response = - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) `when`(dataManager.deleteBeneficiary(123L)).thenReturn(error) @@ -155,7 +156,7 @@ class BeneficiaryRepositoryImpTest { @Test fun testBeneficiaryList_Unsuccessful() = runBlocking { val error: Response?> = - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) `when`(dataManager.beneficiaryList()).thenReturn(error) diff --git a/app/src/test/java/org/mifos/mobile/repositories/ClientChargeRepositoryImpTest.kt b/app/src/test/java/org/mifos/mobile/repositories/ClientChargeRepositoryImpTest.kt index 094591e95..63495d952 100644 --- a/app/src/test/java/org/mifos/mobile/repositories/ClientChargeRepositoryImpTest.kt +++ b/app/src/test/java/org/mifos/mobile/repositories/ClientChargeRepositoryImpTest.kt @@ -5,6 +5,7 @@ import junit.framework.Assert.assertEquals import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.Before import org.junit.Rule import org.junit.Test @@ -51,7 +52,7 @@ class ClientChargeRepositoryImpTest { @Test fun testGetClientCharges_Unsuccessful() = runBlocking { val error: Response?> = - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) `when`(dataManager.getClientCharges(123L)).thenReturn(error) @@ -73,7 +74,7 @@ class ClientChargeRepositoryImpTest { @Test fun testGetLoanCharges_Unsuccessful() = runBlocking { val error: Response?> = - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) `when`(dataManager.getLoanCharges(123L)).thenReturn(error) @@ -95,7 +96,7 @@ class ClientChargeRepositoryImpTest { @Test fun testGetSavingsCharges_Unsuccessful() = runBlocking { val error: Response?> = - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) `when`(dataManager.getSavingsCharges(123L)).thenReturn(error) @@ -117,7 +118,7 @@ class ClientChargeRepositoryImpTest { @Test fun testClientLocalCharges_Unsuccessful() = runBlocking { val error: Response?> = - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) `when`(dataManager.clientLocalCharges()).thenReturn(error) diff --git a/app/src/test/java/org/mifos/mobile/repositories/ClientRepositoryImpTest.kt b/app/src/test/java/org/mifos/mobile/repositories/ClientRepositoryImpTest.kt index bf5cbd859..39344fdf4 100644 --- a/app/src/test/java/org/mifos/mobile/repositories/ClientRepositoryImpTest.kt +++ b/app/src/test/java/org/mifos/mobile/repositories/ClientRepositoryImpTest.kt @@ -6,6 +6,7 @@ import kotlinx.coroutines.test.resetMain import kotlinx.coroutines.test.setMain import okhttp3.Credentials import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.Assert import org.junit.Before import org.junit.Test @@ -61,7 +62,7 @@ class ClientRepositoryImpTest { fun testLoadClient_ErrorResponseReceivedFromDataManager_ReturnsError() = runBlocking{ Dispatchers.setMain(Dispatchers.Unconfined) val errorResponse: Response?> = - Response.error(404, ResponseBody.create(null,"error")) + Response.error(404, "error".toResponseBody(null)) Mockito.`when`( dataManager.clients() ).thenReturn(errorResponse) diff --git a/app/src/test/java/org/mifos/mobile/repositories/LoanRepositoryImpTest.kt b/app/src/test/java/org/mifos/mobile/repositories/LoanRepositoryImpTest.kt index 56b2461db..892137090 100644 --- a/app/src/test/java/org/mifos/mobile/repositories/LoanRepositoryImpTest.kt +++ b/app/src/test/java/org/mifos/mobile/repositories/LoanRepositoryImpTest.kt @@ -6,6 +6,7 @@ import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.resetMain import kotlinx.coroutines.test.setMain import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -63,7 +64,7 @@ class LoanRepositoryImpTest { fun testGetLoanWithAssociations_Unsuccessful() = runBlocking { Dispatchers.setMain(Dispatchers.Unconfined) val error: Response = - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) `when`( dataManager.getLoanWithAssociations( Mockito.anyString(), @@ -98,7 +99,7 @@ class LoanRepositoryImpTest { fun testWithdrawLoanAccount_Unsuccessful() = runBlocking { Dispatchers.setMain(Dispatchers.Unconfined) val error: Response = - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) `when`(dataManager.withdrawLoanAccount(1, loanWithdraw)).thenReturn(error) val result = loanRepositoryImp.withdrawLoanAccount(1, loanWithdraw) @@ -124,7 +125,7 @@ class LoanRepositoryImpTest { fun testTemplate_Unsuccessful() = runBlocking { Dispatchers.setMain(Dispatchers.Unconfined) val error: Response = - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) `when`(dataManager.loanTemplate()).thenReturn(error) val result = loanRepositoryImp.template() @@ -150,7 +151,7 @@ class LoanRepositoryImpTest { fun testGetLoanTemplateByProduct_Unsuccessful() = runBlocking { Dispatchers.setMain(Dispatchers.Unconfined) val error: Response = - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) `when`(dataManager.getLoanTemplateByProduct(1)).thenReturn(error) val result = loanRepositoryImp.getLoanTemplateByProduct(1) diff --git a/app/src/test/java/org/mifos/mobile/repositories/RecentTransactionRepositoryImpTest.kt b/app/src/test/java/org/mifos/mobile/repositories/RecentTransactionRepositoryImpTest.kt index 6795ce9ae..e85d942c8 100644 --- a/app/src/test/java/org/mifos/mobile/repositories/RecentTransactionRepositoryImpTest.kt +++ b/app/src/test/java/org/mifos/mobile/repositories/RecentTransactionRepositoryImpTest.kt @@ -4,6 +4,7 @@ import CoroutineTestRule import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.Assert import org.junit.Before import org.junit.Rule @@ -55,7 +56,7 @@ class RecentTransactionRepositoryImpTest { @Test fun recentTransaction_unsuccessful_response_from_dataManger() = runBlocking { val error: Response?> = - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) val offset = 0 val limit = 50 diff --git a/app/src/test/java/org/mifos/mobile/repositories/SavingsAccountRepositoryImpTest.kt b/app/src/test/java/org/mifos/mobile/repositories/SavingsAccountRepositoryImpTest.kt index e9ffdafc5..845e7d314 100644 --- a/app/src/test/java/org/mifos/mobile/repositories/SavingsAccountRepositoryImpTest.kt +++ b/app/src/test/java/org/mifos/mobile/repositories/SavingsAccountRepositoryImpTest.kt @@ -4,6 +4,7 @@ import CoroutineTestRule import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.Assert import org.junit.Before import org.junit.Rule @@ -67,7 +68,7 @@ class SavingsAccountRepositoryImpTest { fun testGetSavingsWithAssociations_ErrorResponseReceivedFromDataManager_ReturnsError() = runBlocking { val errorResponse: Response = - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) Mockito.`when`( dataManager.getSavingsWithAssociations(mockAccountId, mockAssociationType) ).thenReturn(errorResponse) @@ -102,7 +103,7 @@ class SavingsAccountRepositoryImpTest { fun testGetSavingsAccountApplicationTemplate_ErrorResponseFromDataManager_ReturnsError() = runBlocking { val errorResponse: Response = - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) Mockito.`when`( dataManager.getSavingAccountApplicationTemplate(mockClientId) ).thenReturn(errorResponse) @@ -140,7 +141,7 @@ class SavingsAccountRepositoryImpTest { val mockSavingsAccountApplicationPayload = Mockito.mock(SavingsAccountApplicationPayload::class.java) val errorResponse: Response = - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) Mockito.`when`( dataManager.submitSavingAccountApplication(mockSavingsAccountApplicationPayload) ).thenReturn(errorResponse) @@ -177,7 +178,7 @@ class SavingsAccountRepositoryImpTest { fun testUpdateSavingsAccount_ErrorResponseFromDataManager_ReturnsError() = runBlocking { val mockSavingsAccountUpdatePayload = Mockito.mock(SavingsAccountUpdatePayload::class.java) val errorResponse: Response = - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) Mockito.`when`( dataManager.updateSavingsAccount(mockAccountId, mockSavingsAccountUpdatePayload) ).thenReturn(errorResponse) @@ -223,7 +224,7 @@ class SavingsAccountRepositoryImpTest { val mockSavingsAccountWithdrawPayload = Mockito.mock(SavingsAccountWithdrawPayload::class.java) val errorResponse: Response = - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) Mockito.`when`( dataManager.submitWithdrawSavingsAccount( mockAccountId, @@ -259,7 +260,7 @@ class SavingsAccountRepositoryImpTest { @Test fun testLoanAccountTransferTemplate_ErrorResponseFromDataManager_ReturnsError() = runBlocking { val errorResponse: Response = - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) Mockito.`when`( dataManager.accountTransferTemplate() ).thenReturn(errorResponse) diff --git a/app/src/test/java/org/mifos/mobile/repositories/ThirdPartyTransferRepositoryImpTest.kt b/app/src/test/java/org/mifos/mobile/repositories/ThirdPartyTransferRepositoryImpTest.kt index a5ad341f5..23b2a72c2 100644 --- a/app/src/test/java/org/mifos/mobile/repositories/ThirdPartyTransferRepositoryImpTest.kt +++ b/app/src/test/java/org/mifos/mobile/repositories/ThirdPartyTransferRepositoryImpTest.kt @@ -5,6 +5,7 @@ import junit.framework.Assert.assertEquals import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.Before import org.junit.Rule import org.junit.Test @@ -52,7 +53,7 @@ class ThirdPartyTransferRepositoryImpTest { @Test fun testThirdPartyTransferTemplate_Unsuccessful() = runBlocking { val error: Response = - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) `when`(dataManager.thirdPartyTransferTemplate()).thenReturn(error) val result = transferRepositoryImp.thirdPartyTransferTemplate() @@ -76,7 +77,7 @@ class ThirdPartyTransferRepositoryImpTest { @Test fun testBeneficiaryList_Unsuccessful() = runBlocking { val error: Response?> = - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) `when`(dataManager.beneficiaryList()).thenReturn(error) diff --git a/app/src/test/java/org/mifos/mobile/repositories/TransferRepositoryImpTest.kt b/app/src/test/java/org/mifos/mobile/repositories/TransferRepositoryImpTest.kt index a0876366b..e4f5b76e5 100644 --- a/app/src/test/java/org/mifos/mobile/repositories/TransferRepositoryImpTest.kt +++ b/app/src/test/java/org/mifos/mobile/repositories/TransferRepositoryImpTest.kt @@ -5,6 +5,7 @@ import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.resetMain import kotlinx.coroutines.test.setMain import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.Assert import org.junit.Before import org.junit.Test @@ -132,7 +133,7 @@ class TransferRepositoryImpTest { @Test fun makeThirdPartyTransfer_unsuccessful() = runBlocking { Dispatchers.setMain(Dispatchers.Unconfined) - val error: Response = Response.error(404, ResponseBody.create(null, "error")) + val error: Response = Response.error(404, "error".toResponseBody(null)) val transferPayload = TransferPayload().apply { this.fromOfficeId = 1 this.fromClientId = 2 @@ -179,7 +180,7 @@ class TransferRepositoryImpTest { @Test fun makeSavingsTransfer_unsuccessful() = runBlocking { Dispatchers.setMain(Dispatchers.Unconfined) - val error: Response = Response.error(404, ResponseBody.create(null, "error")) + val error: Response = Response.error(404, "error".toResponseBody(null)) val transferPayload = TransferPayload().apply { this.fromOfficeId = 1 this.fromClientId = 2 diff --git a/app/src/test/java/org/mifos/mobile/repositories/UserAuthRepositoryImpTest.kt b/app/src/test/java/org/mifos/mobile/repositories/UserAuthRepositoryImpTest.kt index cc91c1fd8..28632fc1e 100644 --- a/app/src/test/java/org/mifos/mobile/repositories/UserAuthRepositoryImpTest.kt +++ b/app/src/test/java/org/mifos/mobile/repositories/UserAuthRepositoryImpTest.kt @@ -4,6 +4,7 @@ import CoroutineTestRule import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.Assert import org.junit.Before import org.junit.Rule @@ -79,7 +80,7 @@ class UserAuthRepositoryImpTest { fun testRegisterUser_ErrorResponseReceivedFromDataManager_ReturnsUnsuccessfulRegistration() = runBlocking { val error: Response = - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) val registerPayload = RegisterPayload().apply { this.accountNumber = "accountNumber" this.authenticationMode = "authenticationMode" @@ -131,7 +132,7 @@ class UserAuthRepositoryImpTest { this.username = "username" this.password = "password" } - val errorResponse: Response = Response.error(404, ResponseBody.create(null, "error")) + val errorResponse: Response = Response.error(404, "error".toResponseBody(null)) Mockito.`when`( dataManager.login(mockLoginPayload) ).thenReturn(errorResponse) @@ -165,7 +166,7 @@ class UserAuthRepositoryImpTest { fun testVerifyUser_ErrorResponseReceivedFromDataManager_ReturnsUnsuccessfulRegistrationVerification() = runBlocking { val errorResponse: Response = - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) Mockito.`when`( dataManager.verifyUser(userVerify) ).thenReturn(errorResponse) diff --git a/app/src/test/java/org/mifos/mobile/viewModels/BeneficiaryApplicationViewModelTest.kt b/app/src/test/java/org/mifos/mobile/viewModels/BeneficiaryApplicationViewModelTest.kt index facbb5d96..26494ce22 100644 --- a/app/src/test/java/org/mifos/mobile/viewModels/BeneficiaryApplicationViewModelTest.kt +++ b/app/src/test/java/org/mifos/mobile/viewModels/BeneficiaryApplicationViewModelTest.kt @@ -7,6 +7,7 @@ import androidx.lifecycle.Observer import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.After import org.junit.Before import org.junit.Rule @@ -75,7 +76,7 @@ class BeneficiaryApplicationViewModelTest { `when`(beneficiaryRepositoryImp.beneficiaryTemplate()).thenReturn( Response.error( 404, - ResponseBody.create(null, "error") + "error".toResponseBody(null) ) ) @@ -106,7 +107,7 @@ class BeneficiaryApplicationViewModelTest { val error = RuntimeException("Error Response") val beneficiaryPayload = mock(BeneficiaryPayload::class.java) `when`(beneficiaryRepositoryImp.createBeneficiary(beneficiaryPayload)).thenReturn( - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) ) viewModel.createBeneficiary(beneficiaryPayload) @@ -143,7 +144,7 @@ class BeneficiaryApplicationViewModelTest { beneficiaryUpdatePayload ) ).thenReturn( - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) ) viewModel.updateBeneficiary(123L, beneficiaryUpdatePayload) diff --git a/app/src/test/java/org/mifos/mobile/viewModels/BeneficiaryDetailViewModelTest.kt b/app/src/test/java/org/mifos/mobile/viewModels/BeneficiaryDetailViewModelTest.kt index 092d2d153..3e7754a21 100644 --- a/app/src/test/java/org/mifos/mobile/viewModels/BeneficiaryDetailViewModelTest.kt +++ b/app/src/test/java/org/mifos/mobile/viewModels/BeneficiaryDetailViewModelTest.kt @@ -7,6 +7,7 @@ import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.resetMain import kotlinx.coroutines.test.setMain import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.After import org.junit.Before import org.junit.Rule @@ -72,7 +73,7 @@ class BeneficiaryDetailViewModelTest { `when`(beneficiaryRepositoryImp.deleteBeneficiary(123L)).thenReturn( Response.error( 404, - ResponseBody.create(null, "error") + "error".toResponseBody(null) ) ) diff --git a/app/src/test/java/org/mifos/mobile/viewModels/BeneficiaryListViewModelTest.kt b/app/src/test/java/org/mifos/mobile/viewModels/BeneficiaryListViewModelTest.kt index a398fd525..6d3ca6f48 100644 --- a/app/src/test/java/org/mifos/mobile/viewModels/BeneficiaryListViewModelTest.kt +++ b/app/src/test/java/org/mifos/mobile/viewModels/BeneficiaryListViewModelTest.kt @@ -6,6 +6,7 @@ import androidx.lifecycle.Observer import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.After import org.junit.Before import org.junit.Rule @@ -72,7 +73,7 @@ class BeneficiaryListViewModelTest { `when`(beneficiaryRepositoryImp.beneficiaryList()).thenReturn( Response.error( 404, - ResponseBody.create(null, "error") + "error".toResponseBody(null) ) ) diff --git a/app/src/test/java/org/mifos/mobile/viewModels/ClientChargeViewModelTest.kt b/app/src/test/java/org/mifos/mobile/viewModels/ClientChargeViewModelTest.kt index 9d97ee567..e4de08305 100644 --- a/app/src/test/java/org/mifos/mobile/viewModels/ClientChargeViewModelTest.kt +++ b/app/src/test/java/org/mifos/mobile/viewModels/ClientChargeViewModelTest.kt @@ -6,6 +6,7 @@ import androidx.lifecycle.Observer import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.After import org.junit.Before import org.junit.Rule @@ -79,7 +80,7 @@ class ClientChargeViewModelTest { val throwable = Throwable("Error occurred") `when`(clientChargeRepositoryImp.getClientCharges(123L)).thenReturn( - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) ) viewModel.loadClientCharges(123L) @@ -113,7 +114,7 @@ class ClientChargeViewModelTest { val throwable = Throwable("Error occurred") `when`(clientChargeRepositoryImp.getLoanCharges(123L)).thenReturn( - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) ) viewModel.loadLoanAccountCharges(123L) @@ -147,7 +148,7 @@ class ClientChargeViewModelTest { val throwable = Throwable("Error occurred") `when`(clientChargeRepositoryImp.getSavingsCharges(123L)).thenReturn( - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) ) viewModel.loadSavingsAccountCharges(123L) @@ -189,7 +190,7 @@ class ClientChargeViewModelTest { val throwable = Throwable("Error occurred") `when`(clientChargeRepositoryImp.clientLocalCharges()).thenReturn( - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) ) viewModel.loadClientLocalCharges() diff --git a/app/src/test/java/org/mifos/mobile/viewModels/LoanAccountTransactionViewModelTest.kt b/app/src/test/java/org/mifos/mobile/viewModels/LoanAccountTransactionViewModelTest.kt index 1a2a19c94..7fa342fe3 100644 --- a/app/src/test/java/org/mifos/mobile/viewModels/LoanAccountTransactionViewModelTest.kt +++ b/app/src/test/java/org/mifos/mobile/viewModels/LoanAccountTransactionViewModelTest.kt @@ -7,6 +7,7 @@ import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.resetMain import kotlinx.coroutines.test.setMain import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.After import org.junit.Before import org.junit.Rule @@ -96,7 +97,7 @@ class LoanAccountTransactionViewModelTest { Constants.TRANSACTIONS, 1 ) - ).thenReturn(Response.error(404, ResponseBody.create(null, "error"))) + ).thenReturn(Response.error(404, "error".toResponseBody(null))) viewModel.loadLoanAccountDetails(1) verify(loanUiStateObserver).onChanged(LoanUiState.Loading) diff --git a/app/src/test/java/org/mifos/mobile/viewModels/LoanAccountWithdrawViewModelTest.kt b/app/src/test/java/org/mifos/mobile/viewModels/LoanAccountWithdrawViewModelTest.kt index 7baf7b0cf..53a4121d6 100644 --- a/app/src/test/java/org/mifos/mobile/viewModels/LoanAccountWithdrawViewModelTest.kt +++ b/app/src/test/java/org/mifos/mobile/viewModels/LoanAccountWithdrawViewModelTest.kt @@ -7,6 +7,7 @@ import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.resetMain import kotlinx.coroutines.test.setMain import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.After import org.junit.Before import org.junit.Rule @@ -75,7 +76,7 @@ class LoanAccountWithdrawViewModelTest { 1, mockLoanWithdraw ) - ).thenReturn(Response.error(404, ResponseBody.create(null, "error"))) + ).thenReturn(Response.error(404, "error".toResponseBody(null))) viewModel.withdrawLoanAccount(1, mockLoanWithdraw) verify(loanUiStateObserver).onChanged(LoanUiState.Loading) verify(loanUiStateObserver).onChanged(LoanUiState.ShowError(R.string.error_loan_account_withdraw)) diff --git a/app/src/test/java/org/mifos/mobile/viewModels/LoanAccountsDetailViewModelTest.kt b/app/src/test/java/org/mifos/mobile/viewModels/LoanAccountsDetailViewModelTest.kt index b8b3bc5e6..9cb92d515 100644 --- a/app/src/test/java/org/mifos/mobile/viewModels/LoanAccountsDetailViewModelTest.kt +++ b/app/src/test/java/org/mifos/mobile/viewModels/LoanAccountsDetailViewModelTest.kt @@ -7,6 +7,7 @@ import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.resetMain import kotlinx.coroutines.test.setMain import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.After import org.junit.Before import org.junit.Rule @@ -77,7 +78,7 @@ class LoanAccountsDetailViewModelTest { Constants.REPAYMENT_SCHEDULE, 1 ) - ).thenReturn(Response.error(404, ResponseBody.create(null, "error"))) + ).thenReturn(Response.error(404, "error".toResponseBody(null))) viewModel.loadLoanAccountDetails(1) verify(loanUiStateObserver).onChanged(LoanUiState.Loading) diff --git a/app/src/test/java/org/mifos/mobile/viewModels/LoanApplicationViewModelTest.kt b/app/src/test/java/org/mifos/mobile/viewModels/LoanApplicationViewModelTest.kt index 3075b4ebc..27183fd37 100644 --- a/app/src/test/java/org/mifos/mobile/viewModels/LoanApplicationViewModelTest.kt +++ b/app/src/test/java/org/mifos/mobile/viewModels/LoanApplicationViewModelTest.kt @@ -7,6 +7,7 @@ import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.resetMain import kotlinx.coroutines.test.setMain import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.After import org.junit.Before import org.junit.Rule @@ -79,7 +80,7 @@ class LoanApplicationViewModelTest { `when`(loanRepositoryImp.template()).thenReturn( Response.error( 404, - ResponseBody.create(null, "error") + "error".toResponseBody(null) ) ) viewModel.loadLoanApplicationTemplate(loanState) @@ -120,7 +121,7 @@ class LoanApplicationViewModelTest { `when`(loanRepositoryImp.getLoanTemplateByProduct(1)).thenReturn( Response.error( 404, - ResponseBody.create(null, "error") + "error".toResponseBody(null) ) ) viewModel.loadLoanApplicationTemplateByProduct(1, mockLoanState) diff --git a/app/src/test/java/org/mifos/mobile/viewModels/LoanRepaymentScheduleViewModelTest.kt b/app/src/test/java/org/mifos/mobile/viewModels/LoanRepaymentScheduleViewModelTest.kt index 56eb2f698..15a24d174 100644 --- a/app/src/test/java/org/mifos/mobile/viewModels/LoanRepaymentScheduleViewModelTest.kt +++ b/app/src/test/java/org/mifos/mobile/viewModels/LoanRepaymentScheduleViewModelTest.kt @@ -7,6 +7,7 @@ import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.resetMain import kotlinx.coroutines.test.setMain import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.After import org.junit.Before import org.junit.Rule @@ -81,7 +82,7 @@ class LoanRepaymentScheduleViewModelTest { 1 ) ).thenReturn( - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) ) viewModel.loanLoanWithAssociations(1) verify(loanUiStateObserver).onChanged(LoanUiState.Loading) diff --git a/app/src/test/java/org/mifos/mobile/viewModels/LoginViewModelTest.kt b/app/src/test/java/org/mifos/mobile/viewModels/LoginViewModelTest.kt index 77526baf9..d88a1d412 100644 --- a/app/src/test/java/org/mifos/mobile/viewModels/LoginViewModelTest.kt +++ b/app/src/test/java/org/mifos/mobile/viewModels/LoginViewModelTest.kt @@ -7,6 +7,7 @@ import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.resetMain import kotlinx.coroutines.test.setMain import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.* import org.junit.runner.RunWith import org.mifos.mobile.FakeRemoteDataSource @@ -126,7 +127,7 @@ class LoginViewModelTest { Dispatchers.setMain(Dispatchers.Unconfined) Mockito.`when`( userAuthRepositoryImp.login(Mockito.anyString(), Mockito.anyString()) - ).thenReturn(Response.error(404, ResponseBody.create(null, "error"))) + ).thenReturn(Response.error(404, "error".toResponseBody(null))) loginViewModel.login("username", "password") @@ -141,7 +142,7 @@ class LoginViewModelTest { Dispatchers.setMain(Dispatchers.Unconfined) Mockito.`when`( clientRepositoryImp.loadClient() - ).thenReturn(Response.error(404, ResponseBody.create(null, "error"))) + ).thenReturn(Response.error(404, "error".toResponseBody(null))) loginViewModel.loadClient() @@ -157,7 +158,7 @@ class LoginViewModelTest { Dispatchers.setMain(Dispatchers.Unconfined) Mockito.`when`( clientRepositoryImp.loadClient() - ).thenReturn(Response.error(404, ResponseBody.create(null, "error"))) + ).thenReturn(Response.error(404, "error".toResponseBody(null))) loginViewModel.loadClient() diff --git a/app/src/test/java/org/mifos/mobile/viewModels/RecentTransactionViewModelTest.kt b/app/src/test/java/org/mifos/mobile/viewModels/RecentTransactionViewModelTest.kt index 0ce537153..330709b51 100644 --- a/app/src/test/java/org/mifos/mobile/viewModels/RecentTransactionViewModelTest.kt +++ b/app/src/test/java/org/mifos/mobile/viewModels/RecentTransactionViewModelTest.kt @@ -6,6 +6,7 @@ import androidx.lifecycle.Observer import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.* import org.junit.runner.RunWith import org.mifos.mobile.R @@ -151,7 +152,7 @@ class RecentTransactionViewModelTest { @Test fun loadRecentTransaction_unsuccessful() = runBlocking { `when`(recentTransactionRepositoryImp.recentTransactions(anyInt(), anyInt())).thenReturn( - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) ) viewModel.loadRecentTransactions(false, 0) diff --git a/app/src/test/java/org/mifos/mobile/viewModels/RegistrationViewModelTest.kt b/app/src/test/java/org/mifos/mobile/viewModels/RegistrationViewModelTest.kt index 47db01413..2901041ec 100644 --- a/app/src/test/java/org/mifos/mobile/viewModels/RegistrationViewModelTest.kt +++ b/app/src/test/java/org/mifos/mobile/viewModels/RegistrationViewModelTest.kt @@ -6,6 +6,7 @@ import androidx.lifecycle.Observer import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.* import org.junit.runner.RunWith import org.mifos.mobile.repositories.UserAuthRepository @@ -161,7 +162,7 @@ class RegistrationViewModelTest { Mockito.anyString(), Mockito.anyString() ) - ).thenReturn(Response.error(404, ResponseBody.create(null, "error"))) + ).thenReturn(Response.error(404, "error".toResponseBody(null))) registrationViewModel.registerUser( "accountNumber", @@ -201,7 +202,7 @@ class RegistrationViewModelTest { runBlocking { Mockito.`when`( userAuthRepositoryImp.verifyUser(Mockito.anyString(), Mockito.anyString()) - ).thenReturn(Response.error(404, ResponseBody.create(null, "error"))) + ).thenReturn(Response.error(404, "error".toResponseBody(null))) registrationViewModel.verifyUser("authenticationToken", "requestId") diff --git a/app/src/test/java/org/mifos/mobile/viewModels/SavingAccountsDetailViewModelTest.kt b/app/src/test/java/org/mifos/mobile/viewModels/SavingAccountsDetailViewModelTest.kt index 934384797..68c3f0a7b 100644 --- a/app/src/test/java/org/mifos/mobile/viewModels/SavingAccountsDetailViewModelTest.kt +++ b/app/src/test/java/org/mifos/mobile/viewModels/SavingAccountsDetailViewModelTest.kt @@ -6,6 +6,7 @@ import androidx.lifecycle.Observer import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.After import org.junit.Before import org.junit.Rule @@ -85,7 +86,7 @@ class SavingAccountsDetailViewModelTest { mockAccountId, mockAssociationType ) - ).thenReturn(Response.error(404, ResponseBody.create(null, "error"))) + ).thenReturn(Response.error(404, "error".toResponseBody(null))) savingAccountsDetailViewModel.loadSavingsWithAssociations(mockAccountId) diff --git a/app/src/test/java/org/mifos/mobile/viewModels/SavingAccountsTransactionViewModelTest.kt b/app/src/test/java/org/mifos/mobile/viewModels/SavingAccountsTransactionViewModelTest.kt index 02008a18f..c96b49c3c 100644 --- a/app/src/test/java/org/mifos/mobile/viewModels/SavingAccountsTransactionViewModelTest.kt +++ b/app/src/test/java/org/mifos/mobile/viewModels/SavingAccountsTransactionViewModelTest.kt @@ -6,6 +6,7 @@ import androidx.lifecycle.Observer import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.After import org.junit.Before import org.junit.Rule @@ -86,7 +87,7 @@ class SavingAccountsTransactionViewModelTest { mockAccountId, mockAssociationType ) - ).thenReturn(Response.error(404, ResponseBody.create(null, "error"))) + ).thenReturn(Response.error(404, "error".toResponseBody(null))) savingAccountsTransactionViewModel.loadSavingsWithAssociations(mockAccountId) Mockito.verify(savingAccountsTransactionUiStateObserver) diff --git a/app/src/test/java/org/mifos/mobile/viewModels/SavingsAccountApplicationViewModelTest.kt b/app/src/test/java/org/mifos/mobile/viewModels/SavingsAccountApplicationViewModelTest.kt index 280c3c2de..70d965334 100644 --- a/app/src/test/java/org/mifos/mobile/viewModels/SavingsAccountApplicationViewModelTest.kt +++ b/app/src/test/java/org/mifos/mobile/viewModels/SavingsAccountApplicationViewModelTest.kt @@ -6,6 +6,7 @@ import androidx.lifecycle.Observer import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.After import org.junit.Before import org.junit.Rule @@ -107,7 +108,7 @@ class SavingsAccountApplicationViewModelTest { val mockState = SavingsAccountState.UPDATE Mockito.`when`( savingsAccountRepositoryImp.getSavingAccountApplicationTemplate(mockClientId) - ).thenReturn(Response.error(404, ResponseBody.create(null, "error"))) + ).thenReturn(Response.error(404, "error".toResponseBody(null))) savingsAccountApplicationViewModel.loadSavingsAccountApplicationTemplate( mockClientId, @@ -152,7 +153,7 @@ class SavingsAccountApplicationViewModelTest { savingsAccountRepositoryImp.submitSavingAccountApplication( mockSavingsAccountApplicationPayload ) - ).thenReturn(Response.error(404, ResponseBody.create(null, "error"))) + ).thenReturn(Response.error(404, "error".toResponseBody(null))) savingsAccountApplicationViewModel.submitSavingsAccountApplication( mockSavingsAccountApplicationPayload @@ -175,7 +176,7 @@ class SavingsAccountApplicationViewModelTest { savingsAccountRepositoryImp.submitSavingAccountApplication( mockSavingsAccountApplicationPayload ) - ).thenReturn(Response.error(404, ResponseBody.create(null, "error"))) + ).thenReturn(Response.error(404, "error".toResponseBody(null))) savingsAccountApplicationViewModel.submitSavingsAccountApplication( mockSavingsAccountApplicationPayload @@ -220,7 +221,7 @@ class SavingsAccountApplicationViewModelTest { mockAccountId, mockSavingsAccountUpdatePayload ) - ).thenReturn(Response.error(404, ResponseBody.create(null, "error"))) + ).thenReturn(Response.error(404, "error".toResponseBody(null))) savingsAccountApplicationViewModel.updateSavingsAccount( mockAccountId, @@ -243,7 +244,7 @@ class SavingsAccountApplicationViewModelTest { mockAccountId, mockSavingsAccountUpdatePayload ) - ).thenReturn(Response.error(404, ResponseBody.create(null, "error"))) + ).thenReturn(Response.error(404, "error".toResponseBody(null))) savingsAccountApplicationViewModel.updateSavingsAccount( mockAccountId, diff --git a/app/src/test/java/org/mifos/mobile/viewModels/SavingsAccountWithdrawViewModelTest.kt b/app/src/test/java/org/mifos/mobile/viewModels/SavingsAccountWithdrawViewModelTest.kt index 6e847ee8f..400a6f770 100644 --- a/app/src/test/java/org/mifos/mobile/viewModels/SavingsAccountWithdrawViewModelTest.kt +++ b/app/src/test/java/org/mifos/mobile/viewModels/SavingsAccountWithdrawViewModelTest.kt @@ -6,6 +6,7 @@ import androidx.lifecycle.Observer import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.After import org.junit.Before import org.junit.Rule @@ -89,7 +90,7 @@ class SavingsAccountWithdrawViewModelTest { mockAccountId, mockSavingsAccountWithdrawPayload ) - ).thenReturn(Response.error(404, ResponseBody.create(null, "error"))) + ).thenReturn(Response.error(404, "error".toResponseBody(null))) savingsAccountWithdrawViewModel.submitWithdrawSavingsAccount( mockAccountId, diff --git a/app/src/test/java/org/mifos/mobile/viewModels/SavingsMakeTransferViewModelTest.kt b/app/src/test/java/org/mifos/mobile/viewModels/SavingsMakeTransferViewModelTest.kt index 66c56976a..ecb641671 100644 --- a/app/src/test/java/org/mifos/mobile/viewModels/SavingsMakeTransferViewModelTest.kt +++ b/app/src/test/java/org/mifos/mobile/viewModels/SavingsMakeTransferViewModelTest.kt @@ -6,6 +6,7 @@ import androidx.lifecycle.Observer import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.After import org.junit.Before import org.junit.Rule @@ -76,7 +77,7 @@ class SavingsMakeTransferViewModelTest { val errorResponse = RuntimeException("Loading Failed") Mockito.`when`( savingsAccountRepositoryImp.loanAccountTransferTemplate() - ).thenReturn(Response.error(404, ResponseBody.create(null, "error"))) + ).thenReturn(Response.error(404, "error".toResponseBody(null))) savingsMakeTransferViewModel.loanAccountTransferTemplate() diff --git a/app/src/test/java/org/mifos/mobile/viewModels/ThirdPartyTransferViewModelTest.kt b/app/src/test/java/org/mifos/mobile/viewModels/ThirdPartyTransferViewModelTest.kt index 9d234c9d6..9616d9bdd 100644 --- a/app/src/test/java/org/mifos/mobile/viewModels/ThirdPartyTransferViewModelTest.kt +++ b/app/src/test/java/org/mifos/mobile/viewModels/ThirdPartyTransferViewModelTest.kt @@ -7,6 +7,7 @@ import junit.framework.Assert.assertEquals import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.After import org.junit.Assert.assertNotEquals import org.junit.Before @@ -86,10 +87,10 @@ class ThirdPartyTransferViewModelTest { fun testLoadTransferTemplate_Unsuccessful() = runBlocking { val errorMessage = R.string.error_fetching_third_party_transfer_template `when`(thirdPartyTransferRepositoryImp.thirdPartyTransferTemplate()).thenReturn( - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) ) `when`(thirdPartyTransferRepositoryImp.beneficiaryList()).thenReturn( - Response.error(404, ResponseBody.create(null, "error")) + Response.error(404, "error".toResponseBody(null)) ) thirdPartyTransferViewModel.loadTransferTemplate() diff --git a/app/src/test/java/org/mifos/mobile/viewModels/TransferProcessViewModelTest.kt b/app/src/test/java/org/mifos/mobile/viewModels/TransferProcessViewModelTest.kt index 9f6b5a270..a5c4ff925 100644 --- a/app/src/test/java/org/mifos/mobile/viewModels/TransferProcessViewModelTest.kt +++ b/app/src/test/java/org/mifos/mobile/viewModels/TransferProcessViewModelTest.kt @@ -7,6 +7,7 @@ import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.resetMain import kotlinx.coroutines.test.setMain import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.After import org.junit.Before import org.junit.Rule @@ -86,7 +87,7 @@ class TransferProcessViewModelTest { "dd MMMM yyyy", "en", "0000001", "0000002", TransferType.SELF ) - ).thenReturn(Response.error(404, ResponseBody.create(null, "error"))) + ).thenReturn(Response.error(404, "error".toResponseBody(null))) viewModel.makeTransfer( 1, 2, 3, diff --git a/app/src/test/java/org/mifos/mobile/viewModels/UpdatePasswordViewModelTest.kt b/app/src/test/java/org/mifos/mobile/viewModels/UpdatePasswordViewModelTest.kt index 203f8516c..5a6647cec 100644 --- a/app/src/test/java/org/mifos/mobile/viewModels/UpdatePasswordViewModelTest.kt +++ b/app/src/test/java/org/mifos/mobile/viewModels/UpdatePasswordViewModelTest.kt @@ -6,6 +6,7 @@ import androidx.lifecycle.Observer import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import okhttp3.ResponseBody +import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.* import org.junit.runner.RunWith import org.mifos.mobile.repositories.ClientRepository @@ -105,7 +106,7 @@ class UpdatePasswordViewModelTest { fun testUpdateAccountPassword_ErrorReceivedFromRepository_ReturnsError() = runBlocking { Mockito.`when`( userAuthRepositoryImp.updateAccountPassword(Mockito.anyString(), Mockito.anyString()) - ).thenReturn(Response.error(404, ResponseBody.create(null, "error"))) + ).thenReturn(Response.error(404, "error".toResponseBody(null))) updatePasswordViewModel.updateAccountPassword("newPassword", "newPassword") diff --git a/build.gradle b/build.gradle index 31a15880c..0ce804129 100644 --- a/build.gradle +++ b/build.gradle @@ -56,23 +56,23 @@ ext { countryCodePicker = '2.7.2' supportLibraryVersion = '1.4.2' designLibraryVersion = '1.9.0' - recyclerViewVersion = '1.2.1' + recyclerViewVersion = '1.3.1' vectorDrawablesVersion = '1.1.0' lifecycleVersion = '2.4.1' lifecycleExtensionsVersion = '2.2.0' retrofitVersion = '2.9.0' coroutinesTest = '1.7.3' - okHttp3Version = '3.14.9' + okHttp3Version = '4.11.0' butterKnifeVersion = '8.0.1' dbflowVersion = '4.2.4' - playServicesVersion = '17.0.1' + playServicesVersion = '18.1.0' firebaseMessagingVersion = '21.1.0' - oss_licenses = '17.0.0' + oss_licenses = '17.0.1' kotlinVersion = '1.6.10' tableViewVersion = '0.8.9.4' biometric = '1.1.0' archCoreVersion = '2.2.0' - coroutines = '1.6.4' + coroutines = '1.7.3' jUnitVersion = '4.13.2' mockitoVersion = '5.4.0' runnerVersion = '1.6.0-alpha04' @@ -87,12 +87,12 @@ ext { cropviewVersion = '1.1.8' multiDexVersion = '2.0.1' annotationLibraryVersion ='1.1.0' - firebaseCrashlyticsVersion = '18.4.1' + firebaseCrashlyticsVersion = '18.4.3' activity_version = '1.5.0' - fragment_version = '1.5.0' + fragment_version = '1.6.1' composeVersion = '1.6.0-alpha05' - composeCompiler = '1.3.2' + composeCompiler = '1.5.3' composeActivity = '1.7.2' - materialVersion = '1.1.0' - lifecycleVersion = '2.6.1' + materialVersion = '1.1.2' + lifecycleVersion = '2.6.2' }