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?
CodePudding user response:
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 *_
.)