Issue
Has problem :
given:
someService.getSome(*_) >> Stream.of("A", "B")
when:
someService.getSomeMethod()
then:
noExceptionThrown()
Error: "stream has already been operated upon or closed"
in method "getSomeMethod()" few times are calling someService.getSome(*_) which has to return the same stream. Can somebody help with this case?
Solution
You don't want to return the same Stream, since you can only process each one once. Instead, return identical copies of the Stream:
someService.getSome(*_) >> { Stream.of("A", "B") }
(It's probably also a good idea to be more specific about your expected arguments rather than using *_
.)
Answered By - chrylis -cautiouslyoptimistic-
Answer Checked By - Robin (JavaFixing Admin)