-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from alexandr7035/develop
Add mock flavor
- Loading branch information
Showing
12 changed files
with
409 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
data/src/main/java/by/alexandr7035/data/repository_mock/ChangeProfileRepositoryMock.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package by.alexandr7035.data.repository_mock | ||
|
||
import by.alexandr7035.affinidi_id.domain.core.ErrorType | ||
import by.alexandr7035.affinidi_id.domain.model.profile.change_password.ChangePasswordReqModel | ||
import by.alexandr7035.affinidi_id.domain.model.profile.change_password.ChangePasswordResModel | ||
import by.alexandr7035.affinidi_id.domain.repository.ChangeProfileRepository | ||
import kotlinx.coroutines.delay | ||
|
||
class ChangeProfileRepositoryMock : ChangeProfileRepository { | ||
override suspend fun changePassword(changePasswordReqModel: ChangePasswordReqModel): ChangePasswordResModel { | ||
delay(MockConstants.MOCK_REQ_DELAY_MILLS) | ||
|
||
return if (changePasswordReqModel.oldPassword == MockConstants.MOCK_PASSWORD) { | ||
ChangePasswordResModel.Success | ||
} else { | ||
ChangePasswordResModel.Fail(ErrorType.WRONG_CURRENT_PASSWORD) | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
data/src/main/java/by/alexandr7035/data/repository_mock/IssueCredentialsRepositoryMock.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package by.alexandr7035.data.repository_mock | ||
|
||
import by.alexandr7035.affinidi_id.domain.core.ErrorType | ||
import by.alexandr7035.affinidi_id.domain.model.credentials.issue_vc.IssueCredentialReqModel | ||
import by.alexandr7035.affinidi_id.domain.model.credentials.issue_vc.IssueCredentialResModel | ||
import by.alexandr7035.affinidi_id.domain.repository.IssueCredentialsRepository | ||
import kotlinx.coroutines.delay | ||
|
||
class IssueCredentialsRepositoryMock: IssueCredentialsRepository { | ||
override suspend fun issueCredential(issueCredentialReqModel: IssueCredentialReqModel): IssueCredentialResModel { | ||
delay(MockConstants.MOCK_REQ_DELAY_MILLS) | ||
return IssueCredentialResModel.Fail(ErrorType.ALREADY_HAVE_CREDENTIAL) | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
data/src/main/java/by/alexandr7035/data/repository_mock/LoginRepositoryMock.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package by.alexandr7035.data.repository_mock | ||
|
||
import by.alexandr7035.affinidi_id.domain.core.ErrorType | ||
import by.alexandr7035.affinidi_id.domain.core.GenericRes | ||
import by.alexandr7035.affinidi_id.domain.model.login.AuthCredentials | ||
import by.alexandr7035.affinidi_id.domain.model.login.LogOutModel | ||
import by.alexandr7035.affinidi_id.domain.repository.AppSettings | ||
import by.alexandr7035.affinidi_id.domain.repository.LoginRepository | ||
import kotlinx.coroutines.delay | ||
|
||
class LoginRepositoryMock( | ||
private val appSettings: AppSettings | ||
): LoginRepository { | ||
override suspend fun signIn(userName: String, password: String): GenericRes<Unit> { | ||
delay(MockConstants.MOCK_REQ_DELAY_MILLS) | ||
|
||
return if (userName == MockConstants.MOCK_LOGIN && password == MockConstants.MOCK_PASSWORD) { | ||
appSettings.setAuthCredentials( | ||
AuthCredentials( | ||
userDid = MockConstants.MOCK_DID, | ||
userEmail = MockConstants.MOCK_LOGIN, | ||
accessToken = "access_token_mock", | ||
refreshToken = "refresh_token_mock", | ||
accessTokenObtained = System.currentTimeMillis() | ||
) | ||
) | ||
|
||
GenericRes.Success(Unit) | ||
} else { | ||
GenericRes.Fail(ErrorType.WRONG_USERNAME_OR_PASSWORD) | ||
} | ||
} | ||
|
||
override suspend fun signInWithRefreshToken(): GenericRes<Unit> { | ||
delay(MockConstants.MOCK_REQ_DELAY_MILLS) | ||
|
||
appSettings.updateAuthCredentials( | ||
accessToken = "access_token_mock", | ||
accessTokenRefreshedDate = System.currentTimeMillis() | ||
) | ||
|
||
return GenericRes.Success(Unit) | ||
} | ||
|
||
override suspend fun logOut(): LogOutModel { | ||
delay(MockConstants.MOCK_REQ_DELAY_MILLS) | ||
|
||
appSettings.clearSettings() | ||
return LogOutModel.Success | ||
} | ||
} |
Oops, something went wrong.