Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Android Studio 3.4
- override fun loginUserPost(username: String, password: String, uniqueIdentifier: String, deviceToken: String, apiToken: String) : Single<LoginResponse> {
- val loginRequestEntity = LoginRequestEntity(username, password, uniqueIdentifier, deviceToken)
- return loginAPIService.loginUserPost(loginRequestEntity, apiToken)
- .map {
- loginResponseDomainMapper.map(it)
- }
- }
- @Test
- fun `should return LoginResponse`() {
- val loginRequestEntity = LoginRequestEntity("username", "password", "uniqueidentifier", "devicetoken")
- val loginResponse = LoginResponse("token", createUser(), emptyList(), emptyList())
- val loginResponseEntity = LoginResponseEntity("token", createUserEntity(), emptyList(), emptyList())
- whenever(loginAPIService.loginUserPost(loginRequestEntity, "apitoken")).thenReturn(Single.just(loginResponseEntity))
- whenever(loginAPIService.loginUserPost(loginRequestEntity, "apitoken").map {
- loginResponseDomainMapper.map(it)
- }).thenReturn(Single.just(loginResponse))
- loginServiceImp.loginUserPost("username", "password", "uniqueidentifier", "devicetoken", "apitoken")
- verify(loginAPIService).loginUserPost(loginRequestEntity, "apitoken")
- }
- private fun createUser() =
- User(
- "id",
- "email",
- "firstname",
- "lastname",
- "phone",
- "address",
- "dob",
- "customer",
- listOf("enterpriseids"),
- listOf("vendorids"))
- private fun createUserEntity() =
- UserEntity(
- "id",
- "email",
- "firstname",
- "lastname",
- "phone",
- "address",
- "dob",
- "customer",
- listOf("enterpriseids"),
- listOf("vendorids"))
- }
Add Comment
Please, Sign In to add comment