@Test
public void immutableServiceLifecycle() throws Throwable {

    setUpHost(false);
    URI factoryUri = createImmutableFactoryService(this.host);
    doThroughputPostWithNoQueryResults(false, factoryUri);
    ServiceDocumentQueryResult res = this.host.getFactoryState(factoryUri);
    assertEquals(this.serviceCount, res.documentLinks.size());
    TestContext ctx = this.host.testCreate(res.documentLinks.size());
    ctx.setTestName("DELETE").logBefore();
    for (String link : res.documentLinks) {
        Operation del = Operation.createDelete(this.host, link).setCompletion((o, e) -> {
            ctx.completeIteration();
        });
        this.host.send(del);
    }
    ctx.await();
    ctx.logAfter();
    // verify option validation
    MinimalFactoryTestService f = new MinimalFactoryTestService();
    MinimalFactoryTestService factoryService = (MinimalFactoryTestService) this.host
            .startServiceAndWait(f, UUID.randomUUID().toString(), null);
    factoryService.setChildServiceCaps(
            EnumSet.of(ServiceOption.PERSISTENCE, ServiceOption.IMMUTABLE));
    MinimalTestServiceState body = new MinimalTestServiceState();
    body.id = "id";
    Operation post = Operation.createPost(factoryService.getUri()).setBody(body);
    this.host.sendAndWaitExpectSuccess(post);
    post = Operation.createPost(factoryService.getUri()).setBody(body);
    factoryService.setChildServiceCaps(
            EnumSet.of(ServiceOption.PERSISTENCE,
                    ServiceOption.IMMUTABLE, ServiceOption.PERIODIC_MAINTENANCE));
    // should fail, has PERIODIC_MAINTENANCE
    this.host.sendAndWaitExpectFailure(post);
    post = Operation.createPost(factoryService.getUri()).setBody(body);
    factoryService.setChildServiceCaps(
            EnumSet.of(ServiceOption.PERSISTENCE,
                    ServiceOption.IMMUTABLE, ServiceOption.INSTRUMENTATION));
    // should fail, has INSTRUMENTATION
    this.host.sendAndWaitExpectFailure(post);
}