public static LocalRetryableExecution executeLocallyWithRetry(NodeEngine nodeEngine, Operation operation) {
        if (operation.getOperationResponseHandler() != null) {
            throw new IllegalArgumentException("Operation must not have a response handler set");
        }
        if (!operation.returnsResponse()) {
            throw new IllegalArgumentException("Operation must return a response");
        }
        if (operation.validatesTarget()) {
            throw new IllegalArgumentException("Operation must not validate the target");
        }
        final LocalRetryableExecution execution = new LocalRetryableExecution(nodeEngine, operation);
        execution.run();
        return execution;
    }
@Test
    public void executeLocallyRetriesWhenPartitionIsMigrating() throws InterruptedException {
        final HazelcastInstance instance = createHazelcastInstance(smallInstanceConfig());
        final NodeEngineImpl nodeEngineImpl = getNodeEngineImpl(instance);
        final InternalPartitionService partitionService = nodeEngineImpl.getPartitionService();
        final int randomPartitionId = (int) (Math.random() * partitionService.getPartitionCount());
        final InternalPartitionImpl partition = (InternalPartitionImpl) partitionService.getPartition(randomPartitionId);
        partition.setMigrating();

        final String operationResponse = "operationResponse";
        final Operation operation = new LocalOperation(operationResponse)
                .setPartitionId(randomPartitionId);
        final LocalRetryableExecution execution = executeLocallyWithRetry(nodeEngineImpl, operation);

        spawn((Runnable) () -> {
            try {
                TimeUnit.SECONDS.sleep(10);
            } catch (InterruptedException e) {

            }
            partition.resetMigrating();
        });

        assertTrue(execution.awaitCompletion(1, TimeUnit.MINUTES));
        assertEquals(operationResponse, execution.getResponse());
    }