Skip to content

Commit

Permalink
update sdk
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo <[email protected]>
  • Loading branch information
Balcan committed Mar 7, 2024
1 parent 04a8dad commit 28e4283
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ class SyncIsPerformedInteractor(private val userManager: UserManager?) {
val serverUrl = userManager.d2.systemInfoModule().systemInfo().blockingGet()?.contextPath()
val username = userManager.d2.userModule().user().blockingGet()?.username()

val dataBaseIsImport = userManager.d2.userModule().accountManager()
.getAccounts()
.any {
val dataBaseIsImport = userManager.d2.userModule().accountManager().getCurrentAccount()
?.let {
it.serverUrl() == serverUrl && it.username() == username && it.importDB() != null
}
} ?: false

return when {
dataBaseIsImport -> true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package org.dhis2.usescases.login

import org.dhis2.data.server.UserManager
import org.dhis2.usescases.sync.WAS_INITIAL_SYNC_DONE
import org.hisp.dhis.android.core.configuration.internal.DatabaseAccount
import org.hisp.dhis.android.core.systeminfo.SystemInfo
import org.hisp.dhis.android.core.user.User
import org.junit.Before
import org.junit.Test
import org.mockito.Mockito
Expand Down Expand Up @@ -30,9 +33,57 @@ class SyncIsPerformedInteractorTest {
userManager.d2.dataStoreModule().localDataStore().value(WAS_INITIAL_SYNC_DONE)
.blockingExists(),
) doReturn false
whenever(
userManager.d2.userModule().accountManager().getCurrentAccount(),
)doReturn null

val result = interactor.execute()

assert(!result)
}

@Test
fun `Should check if import exists on datastore module`() {
val serverUrl = "https://play.dhis2.org/40"
val userName = "pepe"

whenever(userManager.d2.dataStoreModule().localDataStore()) doReturn mock()
whenever(
userManager.d2.dataStoreModule().localDataStore().value(WAS_INITIAL_SYNC_DONE),
) doReturn mock()
whenever(
userManager.d2.dataStoreModule().localDataStore().value(WAS_INITIAL_SYNC_DONE)
.blockingExists(),
) doReturn false

val mockedSystemInfo: SystemInfo = mock {
on { contextPath() } doReturn serverUrl
}

val mockedUser: User = mock {
on { username() } doReturn userName
}

whenever(
userManager.d2.userModule().user().blockingGet(),
)doReturn mockedUser

whenever(
userManager.d2.systemInfoModule().systemInfo().blockingGet(),
)doReturn mockedSystemInfo

val mockedAccount: DatabaseAccount = mock() {
on { serverUrl() } doReturn serverUrl
on { username() } doReturn userName
on { importDB() } doReturn mock()
}

whenever(
userManager.d2.userModule().accountManager().getCurrentAccount(),
)doReturn mockedAccount

val result = interactor.execute()

assert(result)
}
}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ hilt = '2.47'
hiltCompiler = '1.0.0'
jacoco = '0.8.10'
designSystem = "0.2-20240222.160714-31"
dhis2sdk = "1.10.0-20240219.122222-17"
dhis2sdk = "1.10.0-20240307.130705-33"
ruleEngine = "3.0.0-20240119.134348-12"
expressionParser = "1.1.0-20240219.115041-14"
appcompat = "1.6.1"
Expand Down

0 comments on commit 28e4283

Please sign in to comment.