@Test
public void successMigrateSameDocumentsTwiceUsingFallback() throws Throwable {

    // disable idempotent post on destination
    for (VerificationHost host : destinationHost.getInProcessHostMap().values()) {
        host.toggleServiceOptions(UriUtils.buildUri(host, ExampleService.FACTORY_LINK),
                null, EnumSet.of(ServiceOption.IDEMPOTENT_POST));
    }
    // create object in host
    List<ExampleServiceState> states = createExampleDocuments(this.exampleSourceFactory, getSourceHost(),
            this.serviceCount);
    // start migration
    MigrationTaskService.State migrationState = validMigrationState(
            ExampleService.FACTORY_LINK);
    migrationState.migrationOptions = EnumSet.of(MigrationOption.DELETE_AFTER);
    Operation op = Operation.createPost(this.destinationFactoryUri)
            .setBody(migrationState);
    op = this.sender.sendAndWait(op);
    String migrationTaskLink = op.getBody(State.class).documentSelfLink;
    State waitForServiceCompletion = waitForServiceCompletion(migrationTaskLink,
            getDestinationHost());
    ServiceStats stats = getStats(migrationTaskLink, getDestinationHost());
    Long processedDocuments = Long.valueOf((long) stats.entries.get(
            MigrationTaskService.STAT_NAME_PROCESSED_DOCUMENTS).latestValue);
    assertEquals(waitForServiceCompletion.taskInfo.stage, TaskStage.FINISHED);
    assertEquals(Long.valueOf(this.serviceCount), processedDocuments);
    // start second migration, which should use the DELETE -> POST logic since the documents already exist
    for (int i = 0; i < this.iterationCount; i++) {
        this.host.log("Start migration with pre-existing target documents (%d)", i);
        migrationState.documentSelfLink = null;
        op = Operation.createPost(this.destinationFactoryUri)
                .setBody(migrationState);
        op = this.sender.sendAndWait(op);
        migrationTaskLink = op.getBody(State.class).documentSelfLink;
        this.host.log("Created task %s", migrationTaskLink);
        waitForServiceCompletion = waitForServiceCompletion(migrationTaskLink,
                getDestinationHost());
        assertEquals(TaskStage.FINISHED, waitForServiceCompletion.taskInfo.stage);
        stats = getStats(migrationTaskLink, getDestinationHost());
        processedDocuments = Long.valueOf((long) stats.entries
                .get(MigrationTaskService.STAT_NAME_PROCESSED_DOCUMENTS).latestValue);
        assertEquals(Long.valueOf(this.serviceCount), processedDocuments);
        stats = getStats(migrationTaskLink, getDestinationHost());
        processedDocuments = Long.valueOf((long) stats.entries
                .get(MigrationTaskService.STAT_NAME_PROCESSED_DOCUMENTS).latestValue);
    }
    // check if object is in new host
    List<URI> uris = getFullUri(getDestinationHost(), states);
    getDestinationHost().getServiceState(EnumSet.noneOf(TestProperty.class),
            ExampleServiceState.class, uris);
}