Open zonder129 opened 5 years ago
For example in MockRequestBuilder a build() method sets user field of appRequest and creates aogRequest out of it:
build()
user
... if (userStorage != null) { user.userStorage = gson.toJson(userStorage) } appRequest.user = user ... val aogRequest = AogRequest(appRequest) ...
But inside internal constructor of AogRequest userStorage field is not set at all, only user.userStorage does:
userStorage
user.userStorage
internal class AogRequest internal constructor( override val appRequest: AppRequest) : ActionRequest { ... override var userStorage: MutableMap<String, Any> = HashMap() ... override val user: User? get() = appRequest.user ... }
So, if we try in a test to set this userStorage, the field will be empty:
@Test fun userStorageTest() { val actionRequest = MockRequestBuilder() .setUserStorage(mapOf(Pair("userId", "someId"))) .build() println("userStorage = ${actionRequest.userStorage}") println("user.userStorage = ${actionRequest.user?.userStorage}") }
the output will be:
userStorage = {} user.userStorage = {"userId":"someId"}
For example in MockRequestBuilder a
build()
method setsuser
field of appRequest and creates aogRequest out of it:But inside internal constructor of AogRequest
userStorage
field is not set at all, onlyuser.userStorage
does:So, if we try in a test to set this userStorage, the field will be empty:
the output will be: