Search in sources :

Example 1 with Stubber

use of org.mockito.stubbing.Stubber in project imcache by Cetsoft.

the class RedisStreamReaderTest method setupInputStreamRead.

protected void setupInputStreamRead(final byte[] bytes, int chunkSize) throws IOException {
    Stubber stubber = null;
    for (int i = 0; i < bytes.length / chunkSize + 1; i++) {
        int length = (i + 1) * chunkSize < bytes.length ? chunkSize : bytes.length - i * chunkSize;
        @SuppressWarnings("rawtypes") Answer answer = createAnswer(bytes, i * chunkSize, length);
        if (stubber == null) {
            stubber = doAnswer(answer);
        } else {
            stubber = stubber.doAnswer(answer);
        }
    }
    stubber.when(inputStream).read((byte[]) any());
}
Also used : Answer(org.mockito.stubbing.Answer) Stubber(org.mockito.stubbing.Stubber)

Aggregations

Answer (org.mockito.stubbing.Answer)1 Stubber (org.mockito.stubbing.Stubber)1