Guest User

Untitled

a guest
Dec 27th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. Android Studio 3.4
  2.  
  3. override fun loginUserPost(username: String, password: String, uniqueIdentifier: String, deviceToken: String, apiToken: String) : Single<LoginResponse> {
  4. val loginRequestEntity = LoginRequestEntity(username, password, uniqueIdentifier, deviceToken)
  5. return loginAPIService.loginUserPost(loginRequestEntity, apiToken)
  6. .map {
  7. loginResponseDomainMapper.map(it)
  8. }
  9. }
  10.  
  11. @Test
  12. fun `should return LoginResponse`() {
  13. val loginRequestEntity = LoginRequestEntity("username", "password", "uniqueidentifier", "devicetoken")
  14. val loginResponse = LoginResponse("token", createUser(), emptyList(), emptyList())
  15. val loginResponseEntity = LoginResponseEntity("token", createUserEntity(), emptyList(), emptyList())
  16.  
  17. whenever(loginAPIService.loginUserPost(loginRequestEntity, "apitoken")).thenReturn(Single.just(loginResponseEntity))
  18. whenever(loginAPIService.loginUserPost(loginRequestEntity, "apitoken").map {
  19. loginResponseDomainMapper.map(it)
  20. }).thenReturn(Single.just(loginResponse))
  21.  
  22. loginServiceImp.loginUserPost("username", "password", "uniqueidentifier", "devicetoken", "apitoken")
  23.  
  24. verify(loginAPIService).loginUserPost(loginRequestEntity, "apitoken")
  25. }
  26.  
  27. private fun createUser() =
  28. User(
  29. "id",
  30. "email",
  31. "firstname",
  32. "lastname",
  33. "phone",
  34. "address",
  35. "dob",
  36. "customer",
  37. listOf("enterpriseids"),
  38. listOf("vendorids"))
  39.  
  40. private fun createUserEntity() =
  41. UserEntity(
  42. "id",
  43. "email",
  44. "firstname",
  45. "lastname",
  46. "phone",
  47. "address",
  48. "dob",
  49. "customer",
  50. listOf("enterpriseids"),
  51. listOf("vendorids"))
  52. }
Add Comment
Please, Sign In to add comment