@SuppressWarnings("unchecked")
    private void expectStore(Map<String, Object> key, byte[] keySerialized,
                             Map<String, Object> value, byte[] valueSerialized,
                             final boolean fail,
                             final CountDownLatch waitForCompletion) {
        List<Object> keyWrapped = Arrays.asList(NAMESPACE, key);
        when(keyConverter.fromConnectData(NAMESPACE, null, keyWrapped)).thenReturn(keySerialized);
        when(valueConverter.fromConnectData(NAMESPACE, null, value)).thenReturn(valueSerialized);

        final ArgumentCaptor<Callback<Void>> storeCallback = ArgumentCaptor.forClass(Callback.class);
        final Map<ByteBuffer, ByteBuffer> offsetsSerialized = Collections.singletonMap(
                keySerialized == null ? null : ByteBuffer.wrap(keySerialized),
                valueSerialized == null ? null : ByteBuffer.wrap(valueSerialized));
        when(store.set(eq(offsetsSerialized), storeCallback.capture())).thenAnswer(invocation -> {
            final Callback<Void> cb = invocation.getArgument(1);
            return service.submit(() -> {
                if (waitForCompletion != null)
                    assertTrue(waitForCompletion.await(10000, TimeUnit.MILLISECONDS));

                if (fail) {
                    cb.onCompletion(EXCEPTION, null);
                } else {
                    cb.onCompletion(null, null);
                }
                return null;
            });
        });
    }
Expect a request to store data to the underlying OffsetBackingStore.

@param key the key for the offset
@param keySerialized serialized version of the key
@param value the value for the offset
@param valueSerialized serialized version of the value
@param fail if true, treat
@param waitForCompletion if non-null, a CountDownLatch that should be awaited on before
                         invoking the callback. A (generous) timeout is still imposed to
                         ensure tests complete.
connect/runtime/src/test/java/org/apache/kafka/connect/storage/OffsetStorageWriterTest.java