i have a class which reads and writes values from/to a byte-buffer.
My write method looks like this:
public void write(final ByteBuffer buffer) {
buffer.putInt(messageLength);
buffer.putShort(version);
foo.write(buffer);
buffer.putInt(checkSum);
...
}
Now i want to write a Unit test for this method and i want the foo-object to be mocked (which is pretty easy). But is it possible that the mocked-foo instance actually does something to the buffer?
In this case when().thenReturn() doesn't help me since the return value is not used.