pp.amorim
07/22/2020, 8:10 PMTobias Berger
07/22/2020, 8:58 PMpp.amorim
07/22/2020, 9:08 PMpp.amorim
07/22/2020, 9:09 PMRealmList
is AbstractList<E>
and written in Javapp.amorim
07/22/2020, 9:10 PMforEach
function, it points to the forEach
from Kotlin.pp.amorim
07/22/2020, 9:12 PMpp.amorim
07/22/2020, 9:18 PM(T) -> Unit
pp.amorim
07/22/2020, 9:20 PMwhen(lastUsedPatients.forEach(any()).thenAnswer {}
could be nice too, I don’t see any problem to reimplement the forEach
using for loop
Tobias Berger
07/22/2020, 11:00 PMpp.amorim
07/22/2020, 11:33 PMpp.amorim
07/22/2020, 11:33 PMpp.amorim
07/22/2020, 11:34 PMmap
Tobias Berger
07/23/2020, 7:09 AMJames Richardson
07/23/2020, 7:59 AMpp.amorim
07/23/2020, 9:03 AMpp.amorim
07/23/2020, 9:06 AMpp.amorim
07/23/2020, 9:06 AMTobias Berger
07/23/2020, 9:27 AMpp.amorim
07/23/2020, 9:40 AMTobias Berger
07/23/2020, 10:28 AMthenReturn
(and not thenAnswer
) this willl always get the same iterator instance which already reached the end of your list.
I think if you want more detailed help, you need to provide a more detailed example that reproduces your issuepp.amorim
07/23/2020, 10:38 AMpp.amorim
07/23/2020, 1:24 PMTobias Berger
07/23/2020, 2:11 PMval user = User(RealmList(message))
Sorry if I seem a bit rude here, I'm really just trying to help. But that's really hard if the error can't be reproducedTobias Berger
07/23/2020, 2:14 PMpp.amorim
07/23/2020, 2:52 PMwhen(messages.iterator()).thenAnswer { messagesList.iterator() }
did the trick, is there any reason for this?pp.amorim
07/23/2020, 2:53 PMTobias Berger
07/23/2020, 3:55 PMiterator()
function. If you mock that with thenReturn(messageList.iterator())
, it will just call that once on messageList and reuse that iterator instance every time you try to get one for your mock. Once your first loop over this iterator is finished, it will always say it has no more items. With thenAnswer
you define a supplier that is called each time your mocked function is used, providing a new iterator for each call (as would be expected)