We have found an interesting issue, that seems to be caused by assertArg. For the following test
verify(mockedService).functionThatExpectsAnInputStream(assertArg((InputStream is) -> {
try {
// Oh my god this thing gets invoked twice !!
assertThat(IOUtils.toByteArray(is),is("a,b,c".getBytes()));
} catch (IOException e) {
fail();
}
}));
The lambda block gets invoked twice, being the IS in the second execution empty.
However if the same logic is done using a regular ArgumentCaptor, it works as expected (a single execution is done):
ArgumentCaptor<InputStream> is = ArgumentCaptor.forClass(InputStream.class);
verify(mockedService).functionThatExpectsAnInputStream(is.capture());
assertThat(is.getValue(),notNullValue());
assertThat(IOUtils.toByteArray(is.getValue()),is("a,b,c".getBytes()));
We could provide further context if needed.
Thank you very much.
We have found an interesting issue, that seems to be caused by assertArg. For the following test
The lambda block gets invoked twice, being the IS in the second execution empty.
However if the same logic is done using a regular ArgumentCaptor, it works as expected (a single execution is done):
We could provide further context if needed.
Thank you very much.