@Override
    public byte[] next() {
        if(index >= capacity) {
            index = 0;
        }
        if(nonces.size() <= index) {
            final byte[] nonce = new byte[len];
            random.nextBytes(nonce);
            nonces.add(nonce);
        }
        return nonces.get(index++);
    }
@Test
    public void testRotation() {
        final RotatingNonceGenerator generator = new RotatingNonceGenerator(12, 2);
        final byte[] r1 = generator.next();
        final byte[] r2 = generator.next();
        final byte[] r3 = generator.next();
        assertFalse(Arrays.equals(r1, r2));
        assertArrayEquals(r1, r3);
    }