How to capture an argument to a mock? #2050
Answered
by
Vampire
efenderbosch-atg
asked this question in
Q&A
-
LotFileEntity newFile = null
1 * lotFileRepo.saveAll({ List<LotFileEntity> l ->
l[1].guid == existingFile1.guid && l[2].guid == existingFile2.guid && l.size() == 3
}) >> { List<LotFileEntity> l ->
List<LotFileEntity> flattened = l.flatten()
newFile = flattened[0]
flattened
} When I run this I get:
|
Beta Was this translation helpful? Give feedback.
Answered by
Vampire
Dec 10, 2024
Replies: 1 comment 1 reply
-
Is that in a |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
efenderbosch-atg
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is that in a
then
block?If so, then it is moved by the compiler to before the according
when
block.But the first line of your snippet stays in the
then
block and thus is not defined up where the interaction is placed now.Wrap both expressions into an
interaction { ... }
block, then they are moved both together and it should work.